Respawn All Empty Cars
#5

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.
Reply


Messages In This Thread
Respawn All Empty Cars - by wouter0100 - 24.08.2010, 19:34
Re: Respawn All Empty Cars - by boelie - 24.08.2010, 19:49
Re: Respawn All Empty Cars - by wouter0100 - 24.08.2010, 20:19
Re: Respawn All Empty Cars - by boelie - 24.08.2010, 20:24
Re: Respawn All Empty Cars - by Finn - 24.08.2010, 20:32
Re: Respawn All Empty Cars - by wouter0100 - 24.08.2010, 20:33

Forum Jump:


Users browsing this thread: 1 Guest(s)