Vice City: Multiplayer

VC:MP Discussion => Support => Bugs and Crashes => Topic started by: BeckzyBoi on Jun 30, 2018, 09:34 AM

Title: onPlayerStateChange
Post by: BeckzyBoi on Jun 30, 2018, 09:34 AM
Sometimes onPlayerStateChange is called rapidly (more than once per second) and the oldState and newState are the same. Sorry if this is already known, but I did search the forum for "onPlayerStateChange" and didn't find any such report.
Title: Re: onPlayerStateChange
Post by: kennedyarz on Jun 30, 2018, 01:37 PM
and what kind of reports do you expect? is more used for functions Distance from point to point I suppose. such as executing an action when you are near a point.
Example:

function onScriptLoad()
{
BankIcon <- array(100, null );
}
 
function onPlayerStateChange( player, oldState, newState )
{
if(DistanceFromPoint( player.Pos.x, player.Pos.y,-908.874,-342.258)<50)
{
if(BankIcon[player.ID]==null) BankIcon[player.ID]=CreateMarker(player.UniqueWorld, Vector(-908.874,-342.258,10), 1, RGB(0, 0, 0),24);
}
if(DistanceFromPoint( player.Pos.x, player.Pos.y,-908.874,-342.258)>50)
{
if(BankIcon[player.ID]!=null) DestroyMarker(BankIcon[player.ID]),BankIcon[player.ID]=null;
}
}

which creates an icon when you're near the bank and disappears when you get away
Title: Re: onPlayerStateChange
Post by: BeckzyBoi on Jul 01, 2018, 04:30 AM
Quote from: kennedyarz on Jun 30, 2018, 01:37 PMand what kind of reports do you expect? is more used for functions Distance from point to point I suppose. such as executing an action when you are near a point.
Example:

function onScriptLoad()
{
BankIcon <- array(100, null );
}
 
function onPlayerStateChange( player, oldState, newState )
{
if(DistanceFromPoint( player.Pos.x, player.Pos.y,-908.874,-342.258)<50)
{
if(BankIcon[player.ID]==null) BankIcon[player.ID]=CreateMarker(player.UniqueWorld, Vector(-908.874,-342.258,10), 1, RGB(0, 0, 0),24);
}
if(DistanceFromPoint( player.Pos.x, player.Pos.y,-908.874,-342.258)>50)
{
if(BankIcon[player.ID]!=null) DestroyMarker(BankIcon[player.ID]),BankIcon[player.ID]=null;
}
}

which creates an icon when you're near the bank and disappears when you get away

I expecpted it to be called when the player's state changes from oldState to newState. Thanks for replying anyway.