Anti Health hack help - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Anti Health hack help (
/showthread.php?tid=453479)
Anti Health hack help -
tuitalker - 25.07.2013
Hi, i'm trying to make a possible anti health hack but i have a problem, when i connect to my server no problem, when 2nd player connects he gets kicked when spawns.
Код:
public OnPlayerSpawn(playerid)
{
SetPlayerHealth(playerid,99);
SetPVarInt(playerid, "i_health", 99);
SetTimerEx("antigodmode",1000,1,"d",playerid);
return 1;
}
Код:
stock antigodmode();
public antigodmode(){
for(new i = 0; i < MAX_PLAYERS; i++)
{
new Float:pHealth;
GetPlayerHealth(i, Float:pHealth);
if(GetPVarInt(i, "i_health") > Float:pHealth)
{
SetPVarInt(i, "i_health", Float:pHealth);
}
if(Float:pHealth > 99)
{
new pname[MAX_PLAYER_NAME];
new string[256];
GetPlayerName(i, pname, sizeof (pname));
format(string, sizeof(string), "%s is kicked for possible health hack.", pname);
SendClientMessageToAll(COLOR_RED, string);
Kick(i);
}else if(Float:pHealth <= 99){
}
}
return 1;
}
Can someone help me? what's wrong with the code
Re: Anti Health hack help -
RajatPawar - 25.07.2013
pawn Код:
public OnPlayerSpawn(playerid)
{
SetPlayerHealth(playerid,99);
SetPVarInt(playerid, "i_health", 99);
SetTimerEx("antigodmode",1000,1,"d",playerid);
return 1;
}
public antigodmode(playerid)
{
new Float:pHealth;
GetPlayerHealth(playerid, Float:pHealth);
if(GetPVarInt(playerid, "i_health") > Float:pHealth)
{
SetPVarInt(playerid, "i_health", Float:pHealth);
}
if(Float:pHealth > 99)
{
new pname[MAX_PLAYER_NAME];
new string[100];
GetPlayerName(playerid, pname, sizeof (pname));
format(string, sizeof(string), "%s is kicked for possible health hack.", pname);
SendClientMessageToAll(COLOR_RED, string);
Kick(playerid);
}
return 1;
}
You seriously need to read the PAWN guide! Stocks don't need to be declared. You need to however declare the above public using
pawn Код:
forward public antigodmode(playerid);
The problem was you were passing parameters through SetTimerEx but in the actual function you were looping through all the players. Either loop through all using the above function but then use SetTimer OR use SetTimerEx to check one player at a time.
Re: Anti Health hack help -
Scenario - 25.07.2013
Quote:
Originally Posted by Rajat_Pawar
PAWNO
|
*PAWN
Pawno is an IDE editor. PAWN is the language.
Re: Anti Health hack help -
tuitalker - 25.07.2013
thank you rajat, i'll go to my country for a month, i thing i will not have internet, so i downloaded all the sa-mp wiki and i'll learn from it.