SA-MP Forums Archive
Detecting if trailer is attached or not - 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: Detecting if trailer is attached or not (/showthread.php?tid=497421)



Detecting if trailer is attached or not - iOxide - 26.02.2014

Hi,

I am making a respawnall cmd but i need to detect if the player has trailer attached to their truck or not so it won't respawn the attached trailer. Only unused trailer will be respawned. Any help?

pawn Код:
CMD:respawnallveh(playerid, params[])
{
    new Msg[128], AdName[24];

    SendAdminText(playerid, "/respawnallveh", params);

    if (APlayerData[playerid][LoggedIn] == true)
    {
       if (APlayerData[playerid][PlayerLevel] >= 3)
       {
           for(new i=0; i<MAX_VEHICLES; i++)
           {
               if(IsVehicleEmpty(i)) SetVehicleToRespawn(i);
           }
           GetPlayerName(playerid, AdName, sizeof(AdName));
           format(Msg, sizeof(Msg), "** Administrator %s has respawned all the vehicles.", AdName);
           SendClientMessageToAll(ADCOLOR, Msg);
       }
       else
           return 0;
    }
    else
        return 0;
    return 1;
}

stock IsVehicleEmpty(vehicleid)
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerInVehicle(i, vehicleid)) return 0;
    }
    return 1;
}



Re: Detecting if trailer is attached or not - Ryan_Undering - 26.02.2014

I suppose you could try checking each vehicle for a trailer attached and exclude any trailer that is from the respawn...

Refer to : https://sampwiki.blast.hk/wiki/GetVehicleTrailer