SA-MP Forums Archive
[Ajuda] My system car not funcioned ! - 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] My system car not funcioned ! (/showthread.php?tid=424748)



My system car not funcioned ! - Duun - 23.03.2013

entaum galera , eu tava fazendo um sistema ( 100 % meu ) , que funcionaria da seguinte forma :
Quando o player saнsse do carro , ele teria 5 seg para entrar novamente ou o carro dele ia ser destruнdo .

olhem o cуdigo :

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT)
    {
        SendClientMessage(playerid, 0xFFFFFFAA, "Vocк tem 5 Segundos para entrar no seu veнculo Novamente");
        SetTimer("Destroy", 5000, false);
    }

    if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
    {
        Entrou_no_carro_novamente[playerid] = 1;
    }
    return 1;
}

forward Destroy(playerid);
public Destroy(playerid)
{
    if(Entrou_no_carro_novamente[playerid] == 0)
    {
        SendClientMessage(playerid, 0xFFFFFFAA, "Seu Veнculo foi destruido Automбticamente");
        DestroyVehicle(Carro);
    }
}
Mais eu saio do carro no jogo , e passa 5 , 10, 15 seg e nada acontece . o carro fica la '-'
pq isso ?


Re: My system car not funcioned ! - iReflesh - 23.03.2013

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT)
    {
        SendClientMessage(playerid, 0xFFFFFFAA, "Vocк tem 5 Segundos para entrar no seu veнculo Novamente");
        Entrou_no_carro_novamente[playerid] = 0;
        SetTimerEx("Destroy", 5000, false, "d", playerid);
    }

    if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
    {
        Entrou_no_carro_novamente[playerid] = 1;
    }
    return 1;
}

forward Destroy(playerid);
public Destroy(playerid)
{
    if(Entrou_no_carro_novamente[playerid] == 0)
    {
        SendClientMessage(playerid, 0xFFFFFFAA, "Seu Veнculo foi destruido Automбticamente");
        DestroyVehicle(Carro);
    }
}



Re: My system car not funcioned ! - Duun - 23.03.2013

Nada muda ..


Re: My system car not funcioned ! - Lуs - 23.03.2013

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT)
    {
        SendClientMessage(playerid, 0xFFFFFFAA, "Vocк tem 5 Segundos para entrar no seu veнculo Novamente");
        SetTimerEx("Destroy", 5000, false, "i", playerid);
    }
    return 1;
}

forward Destroy(playerid);
public Destroy(playerid)
{
    if(!IsPlayerInVehicle(playerid))
    {
        SendClientMessage(playerid, 0xFFFFFFAA, "Seu Veнculo foi destruido Automбticamente");
        DestroyVehicle(Carro);
        return 1;
    }
    return 1;
}
SetTimerEx


Re: My system car not funcioned ! - LeMoi - 23.03.2013

Sera qe n teria que criar uma funcao para obter o id do carro para o destroyvehicle? Eu acho que sim... pode tambem por os carros a darem respawn no addstaticvehicle e ai ja n precisa disto aqui


Re: My system car not funcioned ! - Lуs - 23.03.2013

Quote:
Originally Posted by TiTaNic
Посмотреть сообщение
Sera qe n teria que criar uma funcao para obter o id do carro para o destroyvehicle? Eu acho que sim... pode tambem por os carros a darem respawn no addstaticvehicle e ai ja n precisa disto aqui
Possivelmente ele declarou a variбvel "Carro" como global, nгo vai ter problemas se isso acontecer atй que o segundo jogador saia de um veнculo.

Para resolver tem que declarar a variбvel "Carro" como sendo uma para cada player, utilizando:

pawn Код:
new Carro [ MAX_PLAYERS ];

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT)
    {
        SendClientMessage(playerid, 0xFFFFFFAA, "Vocк tem 5 Segundos para entrar no seu veнculo Novamente");
        SetTimerEx("Destroy", 5000, false, "i", playerid);
    }
    return 1;
}

forward Destroy(playerid);
public Destroy(playerid)
{
    if(!IsPlayerInVehicle(playerid))
    {
        SendClientMessage(playerid, 0xFFFFFFAA, "Seu Veнculo foi destruido Automбticamente");
        DestroyVehicle(Carro[playerid]);
        return 1;
    }
    return 1;
}



Re: My system car not funcioned ! - LeMoi - 23.03.2013

Sim, pensei nisso tambem, mas como tou no phone n consigo ajudar :/ agora ja deve funcionar


Re: My system car not funcioned ! - Duun - 23.03.2013

Show de bota LOS.

Eu jб tinha criado a variбvel global Carro .

Adaptei ao seu cуdigo botando [MAX_PLAYERS] no fim .

Adicionei o Id do carro no parвmetro if(!IsPlayerInVehicle(playerid))

Ficou assim : if(!IsPlayerInVehicle(playerid, Carro[playerid]))

Compilou e deu certo