SA-MP Forums Archive
OnPlayerStateChange isn't being called? - 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: OnPlayerStateChange isn't being called? (/showthread.php?tid=186533)



OnPlayerStateChange isn't being called? - admantis - 29.10.2010

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


Re: OnPlayerStateChange isn't being called? - Jochemd - 29.10.2010

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


Respuesta: Re: OnPlayerStateChange isn't being called? - admantis - 29.10.2010

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.


Re: OnPlayerStateChange isn't being called? - Jochemd - 29.10.2010

It will work, 100% sure.


Re: OnPlayerStateChange isn't being called? - TheHoodRat - 29.10.2010

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.


Respuesta: OnPlayerStateChange isn't being called? - admantis - 29.10.2010

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


Re: OnPlayerStateChange isn't being called? - Jochemd - 29.10.2010

TheHoodRat: It's not needed.