Automatic respawn for unused vehicules.
#10

He's trying to ask for a timer that will not respawn cars, if they have not moved. You could try using something like this I guess:

pawn Код:
enum Vehicledata
{
    Float:PosX,
    Float:PosY,
    Float:PosZ
}
new Vehicleinfo[MAX_VEHICLES][Vehicledata];

public OnVehicleSpawn(vehicleid)
{
    new Float:x, Float:y, Float:z;
    GetVehiclePos(vehicleid, x, y, z);
    Vehicleinfo[vehicleid][PosX] = x;
    Vehicleinfo[vehicleid][PosY] = y;
    Vehicleinfo[vehicleid][PosZ] = z;
    return 1;
}

forward RespawnVehicles( );
public RespawnVehicles( )
{
    new vehicles[ MAX_VEHICLES ];
    for( new i = 0; i < MAX_PLAYERS; i ++ )
    {
        if( IsPlayerInAnyVehicle( i ) )
        {
            vehicles[ GetPlayerVehicleID( i ) ] = 1;
        }
    }

    for( new v = 0; v < MAX_VEHICLES; v ++ )
    {
        if( vehicles[ v ] == 1) continue;
        if(GetVehicleDistanceFromPoint(v, Vehicleinfo[v][PosX], Vehicleinfo[v][PosY], Vehicleinfo[v][PosZ]) <= 3.0) continue; //Change 3.0 if you want, this is just a slightly more accurate float.
        SetVehicleToRespawn( v );
    }
    return 1;
}
Give it a shot, if it doesn't work on the first respawn, it will work for the rest.

EDIT: It's nice to see my name in a post

btw... this should be || not &&
pawn Код:
if( vehicles[ v ] == 1 || setspawn[v ] == 0 ) continue;
Reply


Messages In This Thread
Automatic respawn for unused vehicules. - by Kethrios - 22.01.2013, 08:34
Re: Automatic respawn for unused vehicules. - by _Mohit_ - 22.01.2013, 08:37
Re: Automatic respawn for unused vehicules. - by _Mohit_ - 22.01.2013, 08:40
Re: Automatic respawn for unused vehicules. - by Jewell - 22.01.2013, 08:44
Re : Automatic respawn for unused vehicules. - by Kethrios - 22.01.2013, 08:45
Re: Automatic respawn for unused vehicules. - by _Mohit_ - 22.01.2013, 08:45
Re: Automatic respawn for unused vehicules. - by Jewell - 22.01.2013, 08:47
Re: Automatic respawn for unused vehicules. - by Jewell - 22.01.2013, 09:00
Re : Re: Automatic respawn for unused vehicules. - by Kethrios - 22.01.2013, 09:14
Re: Automatic respawn for unused vehicules. - by Threshold - 22.01.2013, 09:15

Forum Jump:


Users browsing this thread: 3 Guest(s)