18.12.2012, 15:26
Fiz este code para prevenir uns cheaters simples:
So que ou o SetPlayerHealth ou o GetPlayerHealth ta bugado.
De vez em quando funciona.
Debug:
Ajuda??
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;
}
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?