SA-MP Forums Archive
[Ajuda] Detectar se o Trailer й do player - 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] Detectar se o Trailer й do player (/showthread.php?tid=400877)



Detectar se o Trailer й do player - EditPawn - 20.12.2012

Boas pessoal. Bom fiz um sistema que ele escolhe a sua carga para transportar e nisso й criado um veнculo(Carga) para que ele possa ir lб e pegar e transportar atй o local de entrega, mas eu queria fazer com que detectasse se essa carga й dele ou nгo, se for true ele conseguirб pegar, se for false ele nгo irб conseguir pegar a carga. Ai criei uma variavel para o veнculo que fosse criado ao playerid, mas nгo tenho idйia como fazer para verificar se a carga й dele ou nгo! :S

Alguem poderia me ajudar ?

Cуdigo para que crie o Veнculo(carga que o player precisa transportar)
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case D_M_Carga:
        {
            if(response)
            {
                new rand = random(sizeof(CoordCarga)), Float:angulo;
                if(rand >= 0 && rand <= 3) angulo = 67.5803;
                else if(rand >= 4 && rand <= 7) angulo = 160.0426;
                SetPlayerCheckpoint(playerid, CoordCarga[rand][0], CoordCarga[rand][1], CoordCarga[rand][2], 5);
                SendClientMessage(playerid, COR_CYAN, "Vб atй a marca vermelha buscar sua Carga!");
                switch(listitem)
                {
                    case 0:
                    {
                        InfoEmprego[playerid][Carga] = CreateVehicle(591, CoordCarga[rand][0], CoordCarga[rand][1], CoordCarga[rand][2], angulo, 1, 1, -1);
                    }
                    case 1:
                    {
                        InfoEmprego[playerid][Carga] = CreateVehicle(435, CoordCarga[rand][0], CoordCarga[rand][1], CoordCarga[rand][2], angulo, 1, 1, -1);
                    }
                    case 2:
                    {
                        InfoEmprego[playerid][Carga] = CreateVehicle(450, CoordCarga[rand][0], CoordCarga[rand][1], CoordCarga[rand][2], angulo, 1, 1, -1);
                    }
                    case 3:
                    {
                        InfoEmprego[playerid][Carga] = CreateVehicle(584, CoordCarga[rand][0], CoordCarga[rand][1], CoordCarga[rand][2], angulo, 1, 1, -1);
                    }
                }
            }
        }
    }
    return 1;
}
Agradeзo

@EDIT
Eu gostaria de apenas saber como eu posso verificar se o player pega o trailer, porque esses trailers q sгo criados ele й facilmente attached ao caminhгo, й sу chegar de rй e ele pega o trailer, eu gostaria de saber como eu posso fazer essa verificaзгo de quando ele pega, e ai eu posso prosseguir o meu sistema. Sу tenho dificuldade nisso mesmo.

Obs: Eu tinha pensado em fazer pela public OnPlayerUpdate, mas pelo que eu sei(Nao tenho certeza), mas ela chama a cada 1/4 de segundo, e nгo gosto de usar essa public por isso :S


Re: Detectar se o Trailer й do player - BielCOP - 20.12.2012

N entendi.

Explica melhor q eu ajudo.


Re: Detectar se o Trailer й do player - @FatalFormat - 20.12.2012

if(!InfoEmprego[playerid][Carga])

Acredito que sejб assim.

Pelo que eu entendi!


Re: Detectar se o Trailer й do player - GTO.DoDo - 20.12.2012

Код:
if(GetPlayerVehicleID(playerid) != InfoEmprego[playerid][Carga])
{
    SendClientMessage(playerid, -1, "ERRO: N e Seu Carro");
    return 0;
}



Re: Detectar se o Trailer й do player - EditPawn - 20.12.2012

Sу quero saber como faz pra detectar quando o Caminhгo pega a Carga (O trailer)..


Re: Detectar se o Trailer й do player - GTO.DoDo - 20.12.2012

Quote:
Originally Posted by EditPawn
Посмотреть сообщение
Sу quero saber como faz pra detectar quando o Caminhгo pega a Carga (O trailer)..
************


Re: Detectar se o Trailer й do player - FeelLikeASir_ - 20.12.2012

pawn Код:
new bool: a[MAX_PLAYERS];

public OnPlayerUpdate(playerid) {
    if(IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid) && !a[playerid])) {
        SendClientMessage(playerid, -1, "Um trailer foi anexado ao veнculo");
        if(GetVehicleTrailer(GetPlayerVehicleID(playerid) == InfoEmprego[playerid][Carga])) {
            //enjoy;
            a[playerid] = true; //evitar flood.
        }
    }
    return true;
}



Re: Detectar se o Trailer й do player - EditPawn - 20.12.2012

Quote:
Originally Posted by FeelLikeASir_
Посмотреть сообщение
pawn Код:
new bool: a[MAX_PLAYERS];

public OnPlayerUpdate(playerid) {
    if(IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid) && !a[playerid])) {
        SendClientMessage(playerid, -1, "Um trailer foi anexado ao veнculo");
        if(GetVehicleTrailer(GetPlayerVehicleID(playerid) == InfoEmprego[playerid][Carga])) {
            //enjoy;
            a[playerid] = true; //evitar flood.
        }
    }
    return true;
}
Sу pela OnPlayerUpdate ? :/
Tinha pensado em usar, mas fiquei meio em dъvida.

Obs: Nгo gosto muito de usar essa callback, mas mesmo assim irei usar!

Obrigado ^^
Reputado por ter ajudado