SA-MP Forums Archive
trailer respawning when it is attacthed - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: trailer respawning when it is attacthed (/showthread.php?tid=623669)



trailer respawning when it is attacthed - bugmenotlol - 03.12.2016

i have this code to respawn unocupied vehicles in the server
PHP код:
stock IsVehicleOccupied(vehicleid)
{
for(new 
i=0;i<MAX_PLAYERS;i++)
{
if(
IsPlayerInVehicle (i,vehicleid)) return 1;
}
return 
0;

the prob is when i use this the trailer that is attacthed to truck also will respawn
how to fix it ??


Re: trailer respawning when it is attacthed - Banditul18 - 03.12.2016

I have this codes:
Код:
 IsVehicleEmpty(vehicleid)
{
        foreach(new i: Player)
        {
            if(IsPlayerInVehicle(i, vehicleid)) return 0;
        }
        return 1;
}
IsTrailerAttached(trailerid)
{
    for(new i = 1, j=GetVehiclePoolSize(); i <=j ; i++)
    {
        if(GetVehicleTrailer(i) == trailerid) // Check if this trailer attached to another vehicle
        {
            return true;
        }
    }
    return false;
}
And I use them like this
Код:
 vmod = GetVehicleModel(car);
        if(vmod == 435 || vmod == 450 || vmod == 584) // Check if it's a trailer
        {
            if(!IsTrailerAttached(car))
                SetVehicleToRespawn(car);
        }
        else
            if(IsVehicleEmpty(car)) SetVehicleToRespawn(car);
Maybe will help you


Re: trailer respawning when it is attacthed - bugmenotlol - 04.12.2016

Can u give more codes ?
like ur codes when using respawn command