Respawn All Empty Cars - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Respawn All Empty Cars (
/showthread.php?tid=170947)
Respawn All Empty Cars -
wouter0100 - 24.08.2010
Hello,
I have a script for respawn all cars and i wil a script for empty cars..
I have this script: (And only for RCON
)
Code:
if(!strcmp(cmdtext, "/respawncar", true))
{
for(new i = 0; i < MAX_VEHICLES; i++)
{
SetVehicleToRespawn(i);
}
return 1;
}
Thanks
Re: Respawn All Empty Cars -
boelie - 24.08.2010
Code:
RespawnEmptyCars();
public RespawnEmptyCars()
{
for(new i=0; i<MAX_VEHICLES; i++)
{
for(new pl = 0; pl<MAX_PLAYERS; pl++)
{
if(IsPlayerConnected(pl))
{
if(!IsVehicleInUse(i))//if(!IsPlayerInVehicle(pl, i))
{
SetVehicleToRespawn(i);
}
}
}
}
}
Edit:
Code:
stock IsVehicleInUse(vehicleid)
{
for(new i=0; i<GetMaxPlayers(); i++)
{
if(IsPlayerConnected(i))
{
if(GetPlayerVehicleID(i) == vehicleid)
return true;
}
}
return false;
}
you need both to work
Re: Respawn All Empty Cars -
wouter0100 - 24.08.2010
Not work
or what is the command? /RespawnEmptyCars? (And i have logged in in rcon....)
Re: Respawn All Empty Cars -
boelie - 24.08.2010
Code:
if (strcmp(cmdtext, "/respawncars", true) == 0)
{
if(IsPlayerAdmin(playerid))
{
RespawnEmptyCars();
}
else
{
SendClientMessage(playerid,COLOR_WHITE,"Only rcon admins can use this command");
}
return 1;
}
Re: Respawn All Empty Cars -
Finn - 24.08.2010
I hope you've re-defined
MAX_VEHICLES and
MAX_PLAYERS to the correct amounts.
pawn Code:
stock SetEmptyVehiclesToRespawn()
{
new bool:activeveh[MAX_VEHICLES + 1], tempveh;
for(new i; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
tempveh = GetPlayerVehicleID(i);
if(tempveh != INVALID_VEHICLE_ID)
{
activeveh[tempveh] = true;
}
}
}
for(new v = 1; v < (MAX_VEHICLES + 1); v++)
{
if(!activeveh[v])
{
SetVehicleToRespawn(v);
}
}
return 1;
}
pawn Code:
if(strcmp(cmdtext, "/respawncars", true) == 0)
{
if(IsPlayerAdmin(playerid))
{
SetEmptyVehiclesToRespawn();
return 1;
}
else return SendClientMessage(playerid, COLOR_WHITE, "Only rcon admins can use this command");
}
Edit: Sorry, had a bug in the code. I totally forgot that vehicle IDs start from 1.
Re: Respawn All Empty Cars -
wouter0100 - 24.08.2010
TY ALL