OnPlayerStateChange isn't being called?
#1

Hello everybody, my problem is OnPlayerStateChange isn't being called properly. Please look in my script
pawn Код:
public OnPlayerStateChange(playerid,newstate,oldstate)
{
    if (newstate == PLAYER_STATE_DRIVER && oldstate == PLAYER_STATE_ONFOOT)
    {
        new veh = GetPlayerVehicleID(playerid);
        if (veh == 425 || veh == 520)
        {
            if (PlayerInfo[playerid][pPermissons] == 0)
            {
                SendClientMessage(playerid,COLOR_WHITE,"You don't have got permissons to use this vehicle!");
                RemovePlayerFromVehicle(playerid);
            }
            else if (PlayerInfo[playerid][pPermissons] > 0)
            {
                SendClientMessage(playerid,COLOR_WHITE,"You have used 1 permisson for using this vehicle !");
                PlayerInfo[playerid][pPermissons]--;
                new string[64], pname[MAX_PLAYER_NAME];
                GetPlayerName(playerid, pname, sizeof(pname));
                format(string, sizeof(string), "%s has used a permisson!", pname);
                print(string);
            }
        }
    }
    return 1;
}
No errors nor warnings when compiled but In Game it doesnt work
please give me a hand
Reply
#2

You have used GetPlayerVehicleID, but that will get the players' car ID (builded car ID) ingame. Use GetVehicleModel(GetPlayerVehicleID(playerid)) instead.
Reply
#3

Quote:
Originally Posted by Jochemd
Посмотреть сообщение
You have used GetPlayerVehicleID, but that will get the players' car ID (builded car ID) ingame. Use GetVehicleModel(GetPlayerVehicleID(playerid)) instead.
I will try, thank you. if it works or not i will respond here.
Reply
#4

It will work, 100% sure.
Reply
#5

You forgot to return the codes before the closing braces. Therefore, the script is only reading the braces, here, try now. If it doesn't work, I'll still help you, but I gotta look into it more.

pawn Код:
public OnPlayerStateChange(playerid,newstate,oldstate)
{
    if (newstate == PLAYER_STATE_DRIVER && oldstate == PLAYER_STATE_ONFOOT)
    {
        new veh = GetPlayerVehicleID(playerid);
        if (veh == 425 || veh == 520)
        {
            if (PlayerInfo[playerid][pPermissons] == 0)
            {
                SendClientMessage(playerid,COLOR_WHITE,"You don't have got permissons to use this vehicle!");
                RemovePlayerFromVehicle(playerid);
                return 1;
            }
            else if (PlayerInfo[playerid][pPermissons] > 0)
            {
                SendClientMessage(playerid,COLOR_WHITE,"You have used 1 permisson for using this vehicle !");
                PlayerInfo[playerid][pPermissons]--;
                new string[64], pname[MAX_PLAYER_NAME];
                GetPlayerName(playerid, pname, sizeof(pname));
                format(string, sizeof(string), "%s has used a permisson!", pname);
                print(string);
                return 1;
            }
        }
    }
    return 1;
}
Not tested because I don't have your PlayerInfo enum. Try it out, see how it is.
Reply
#6

OSHIT It works D Thank yoou i will put you in credits ^^
EDIT: TheHoodRat thanks for that tip I forgot as well thanks
Reply
#7

TheHoodRat: It's not needed.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)