SA-MP Forums Archive
Need help - Priv car - 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: Need help - Priv car (/showthread.php?tid=313581)



Need help - Priv car - Twix[KDZ] - 26.01.2012

I got this Private Car system from another member in here. I get error when i compile it. Here is the script:
And yes, my name is NuckFuts, lol

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(vehicleid == NuckFuts)
{
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,sizeof(pName));
if(strcmp(pName,"NuckFuts") == 0)
{
SendClientMessage(playerid,-1,"Welcome to your car, Mang!");
}
else
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid,-1,"This car is payed and reserved for NuckFuts!");
}
}


Re: Need help - Priv car - [XST]O_x - 26.01.2012

That will call the function immediatly when a player is in a radius of a vehicle and trying to enter it. (presses enter or F)
I recommend a usage of OnPlayerStateChange:
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        new pName[24]; GetPlayerName(playerid,pName,24);
        if( (!strcmp(pName,"NuckFuts")) && (GetPlayerVehicleID(playerid) == NuckFuts))
        {
             //....
        }
        else
        {
            RemovePlayerFromVehicle(playerid);
            SendClientMessage(playerid,-1,"This car is payed and reserved for NuckFuts!");
        }
    }
    return 1;
}