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.
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
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.