SA-MP Forums Archive
[Help]Problem with OnPlayerStateChange - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [Help]Problem with OnPlayerStateChange (/showthread.php?tid=113593)



[Help]Problem with OnPlayerStateChange - Tigerbeast11 - 14.12.2009

I wanna be able to get the players old state like this:

pawn Код:
if(GetPlayerOldState(playerid) == PLAYER_STATE_DRIVER)
How to do this?


Re: [Help]Problem with OnPlayerStateChange - Martin_M - 14.12.2009

Код:
if(oldstate == PLAYER_STATE_DRIVER)



Re: [Help]Problem with OnPlayerStateChange - Tigerbeast11 - 14.12.2009

Quote:
Originally Posted by Martin_M
Код:
if(oldstate == PLAYER_STATE_DRIVER)
would i need a switch?

pawn Код:
switch(oldstate)
?

Also, plz help me with this:

http://forum.sa-mp.com/index.php?topic=138703.0


Re: [Help]Problem with OnPlayerStateChange - Martin_M - 14.12.2009

What do you want to do exactly?
Here you a little example:
Код:
public OnPlayerStateChange(playerid,newstate,oldstate)
{
if(oldstate == PLAYER_STATE_DRIVER) // If i changed my state, and changed from driver to something else
{ // Then..
// Something happens
}
return 1; // OnPlayerStateChange callback return
} // Closing OnPlayerStateChange callback.



Re: [Help]Problem with OnPlayerStateChange - Martin_M - 14.12.2009

Sorry for double post. Mistake.


Re: [Help]Problem with OnPlayerStateChange - Tigerbeast11 - 14.12.2009

I just wanted to check if I would need a switch. I wanna send a msg to evryone if they exit the car.


Re: [Help]Problem with OnPlayerStateChange - LarzI - 14.12.2009

No you don't need a switch statement.
Switch statements are only useful if you want to check for if var is equal to more than one value

Example
pawn Код:
switch(oldstate)
{
  case PLAYER_STATE_DRIVER: { /*something*/ }
  case PLAYER_STATE_PASSENGER: { /*something else*/ }
}
If you only want to check for one state, then a switch statement isn't necesarry.


Re: [Help]Problem with OnPlayerStateChange - Tigerbeast11 - 14.12.2009

Quote:
Originally Posted by lrZ^ aka LarzI
No you don't need a switch statement.
Switch statements are only useful if you want to check for if var is equal to more than one value

Example
pawn Код:
switch(oldstate)
{
  case PLAYER_STATE_DRIVER: { /*something*/ }
  case PLAYER_STATE_PASSENGER: { /*something else*/ }
}
If you only want to check for one state, then a switch statement isn't necesarry.
K, thnx!


Re: [Help]Problem with OnPlayerStateChange - LarzI - 14.12.2009

No problem