SA-MP Forums Archive
OnPlayerStateChange won't work - 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)
+--- Thread: OnPlayerStateChange won't work (/showthread.php?tid=553115)



OnPlayerStateChange won't work - gdkparadox - 28.12.2014

Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
switch(GetVehicleModel(GetPlayerVehicleID(playerid)))
	{
        case 601, 598, 427, 523, 497, 421:
        {
			if(GetTeam{playerid} == CLASS_CIV && newstate == PLAYER_STATE_DRIVER)
			{
			    if(GetPlayerLastVehicleID[playerid] != GetPlayerVehicleID(playerid))
			    {
	                new current_zone;
	        		current_zone = Player_Zone[playerid];
					new string[150];
		            format(string,sizeof(string),"[DISPATCH]: Suspect %s [%d] has just stolen a law enforcement vehicle at %s", GetName(playerid), playerid, ZoneNames[current_zone][zone_name]);
	                CopRadio(BLUE, string);
	                SetPlayerWantedLevel(playerid,GetPlayerWantedLevel(playerid) + 4);
	                SendClientMessage(playerid, RED, "Law enforcement vehicle theft [WANTED LEVEL INCREASED]");
	        		return 1;
        		}
			}
        }
}
This piece of code won't work. As a CLASS_CIV player enter a vehicle with those types (601, 598, 427, 523, 497, 421) he won't get SetPlayerWantedLevel(playerid,GetPlayerWantedLevel (playerid) + 4);

Any thoughts? Help will be rewarded with rep.


Re: OnPlayerStateChange won't work - gdkparadox - 28.12.2014

On that "case" line, are there supposed to be the vehicle's IDs or Type?

Still, any help would be awesome.


Re: OnPlayerStateChange won't work - M4D - 28.12.2014

Print your code line by line
I mean like this:

Line 1 bla bla bla
print("#1");
Next Line bla. Bla bla
print("#2");

And see in consol that which line stops your code (debuging > search in wiki )
If you couldn't fix, post here and tell me which line stops your code…
For example if in consol you see:
#1
#2
#3

This mean after print("#3"); your code stops and copy line after print("#3);

But i think your problem is GetPlayerLastVehicleID
I'm not sure but i think..
I'm on my cellphone and i can't test the code. Debug it by yourself and poat here result