24.08.2010, 20:32
I hope you've re-defined MAX_VEHICLES and MAX_PLAYERS to the correct amounts.
Edit: Sorry, had a bug in the code. I totally forgot that vehicle IDs start from 1.
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");
}