anticheat not working
#1

Hello. I am working on a anticheat that would check if person is using health cheats. Basically, it creates a bang around him and after 500 miliseconds it checks if the health decreased or not. However, everytime I do it, it tells me im a cheater, even if I dont have cheats on. Any ideas please?

Code:
forward healthcheckinveh(playerid,targetid,oldhealth,newhealth,vid,seat);
forward healthcheck(playerid,targetid,oldhealth,newhealth);

CMD:explode(playerid,params[])
{
	if(PlayerInfo[playerid][pAdmin]<3) return SendClientMessage(playerid,COLOR_RED,"Acces denied.");
	new targetid;
	if(sscanf(params,"u",targetid)) return SendClientMessage(playerid,COLOR_RED,"usage: /explode [id].");
	if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid,COLOR_RED,"Invalid ID.");
	if(!IsPlayerInAnyVehicle(targetid))
	{
            new Float:x,Float:y,Float:z;
	    new Float:oldhealth;
	    GetPlayerPos(targetid,x,y,z);
    	    GetPlayerHealth(targetid,oldhealth);
	    CreateExplosion(x,y,z,8,10);
	    SetTimer("healthcheck",500,0);
	}
	else // if player is in vehicle
	{
		new vid=GetPlayerVehicleID(targetid);
		new seat=GetPlayerVehicleSeat(targetid);
		new Float:x,Float:y,Float:z;
		new Float:oldhealth;
		GetPlayerPos(targetid,x,y,z);
		SetPlayerPos(targetid,x,y+100,z);
		GetPlayerHealth(targetid,oldhealth);
		CreateExplosion(x,y,z,8,10);
		SetTimer("healthcheckinveh",500,0);
	}
	return 1;
}

public healthcheckinveh(playerid,targetid,oldhealth,newhealth,vid,seat)
{
	new Float:newhealth;
        GetPlayerHealth(targetid,newhealth);
        if(newhealth>=oldhealth) SendClientMessage(playerid,COLOR_RED,"Cheater.");
	SetPlayerHealth(targetid,oldhealth);
	PutPlayerInVehicle(targetid,vid,seat);
	return 1;
}

public healthcheck(playerid,targetid,oldhealth,newhealth)
{
        new Float:newhealth;
        GetPlayerHealth(targetid,newhealth);
   	if(newhealth>=oldhealth) SendClientMessage(playerid,COLOR_RED,"Cheater.");
   	SetPlayerHealth(targetid,oldhealth);
   	return 1;
}
Reply
#2

Use SetTimerEx instead of SetTimer so you can pass arguments. Also create a per-player global variable to hold timers.
Reply
#3

Thanks buddy. Works.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)