Destroy all empty vehicles?
#1

Код:
public VehicleCheck()
{
    new empty = false;
    new currentveh;
    for(new i =0; i != MAX_VEHICLES; ++i)
    {
        for (new x = 0; x != MAX_PLAYERS; ++x)
	{
            if(GetPlayerVehicleID(x) != i)
	    {
		empty = true;
		currentveh = i;
	    }
	}
    }
    if(empty)
    {
	DestroyVehicle(currentveh);
    }
}
This is the code I wrote to attempt to destroy all empty vehicles.
I called it using a timer that runs every 1 second (1000ms) and it doesn't seem to clear up any vehicles that have no one in them. Any ideas?
Reply
#2

pawn Код:
stock VehicleCheck(vehicleid)
{
    for(new i = 0; i < MAX_PLAYERS; i++)    //All players
    {
        if(GetPlayerState(i) == PLAYER_STATE_DRIVER || GetPlayerState(i) == PLAYER_STATE_PASSENGER)
        {
            if(GetPlayerVehicleID(i) == vehicleid)
            {
                return 1;
            }
        }
    }
return 0;
}
Use this.

Inlcude the Destroy Function also. Its not included
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)