Destroying emtpy vehicles
#1

Hello all, i realy have no idea how to delete all empty vehicles.
I mean, on the 5 seconds all the vehicles that are emtpy get destroyed, not where the players are in.
Help me please.
Reply
#2

you mean destroy the unoccupied vehicles which are not in range of any player?

if i were you i'd set the respawn time for the vehicles and that would make it auto respawn
Reply
#3

Use AddStaticVehicleEx to add your vehicles, and set 5 seconds as respawn time. When the player leaves the vehicles, it'll be respawned after 5 seconds.

This forum requires that you wait .. Blah blah blah, waste of time.
Reply
#4

No no, i mean delete all empty vehicles in the whole server. And i dont want respawn, because its stunt server ( /v and /sveh)
Reply
#5

pawn Код:
stock IsVehicleOccupied(vehicleid)
{
    for (new i = 0; i < GetMaxPlayers(); i ++)
    {
        if (GetPlayerVehicleID(playerid) == vehicleid) return true;
    }
    return false;
}
Just written, so untested. This checks if a specific vehicle is occupied. You can use it in a loop through all vehicles to delete all unsused ones. Not the fastest method, but should be fine if you dont want to delete the vehicles every second
Reply
#6

Quote:
Originally Posted by Mauzen
Посмотреть сообщение
pawn Код:
stock IsVehicleOccupied(vehicleid)
{
    for (new i = 0; i < GetMaxPlayers(); i ++)
    {
        if (GetPlayerVehicleID(playerid) == vehicleid) return true;
    }
    return false;
}
Just written, so untested. This checks if a specific vehicle is occupied. You can use it in a loop through all vehicles to delete all unsused ones. Not the fastest method, but should be fine if you dont want to delete the vehicles every second
i think cpu usuage gets affected if he uses every second
Reply
#7

Well i host on my friends vps, so not my problem. But where can i set it? Because i have when you leave a vehicle it removes. But /sveh makes a vehicle infront of you. So i need it to be done in about 10 seconds. So if player leave it, it stays for 10 seconds and he can get in in that 10 seconds. But if no one enters it, then it deletes it.
Because the /sveh is here, now they keep spawning andromada`s at the home spawn point -,-
So how to make in a timer?
Reply
#8

pawn Код:
forward DeleteEmptyVehicles();
public OnGameModeInit()
{
    SetTimer("DeleteEmtpyVehicles", 10000, true);
    return 1;
}

public DeleteEmptyVehicles()
{
    for(new v=0; v<MAX_VEHICLES; v++)
    {
        new count = 0;
        for(new i=0; i<GetMaxPlayers(); i++)
        {
            if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
            {
                if(GetPlayerVehicleID(i) == v) count++;
            }
        }
        if(count > 0)
        {
            DestroyVehicle(v);
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)