SA-MP Forums Archive
[Ajuda] GetVehicleTrailer - 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] GetVehicleTrailer (/showthread.php?tid=657068)



GetVehicleTrailer - Mitic0 - 31.07.2018

pawn Код:
new Veiculo = CreateVehicle(...);
GetVehicleTrailer(Veiculo);
Isso й incorreto? ou o tenho que utilizar o GetPlayerVehicleID mesmo ? ( GetVehicleTrailer(GetPlayerVehicleID(playerid)); )


Re: GetVehicleTrailer - willttoonn - 31.07.2018

Vocк ta criando um veнculo, como ele estaria com um trailer engatado a ele?

O GetPlayerVehicleID й usado para conseguir o ID daquele veнculo que o jogador estб dentro dele, logo se vocк quer descobrir o ID do trailer que estб engatado ao veнculo do jogador, vocк usa:
pawn Код:
new vehicleid = GetVehiclePlayerID(playerid);
new trailerid = GetVehicleTrailer(vehicleid);
O trailerid irб retornar o ID do trailer engatado ao veнculo. Se o valor retornar em 0 significa que nenhum trailer estб engatado ao veнculo.


Re: GetVehicleTrailer - Mitic0 - 31.07.2018

Bom, quero que verifique se o trailer estб na carreta

pawn Код:
new veiculosetado = GetarVeiculo(GetVehiclePlayerID(playerid));
new Trailer = GetVehicleTrailer(veiculosetado);



public GetarVeiculo(idveiculo)
{
    new valor = 0;
    for(new i = 0; i < MAX_VEHICLES; i ++)
    {
        if(Veiculos[i][vVeh] == idveiculo)
        {
            valor++;
            return i;
        }
    }
    return valor;
}
mas estб retornando com valor 0 oque tem de errado ?


Re: GetVehicleTrailer - SIZET - 31.07.2018

Para verificar se o trailer estб na carreta use a funзгo: IsTrailerAttachedToVehicle

Aqui eu farei se a carreta nгo estiver engatada em um trailer de Petroleiro mandar uma mensagem de erro:

PHP код:
new VeiculoID GetPlayerVehicleID(playerid);
if(
IsTrailerAttachedToVehicle(VeiculoID))
{
    if(
GetVehicleModel(GetVehicleTrailer(VeiculoID)) != 584) return SendClientMessage(playeridVermelho"| ERRO | Vocк nгo esta com o tanque de Petroleo.");




Re: GetVehicleTrailer - Cauezin - 31.07.2018

O que vocк realmente quer fazer?


Re: GetVehicleTrailer - Mitic0 - 31.07.2018

Quote:
Originally Posted by Cauezin
Посмотреть сообщение
O que vocк realmente quer fazer?
quero setar a gasolina para o trailer


Re: GetVehicleTrailer - Mitic0 - 31.07.2018

Quote:
Originally Posted by SIZET
Посмотреть сообщение
Para verificar se o trailer estб na carreta use a funзгo: IsTrailerAttachedToVehicle

Aqui eu farei se a carreta nгo estiver engatada em um trailer de Petroleiro mandar uma mensagem de erro:

PHP код:
new VeiculoID GetPlayerVehicleID(playerid);
if(
IsTrailerAttachedToVehicle(VeiculoID))
{
    if(
GetVehicleModel(GetVehicleTrailer(VeiculoID)) != 584) return SendClientMessage(playeridVermelho"| ERRO | Vocк nгo esta com o tanque de Petroleo.");

eu nгo quero fazer com GetPlayerVehicleID(playerid), quero fazer com a variбvel do veнculo que estб criado, new carro = CreateVehicle ..., com o GetPlayerVehicleID(playerid) eu jб estava conseguindo.


Re: GetVehicleTrailer - willttoonn - 31.07.2018

Use o que eu mandei no primeiro post que ele irб retornar o ID do trailer corretamente.


Re: GetVehicleTrailer - Mitic0 - 31.07.2018

Quote:
Originally Posted by willttoonn
Посмотреть сообщение
Use o que eu mandei no primeiro post que ele irб retornar o ID do trailer corretamente.
willttoonn como eu disse, assim jб estб, eu quero colocar na variбvel pois ficara melhor para eu acrescentar mais coisas, como salvar a gasolina no tanque, etc, com o GetPlayerVehicleID jб estava funcionando.


quero mais ou menos isso ,

pawn Код:
new veiculosetado = GetarVeiculo(GetVehiclePlayerID(playerid));// verificar se й um veнculo comprado, ou setado
new Trailer = GetVehicleTrailer(veiculosetado);


public GetarVeiculo(idveiculo)
{
    new valor = 0;
    for(new i = 0; i < MAX_VEHICLES; i ++)
    {
        if(Veiculos[i][vVeh] == idveiculo)
        {
            valor++;
            return i;
        }
    }
    return valor;
}



Re: GetVehicleTrailer - willttoonn - 31.07.2018

Qual seria a funзгo do GetarVeiculo?