SA-MP Forums Archive
Problem with this - 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: Problem with this (/showthread.php?tid=310645)



Problem with this - Face9000 - 13.01.2012

Hello,i maked a small limit to vehicles,players must wait 5 seconds each before entering in a vehicle:

OnPlayerStateChange

pawn Код:
if(GetPVarInt(playerid,"VWTIMER")>GetTickCount())return SendClientMessage(playerid,0xFF0000FF,"You must wait 5 seconds before entering in a vehicle again.");
   SetPVarInt(playerid,"VWTIMER",GetTickCount()+5000);
   RemovePlayerFromVehicle(playerid);
But dont work,what's wrong?


Re: Problem with this - JamesC - 13.01.2012

The problem is that you do not remove the player from the vehicle in any way as you are returning return an error message and thus making everything that comes after it not execute. This is why it is important for your code to have a logical flow.

pawn Код:
if(GetPVarInt(playerid,"VWTIMER")>GetTickCount()) {
    SendClientMessage(playerid,0xFF0000FF,"You must wait 5 seconds before entering in a vehicle again.");
    SetPVarInt(playerid,"VWTIMER",GetTickCount()+5000);
    RemovePlayerFromVehicle(playerid);
    return 1;
}



Re: Problem with this - Face9000 - 13.01.2012

Thank you.