[0.3e] Making a respawn unused car command - 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: [0.3e] Making a respawn unused car command (
/showthread.php?tid=412571)
[0.3e] Making a respawn unused car command -
rymax99 - 02.02.2013
Hi, I'd like some help on going about making a command for RCON administrators to respawn the unused cars (not in use by players) Thanks
Re: [0.3e] Making a respawn unused car command -
iManakoss - 02.02.2013
Код:
dcmd_respawncars(playerid,params[])
{
#pragma unused params
if(IsPlayerAdmin(playerid))
{
SendClientMessage(playerid, green, "|- Your have Successfully Respawned all Vehicles! -|");
GameTextForAll("~n~~n~~n~~n~~n~~n~~r~Vehicles ~g~Respawned!", 3000,3);
for(new cars=0; cars<MAX_VEHICLES; cars++)
{
if(!VehicleOccupied(cars))
{
SetVehicleToRespawn(cars);
}
}
return 1;
}
else return ErrorMessages(playerid, 1);
}
You need the include ofc.
Re: [0.3e] Making a respawn unused car command -
]Rafaellos[ - 02.02.2013
"else return ErrorMessages(playerid, 1);"
Change this to:
"else return SendClientMessage(playerid, -1, "Your not RCON Administrator to use that command.");"
Re: [0.3e] Making a respawn unused car command -
Mean - 02.02.2013
Add this function anywhere in your script:
pawn Код:
stock IsVehicleOccupied(vehid) {
for(new i; i <= MAX_PLAYERS; i++)
if(IsPlayerInVehicle(i, vehid)) return 1;
return 0;
}
After that, you can use:
pawn Код:
CMD:respawncars(playerid, params[]) {
if(!IsPlayerAdmin(playerid)) return 0;
for(new i=0; i<MAX_VEHICLES; ++i)
if(!IsVehicleOccupied(i))
SetVehicleToRespawn(i);
return 1;
}
No need for any includes :]