Anti Health hack help
#1

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
Reply
#2

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.
Reply
#3

Quote:
Originally Posted by Rajat_Pawar
Посмотреть сообщение
PAWNO
*PAWN

Pawno is an IDE editor. PAWN is the language.
Reply
#4

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)