OnPlayerStateChange[SOLVED]
#1

i would like to set player wanted level by 1 if a civilian enters a civilian car. but if he enters a cop car his wanted level will go up by 4 stars...
how do i do that? pls help
Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
	if(gTeam[playerid] == TEAM_CIVILIAN)
	{
		if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
		{
 			new wanted = GetPlayerWantedLevel(playerid);
			new vehicleid = GetVehicleModel(playerid);
			switch(vehicleid)
  			{
		  			case 400: SetPlayerWantedLevel(playerid, wanted + 1);//landstalker
		  			case 401: SetPlayerWantedLevel(playerid, wanted + 1);//bravura
		            case 402: SetPlayerWantedLevel(playerid, wanted + 1);//buffalo
                    case 523: SetPlayerWantedLevel(playerid, wanted + 4);//Hpv-1000
                    case 598: SetPlayerWantedLevel(playerid, wanted + 4);//Cop Car LV
                               ...
             }
         }
     }
     return 1;

}
Reply
#2

When you compile this, does it give you errors? If so, post them here.
Reply
#3

Quote:
Originally Posted by randomkid88
When you compile this, does it give you errors? If so, post them here.
no, only in game when i enter a car it doesnt do anything...
Reply
#4

Ok, try this. Where you have "wanted + 1" change to "wanted++" and "wanted + 4" to "wanted+4"

pawn Код:
case 400: SetPlayerWantedLevel(playerid, wanted++);//landstalker
case 401: SetPlayerWantedLevel(playerid, wanted++);//bravura
case 402: SetPlayerWantedLevel(playerid, wanted++ );//buffalo
case 523: SetPlayerWantedLevel(playerid, wanted+4);//Hpv-1000
case 598: SetPlayerWantedLevel(playerid, wanted+4);//Cop Car LV
Reply
#5

instead of a case do the last one at


default: { //docar stuff }

default will run when your case's dont apply
Reply
#6

Quote:
Originally Posted by randomkid88
Ok, try this. Where you have "wanted + 1" change to "wanted++" and "wanted + 4" to "wanted+4"

pawn Код:
case 400: SetPlayerWantedLevel(playerid, wanted++);//landstalker
case 401: SetPlayerWantedLevel(playerid, wanted++);//bravura
case 402: SetPlayerWantedLevel(playerid, wanted++ );//buffalo
case 523: SetPlayerWantedLevel(playerid, wanted+4);//Hpv-1000
case 598: SetPlayerWantedLevel(playerid, wanted+4);//Cop Car LV
no, it doesnt work. i think the problem is in getvehiclemodel or something with the switch
Reply
#7

You could try switching it to OnPlayerEnterVehicle. Make sure you do
pawn Код:
if(!ispassenger)
{
   //switch stuff here
}
That way it only sets wanted level if they are entering as driver. You could take it out if you want.
Reply
#8

Quote:
Originally Posted by (SF)Noobanatior
instead of a case do the last one at


default: { //docar stuff }

default will run when your case's dont apply
ok, i put default at the end and commented all the civilian cars now it gives me +1 wanted level for any stolen car but for police cars too.
what do i do now? i need to get 4 stars on entering a police car.
Reply
#9

or add if(!IsPlayerInAnyVehicle(playerid))print("player not in car yet);

to make sure they are in the car when this code runs
Reply
#10

Quote:
Originally Posted by randomkid88
You could try switching it to OnPlayerEnterVehicle. Make sure you do
pawn Код:
if(!ispassenger)
{
   //switch stuff here
}
That way it only sets wanted level if they are entering as driver. You could take it out if you want.
i tried but it sets my level when im going to enter it, not when im already inside the car...
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)