SA-MP Forums Archive
Strange problem with OnPlayerEnterVehicle - 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: Strange problem with OnPlayerEnterVehicle (/showthread.php?tid=491068)



Strange problem with OnPlayerEnterVehicle - barts - 29.01.2014

This script works when its under OnPlayerStateChange:
PHP код:
    if(newstate == 2)
    {
        new 
CarCheck GetPlayerVehicleID(playerid);
        if(
CarCheck == Cars[Taxi1] || CarCheck == Cars[Taxi2] || CarCheck == Cars[Taxi3] || CarCheck == Cars[Taxi4] || CarCheck == Cars[Taxi5] || CarCheck == Cars[Taxi6] || CarCheck == Cars[Taxi7] || CarCheck == Cars[Taxi8] || CarCheck == Cars[Taxi8] || CarCheck == Cars[Taxi9] || CarCheck == Cars[Taxi10] || CarCheck == Cars[Taxi11] || CarCheck == Cars[Taxi12] || CarCheck == Cars[Taxi13] || CarCheck == Cars[Taxi14] || CarCheck == Cars[Taxi15] || CarCheck == Cars[Taxi16] || CarCheck == Cars[Taxi17] )
        {
            if(
PlayerInfo[playerid][pJob] != JOB_TAXIDRIVER)
            {
            
RemovePlayerFromVehicle(playerid);
            
SendClientMessage(playeridCOLOR_ORANGE" You can't start the engine as it belongs to the Taxi Drivers.");
            return 
1;
            }
        }
        new 
CarCheck2 GetPlayerVehicleID(playerid);
        if(
CarCheck2 == Cars2[Mech1] || CarCheck2 == Cars2[Mech2] || CarCheck2 == Cars2[Mech3] || CarCheck2 == Cars2[Mech4] || CarCheck2 == Cars2[Mech5] )
        {
            if(
PlayerInfo[playerid][pJob] != JOB_MECHANIC)
            {
            
RemovePlayerFromVehicle(playerid);
            
SendClientMessage(playeridCOLOR_ORANGE" You can't start the engine as it belongs to the Mechanics.");
            return 
1;
            }
        }
    } 
But when i put it under OnPlayerEnterVehicle it dont work(I remove the line if(newstate == 2))


Re: Strange problem with OnPlayerEnterVehicle - Scottas - 29.01.2014

That's because OnPlayerEnter vehicle is called when player starts to enter vehicle, so you can't remove him from vehicle, because he isn't in vehicle.


Re: Strange problem with OnPlayerEnterVehicle - barts - 29.01.2014

But i changed the thing to:
Quote:

new Floatos[3];
GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
SetPlayerPos(playerid, pos[0], pos[1], pos[2]);

and it dont works


Re: Strange problem with OnPlayerEnterVehicle - Threshold - 29.01.2014

Or you can try ClearAnimations(playerid); under OnPlayerEnterVehicle..