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



Health Bugada?? - Dr_Pawno - 18.12.2012

Fiz este code para prevenir uns cheaters simples:

pawn Код:
//AntiCheaters

new Float:AntiCheater_Vida[MAX_PLAYERS];

forward CheaterHealth();
public CheaterHealth()
{
    for(new Var = 0; Var < sizeof(AntiCheater_Vida); Var++)
        AntiCheater_Vida[Var] = 0.0;

    //foreach(new i: Player)   
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        GetPlayerHealth(i, AntiCheater_Vida[i]);
        SetPlayerHealth(i, AntiCheater_Vida[i] + 5);
    }
    SetTimer("CheaterHealthCheck", 5000, false);
    return 1;
}

forward CheaterHealthCheck();
public CheaterHealthCheck()
{
    new Float:AntiCheaterCheck;
    //foreach(new i: Player)
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        GetPlayerHealth(i, AntiCheaterCheck);
        printf("ID %d: %f = %f?", i, AntiCheaterCheck, AntiCheater_Vida[i]);
        if(AntiCheaterCheck == AntiCheater_Vida[i])
        {
            SendClientMessage(i, -1, "Cheater");
        }
        SetPlayerHealth(i, AntiCheater_Vida[i]);
    }
    return 1;
}
So que ou o SetPlayerHealth ou o GetPlayerHealth ta bugado.
De vez em quando funciona.

Debug:

Код:
ID 0: 115.000000 = 115.000000?
ID 0: 120.000000 = 115.000000?
ID 0: 110.000000 = 110.000000?
ID 0: 110.000000 = 110.000000?
ID 0: 110.000000 = 110.000000?
ID 0: 110.000000 = 110.000000?
Ajuda??


Re: Health Bugada?? - VenoN - 18.12.2012

cara nгo sei a certa mais eu tenho certeza que o erro й nesse

pawn Код:
%f = %f se nгo me engano em vez de %f ia outra coisa %f02 algo parecido!



Re: Health Bugada?? - .FuneraL. - 18.12.2012

Tenta Colocar %.2f ou %.0f, Apуs o ponto, aponta as casas decimais do nъmero.


Re: Health Bugada?? - Sky™ - 18.12.2012

pawn Код:
new Float:AntiCheater_Vida[MAX_PLAYERS];

forward CheaterHealth();
public CheaterHealth()
{
    for(new Var = 0; Var < sizeof(AntiCheater_Vida); Var++)
        AntiCheater_Vida[Var] = 0.0;

    //foreach(new i: Player)    
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        GetPlayerHealth(i, AntiCheater_Vida[i]);
        SetPlayerHealth(i, AntiCheater_Vida[i] + 5);
    }
    SetTimer("CheaterHealthCheck", 5000, false);
    return 1;
}

forward CheaterHealthCheck();
public CheaterHealthCheck()
{
    new Float:AntiCheaterCheck;
    //foreach(new i: Player)
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        GetPlayerHealth(i, AntiCheaterCheck);
        printf("ID %d: %0.f = %0.f?", i, AntiCheaterCheck, AntiCheater_Vida[i]);
        if(AntiCheaterCheck == AntiCheater_Vida[i])
        {
            SendClientMessage(i, -1, "Cheater");
        }
        SetPlayerHealth(i, AntiCheater_Vida[i]);
    }
    return 1;
}



Re: Health Bugada?? - Dr_Pawno - 18.12.2012

Nгo sei se sabe... mais isso й um DEBUG :X

@Edit:

Nao sei se Sabem <<


Re: Health Bugada?? - tonisantolia - 18.12.2012

Quote:
Originally Posted by Sky_.
Посмотреть сообщение
pawn Код:
new Float:AntiCheater_Vida[MAX_PLAYERS];

forward CheaterHealth();
public CheaterHealth()
{
    for(new Var = 0; Var < sizeof(AntiCheater_Vida); Var++)
        AntiCheater_Vida[Var] = 0.0;

    //foreach(new i: Player)    
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        GetPlayerHealth(i, AntiCheater_Vida[i]);
        SetPlayerHealth(i, AntiCheater_Vida[i] + 5);
    }
    SetTimer("CheaterHealthCheck", 5000, false);
    return 1;
}

forward CheaterHealthCheck();
public CheaterHealthCheck()
{
    new Float:AntiCheaterCheck;
    //foreach(new i: Player)
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        GetPlayerHealth(i, AntiCheaterCheck);
        printf("ID %d: %0.f = %0.f?", i, AntiCheaterCheck, AntiCheater_Vida[i]);
        if(AntiCheaterCheck == AntiCheater_Vida[i])
        {
            SendClientMessage(i, -1, "Cheater");
        }
        SetPlayerHealth(i, AntiCheater_Vida[i]);
    }
    return 1;
}
Mudou oq?

@topic
Praq desativar o foreach e por um loop comum se o foreach substitui deixando o loop atй mais leve
Analisando o codigo para ver oq e


Re: Health Bugada?? - VenoN - 18.12.2012

Quote:
Originally Posted by tonisantolia
Посмотреть сообщение
Mudou oq?

@topic
Praq desativar o foreach e por um loop comum se o foreach substitui deixando o loop atй mais leve
Analisando o codigo para ver oq e
perdeu a visгo??

ele mudou a float para as floats de numeros decimais meu brother!
acho que ele nem testou o code!


Re: Health Bugada?? - Dr_Pawno - 18.12.2012

Quote:
Originally Posted by tonisantolia
Посмотреть сообщение
Mudou oq?

@topic
Praq desativar o foreach e por um loop comum se o foreach substitui deixando o loop atй mais leve
Analisando o codigo para ver oq e
Quote:
Originally Posted by Alex_Kidds
Посмотреть сообщение
perdeu a visгo??

ele mudou a float para as floats de numeros decimais meu brother!
acho que ele nem testou o code!
Traduzindo... Ele apenas alterou o Debug :X