SA-MP Forums Archive
Anti unoccupied vehicle teleport - 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: Anti unoccupied vehicle teleport (/showthread.php?tid=402194)



Anti unoccupied vehicle teleport - Vvolk - 25.12.2012

Hello everybody. I want to make protection against unoccupied vehicle teleport, but I don't realy know how to make it, only I know that I need onunoccupiedvehicleupdate callback. In this video is shown this protection: [ame]http://www.youtube.com/watch?v=nYN69GRp5qs[/ame]

Who can give me code or explain something about that?


Re: Anti unoccupied vehicle teleport - park4bmx - 25.12.2012

pawn Код:
//the function
COMMAND:cleanv(playerid, params[])
{
new TotalVeh=0;
for(new vehicles=0; vehicles < MAX_VEHICLES; vehicles++)
{
    if(IsAnyPlayerInVehicle(vehicles)==0)
    {
        DestroyVehicle(vehicles);
        TotalVeh++;
    }
printf("%d Vehicles Cleaned!",TotalVeh);//you can change it to return the msg to the player
}
return 1;
}
//The stock
stock IsAnyPlayerInVehicle(vehicleid)
{
for(new playerids=0; playerids < MAX_PLAYERS; playerids++)
{
    if(IsPlayerInVehicle(playerids, vehicleid)==1) return true;
    else return false;
}
return false;
}
This will remove any vehicle without a driver!
NOTE: this can be done better, but this is for a example.