SA-MP Forums Archive
Question with example :D - 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: Question with example :D (/showthread.php?tid=528522)



Question with example :D - NeroX98 - 28.07.2014

Hi guys,

I have problem with making anti-cheats and other stuff when i have to set a variable and after some time to check it because the server in the same time when its changing the variable he is already checking the variable and this can lead to not accurate anti cheat.

For example:
1.I have variable pHealth and my function GiveHealth(playerid, health);
Код:
stock GiveHealth(playerid, health)
{
	pHealth[playerid] = health;
	return SetPlayerHealth(playerid, health);
}
2. Also i have GlobalTimer on 1 second
Код:
public OnGameModeInIt()
{
	SetTimer("GlobalTimer", 1000, true);
	return 1;
}

forward GlobalTimer();
public GlobalTimer()
{
	foreach (new i : Player)
	{
		if(pHealth != GetPlayerHealth(i);
		{
			Kick(i);
		}
	}
	return 1;
}
So sometimes (not every time) when i use GiveHealth(playerid, health-1) the player would get kicked because he has health hack (not accurate)... I found that sometimes the variable lates and sometimes pHealth is for example 100 and GetPlayerHealth is 99...

How can i fix this... The timer is faster than the GiveHealth function and it can lead to kicking innocent players.


Re: Question with example :D - Blademaster680 - 28.07.2014

It could be that the player gets damaged. so make it so when a player recieves damage it subtracts pHealth[playerid]