SA-MP Forums Archive
[Ajuda] respawnando trailer do caminhгo - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Ajuda] respawnando trailer do caminhгo (/showthread.php?tid=586498)



respawnando trailer do caminhгo - Killer21 - 22.08.2015

Galera, criei o comando de respawnar veiculos desocupados no server, mas se o player estiver trabalhando de caminhoeiro levando um trailer, o trailer tambem й respawnado :/

PHP код:
CMD:respawn(playerid, params[])
{
    if(
PlayerInfo[playerid][Admin] == 1)
    {
        new 
String[100], Nome[MAX_PLAYER_NAME];
        
GetPlayerName(playerid, Nome, sizeof(Nome));
        
format(String, sizeof(String), "[PL-ADMIN] O Administrador {1BA5E0}%s{00C2EC} deu respawn em todos os veнculos", Nome);
        
SendClientMessageToAll(AZUL_CLARO, String);
        for(new 
v = 0; v < MAX_VEHICLES; v++)
        {
        if(!
IsVehicleOccupied(v)) SetVehicleToRespawn(v);
        }
    }
    else
    {
         
SendClientMessage(playerid, CRIMSON, "[ERRO] Vocк nгo й um Administrador.");
    }
    return 
1;
} 
PHP код:
IsVehicleOccupied(vehicleid)
{
for(new 
i = 0; i < MAX_PLAYERS; i++) if(IsPlayerInVehicle(i, vehicleid) && GetPlayerState(i) == PLAYER_STATE_DRIVER)
return 
1; return 0;
} 



Re: respawnando trailer do caminhгo - iTakelot - 22.08.2015

PHP код:
CMD:respawn(playerid, params[])
{
    if(
PlayerInfo[playerid][Admin] < 2) return SendClientMessage(playerid, -1, "{ff0000}Vocк precisa ser admin nivel 2 para usar este comando!");
    for(new 
i; i < MAX_VEHICLES; i++)
    if(!
IsVehicleInUse(i))
    
SetVehicleToRespawn(i);
    return 
1;
} 
Stock

PHP код:
stock IsVehicleInUse(vehicleid)
{
    new 
Veiculo;
    for(new 
i; i < MAX_PLAYERS; i++)
    {
        if(
GetPlayerVehicleID(i) == vehicleid)
        
Veiculo = vehicleid;
        if(
GetVehicleTrailer(GetPlayerVehicleID(i)) == vehicleid)
        
Veiculo = vehicleid;
    }
    return 
Veiculo;
}