OnPlayerStateChange bugged
#1

Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
	if(newstate == PLAYER_STATE_DRIVER)
    {
        if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 596 || 597 || 598 || 599 || 601 || 427)
        {
            if(gTeam[playerid] == CIV)
            {
                SendClientMessage(playerid, COLOR_RED, "WARNING: You just stole a police car, your wanted level has been increased!");
                SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid)+3);
            }
        }
    }
	return 1;
}
When I enter any car as a CIV, it sends the warning message. It's supposed to be for all the police cars, but it does it for any car.
Reply
#2

pawn Код:
GetVehicleModel(GetPlayerVehicleID(playerid)) == 596 || 597 || 598 || 599 || 601 || 427
This is wrong. It hurts my eyes.

Try this:
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        new vmid = GetVehicleModel(GetPlayerVehicleID(playerid));
        if(vmid == 596 || vmid == 597 || vmid == 598 || vmid == 599 || vmid == 601 || vmid == 427)
        {
            if(gTeam[playerid] == CIV)
            {
                SendClientMessage(playerid, COLOR_RED, "WARNING: You just stole a police car, your wanted level has been increased!");
                SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid)+3);
            }
        }
    }
    return 1;
}
Reply
#3

A function is a better choice.

pawn Код:
IsPoliceCar(model)
{
    switch(model) { case 596, 597, 598,  599, 601, 427: { return 1; } }
    return 0;
}
Reply
#4

Your code worked, Jachu! Thank you!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)