Detecting if trailer is attached or not
#1

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;
}
Reply
#2

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)