[AJUDA]Quando player cancela entrada em veнculo
#1

Oi gente,bem,eu fiz um negуcio de que ataca um objeto no jogador,mais ae,quando ele entra no carro,o objeto some,e se ele sai o objeto volta,ate ai td certo neh,mas o problema eh que se eu aperto para ele entrar no carro,e depois tipo cancelo a entrada com alguma tecla de movimento,o objeto some e nao aparece,a nao ser que eu entre no carro e saia,quando eu cancelo o objeto some e so reaparece se eu morro ou se entro no carro sem cancelar,eh tipo um bug. tem algum codigo que tire esse bug? que ele so remova o objeto quando o jogador realmente estiver dirigindo o veiculo? aguardo ajuda gente! desde ja vlws
Reply
#2

muda o codigo da public OnPlayerEnterVehicle pra

pawn Код:
public OnPlayerStateChange(playerid, newsatate, oldstate)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
    //codigo pra sumir o objeto
    }
    if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)
    {
    //codigo pra voltar o objeto
    }
    return 1;
}
Reply
#3

No caso o code eh dum negocio de arara:
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(Info[i][Arara]) { RemovePlayerAttachedObject(i, 0); }
    }
    return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(Info[i][Arara]) { SetPlayerAttachedObject(playerid,0, 19079, 1, 0.319503, -0.089340, -0.185576, 0.000000, 0.000000, 0.000000, 1.000000, 1.000000, 1.000000 ); }
    }
    return 1;
}
ta vendo,este eh o code que eu to usando,mas eu nao to conseguindo incluir no statechange,e como vc pode ver,precisa do if(info[i][arara]) pra ver se o cara tem a arara,no caso se nao tiver,ele nao ataca e nem remove objeto. como eu incluo isso no statechange? vlws aguardo resposta
Reply
#4

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        if(Info[playerid][Arara])
            RemovePlayerAttachedObject(i, 0);
    }
    if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
    {
        if(Info[playerid][Arara])
            SetPlayerAttachedObject(playerid,0, 19079, 1, 0.319503, -0.089340, -0.185576, 0.000000, 0.000000, 0.000000, 1.000000, 1.000000, 1.000000 );
    }
    return 1;
}
Reply
#5

deu um erro:
pawn Код:
error 017: undefined symbol "i"
ah,e com esse seu code eu tenho que deletar o playerentervehicle e o playerexitvehicle?

@EDIT
Eu tentei assim,compilou,eu testei e nгo deu certo.
OBS.: Tentei com os publics de enter e exit vehicle:
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    if(IsPlayerInAnyVehicle(playerid))
    {
        if(Info[playerid][Arara])
        RemovePlayerAttachedObject(i, 0);
    }
    if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
    {
        if(Info[playerid][Arara])
        SetPlayerAttachedObject(playerid,0, 19079, 1, 0.319503, -0.089340, -0.185576, 0.000000, 0.000000, 0.000000, 1.000000, 1.000000, 1.000000 );
    }
    return 1;
}
Agora eu tentei sem as publics exit e enter e tambйm nгo deu,o objeto continua atacado ao player quando ele entra no veнculo.
Reply
#6

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(Info[i][Arara])
                RemovePlayerAttachedObject(i, 0);
        }
    }
    if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
    {
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(Info[i][Arara])
                SetPlayerAttachedObject(playerid,0, 19079, 1, 0.319503, -0.089340, -0.185576, 0.000000, 0.000000, 0.000000, 1.000000, 1.000000, 1.000000 );
        }
    }
    return 1;
}
Reply
#7

Nгo deu certo!
Reply
#8

Inverti o codigo --' as vezes eu me supero

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
    {
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(Info[i][Arara])
                RemovePlayerAttachedObject(i, 0);
        }
    }
    if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)
    {
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(Info[i][Arara])
                SetPlayerAttachedObject(playerid,0, 19079, 1, 0.319503, -0.089340, -0.185576, 0.000000, 0.000000, 0.000000, 1.000000, 1.000000, 1.000000 );
        }
    }
    return 1;
}
Reply
#9

vlws xD!!!!!!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)