[Ajuda] Ajuda com comando de respawnar veнculos desocupados.
#1

Pessoal criei um comando aqui que serve para resetar os veнculos desocupados no servidor, sendo assim, voltando ao seu local de spawn.. mas, tem uma coisa, o trailer 'anexado' ao caminhгo, tambйm й respawnado, e eu gostaria que alguйm podesse fazer com que esse comando nгo surta efeito em trailers anexados ao caminhгo. Obrigado a quem me ajudar!

PHP Code:
COMMAND:rc(playeridparams[])
{
    
SendAdminText(playerid"/rc"params);
    if (
APlayerData[playerid][LoggedIn] == true)
    {
        
        if (
APlayerData[playerid][PlayerLevel] >= 3)
        {
            
            
SendClientMessageToAll(0x00FF00FF#Todos os veнculos foram resetados pelo admin");
            
ResetarCarros();
        }
        else
        return 
0;
    }
    else
    return 
0;
    return 
1;

PHP Code:
stock ResetarCarros() //Creditos: thegarfield
{
    static 
bool:inVeh;
    for(new 
iMAX_VEHICLESi++ )
    {
        
inVeh false;
        for(new 
jGetMaxPlayers(); j++ )
        {
            if(
IsPlayerInVehiclej))
            
inVeh true;
            break;
        }
        if(!
inVehSetVehicleToRespawn(i);
   }

Reply
#2

O Trailer й tambйm um veнculo e tem o seu ID. Sу que й um tipo de veнculo que nгo da para entrar

Vб no seu samp e digite /dl, pegue o id dos trailers que vocк queira que nгo de respawn depois poste aqui o numero dos id's
Reply
#3

435, 450, 584, 591, 606, 607, 608, 610, 611.
Reply
#4

Vк se funciona,
Se vocк nгo tiver a variбvel carid no seu GM , fale que eu posto aqui

pawn Code:
COMMAND:rc(playerid, params[])
{
    SendAdminText(playerid, "/rc", params);
    if (APlayerData[playerid][LoggedIn] == true)
    {
         
        if (APlayerData[playerid][PlayerLevel] >= 3)
        {
             
            SendClientMessageToAll(0x00FF00FF, #Todos os veнculos foram resetados pelo admin");
            ResetarCarros();
        }
        else if((carid >= 435) || (carid == 450) || (carid == 584) || (carid == 591) || (carid == 606)) && (carid <= 611))
        {
            return 1;
        }
        return 0;
    }
    else
    return 0;
    return 1;
}
Reply
#5

Amigo, eu nгo tenho a variбvel carid, poderia me passar?
Reply
#6

carid й o model carro

mas ele fez isso mal ...
oh cara, entao voce, so depois de todos os veiculos terem sido spawnados й que vai obter o id?


pawn Code:
stock ResetarCarros() //Creditos: thegarfield
{
    static bool:inVeh;
    new carid;
    for(new i; i < MAX_VEHICLES; i++ )
    {
        carid=GetVehicleModel(i);
        inVeh = false;
        for(new j; j < GetMaxPlayers(); j++ )
        {
            if((carid >= 435) || (carid == 450) || (carid == 584) || (carid == 591) || (carid == 606)) && (carid <= 611)) continue;
            if(IsPlayerInVehicle( j, i ))
                inVeh = true;
                break;
        }
        if(!inVeh) SetVehicleToRespawn(i);
   }
}
Reply
#7

Linha:

PHP Code:
if((carid >= 435) || (carid == 450) || (carid == 584) || (carid == 591) || (carid == 606)) && (carid <= 611)) continue; 
Erro:

PHP Code:
error 001expected token";"but found ")" 
O que pode ser?
Reply
#8

Olб colega, talves isso pode ser sua soluзгo, nгo custa tentar.


PHP Code:
    if(strcmp(cmd"/rv"true) == 0)
    {
        if(
pAdmin[playerid] > 3)
        {
            for(new 
0MAX_VEHICLESv++)
            {
                if(!
IsVehicleOccupied(v)) SetVehicleToRespawn(v);
            }
            
format(stringsizeof(string), "O(A) ADM %s (%d) respawnou todos os veнculos desocupados."GetPlayerNameEx(playerid), playerid);
            
SendClientMessageToAll(tcadmstring);
            
SendClientMessage(playeridVerde"Veнculos desocupados respawnados!");
        }
        return 
1;
    } 
Stock:

PHP Code:
stock IsVehicleOccupied(vehicleid)
{
    for(new 
0MAX_PLAYERSi++)
    {
        if(
IsPlayerConnected(i))
        {
            if(
GetPlayerState(i) == PLAYER_STATE_DRIVER || GetPlayerState(i) == PLAYER_STATE_PASSENGER)
            {
                if(
GetPlayerVehicleID(i) == vehicleid)
                {
                    return 
1;
                }
            }
        }
    }
    return 
0;

Usava em meu antigo servidor, basta vocк configurar corretamente o comando e pronto, espero ter ajudado.
Reply
#9

Quote:
Originally Posted by DartakousLien
View Post
carid й o model carro

mas ele fez isso mal ...
oh cara, entao voce, so depois de todos os veiculos terem sido spawnados й que vai obter o id?


pawn Code:
stock ResetarCarros() //Creditos: thegarfield
{
    static bool:inVeh;
    new carid;
    for(new i; i < MAX_VEHICLES; i++ )
    {
        carid=GetVehicleModel(i);
        inVeh = false;
        for(new j; j < GetMaxPlayers(); j++ )
        {
            if((carid >= 435) || (carid == 450) || (carid == 584) || (carid == 591) || (carid == 606)) && (carid <= 611)) continue;
            if(IsPlayerInVehicle( j, i ))
                inVeh = true;
                break;
        }
        if(!inVeh) SetVehicleToRespawn(i);
   }
}
Nгo deu certo, agora estб resetando todos os veнculos, atй mesmo os que estгo ocupados! :/
me ajudem
Reply
#10

tira o segundo parentes aqui (carid == 606))
pawn Code:
stock ResetarCarros() //Creditos: thegarfield
{
    static bool:inVeh;
    new carid;
    for(new i; i < MAX_VEHICLES; i++ )
    {
        carid=GetVehicleModel(i);
        inVeh = false;
        for(new j; j < GetMaxPlayers(); j++ )
        {
            if((carid >= 435) || (carid == 450) || (carid == 584) || (carid == 591) || (carid == 606) && (carid <= 611)){
                 if(IsPlayerInVehicle( j, i )){
                    inVeh = true;  
                 }
            }
        }
        if(!inVeh) SetVehicleToRespawn(i);
   }
}
Reply
#11

Nгo deu certo, ainda estб resetando os trailers!
Reply
#12

Eu acho que trailer nгo й considerado veiculo, tem que fazer um esquema ai...
Reply
#13

pode me ajudar com isto?
Reply
#14

Quote:
Originally Posted by AndersonAq
View Post
Nгo deu certo, ainda estб resetando os trailers!
troca

pawn Code:
if((carid >= 435) || (carid == 450) || (carid == 584) || (carid == 591) || (carid == 606) && (carid <= 611)){
    if(IsPlayerInVehicle( j, i )){
        inVeh = true;  
    }
}
por

pawn Code:
if(IsPlayerInVehicle( j, i )){
    inVeh = true;
}
Reply
#15

agora nгo estб resetando nenhum veнculo..
Reply
#16

alguйm pode me ajudar por favor?
Reply
#17

pawn Code:
stock ResetarCarros() //Creditos: thegarfield
{
    static bool:inVeh;
    static bool:isTrailer;
    new carid;
    for(new i; i < MAX_VEHICLES; i++ )
    {
        carid=GetVehicleModel(i);
        inVeh = false;
        isTrailer = true;
        if((carid != 435) || (carid != 450) || (carid != 584) || (carid != 591) || (carid != 606) ||(carid != 607) || (carid != 608) || (carid != 609) || (carid != 610) || (carid != 611)){
        isTrailer= false;
        for(new j; j < GetMaxPlayers(); j++ )
       {
                 if(IsPlayerInVehicle( j, i )){
                    inVeh = true;  
                    break;
                 }
            }
        }
       
        if(!inVeh && !isTrailer) SetVehicleToRespawn(i);
   }
}
Peзo desculpa pela identacao mas tou a escrever no tele ^^ experimenta agr, se continuar a n dar, tira o break
Reply
#18

Erro:

PHP Code:
error 017undefined symbol "i" 
Linha:

PHP Code:
if(!inVehSetVehicleToRespawn(i); 
Reply
#19

Peзo desculpa, tira a { q ta antes dessa linha, por cima de if(!InVeh)
Reply
#20

troca "i" por "playerid"
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)