SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 16/12/2012, 08:36 PM   #1
PDChaseOfficial
Little Clucker
 
Join Date: Dec 2012
Posts: 41
Reputation: 0
Default anticheat not working

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;
}
__________________
PDChaseOfficial is offline   Reply With Quote
Old 16/12/2012, 08:41 PM   #2
[KHK]Khalid
Gangsta
 
[KHK]Khalid's Avatar
 
Join Date: Jan 2012
Location: Alexandria, Egypt
Posts: 854
Reputation: 136
Default Re: anticheat not working

Use SetTimerEx instead of SetTimer so you can pass arguments. Also create a per-player global variable to hold timers.
[KHK]Khalid is offline   Reply With Quote
Old 16/12/2012, 08:51 PM   #3
PDChaseOfficial
Little Clucker
 
Join Date: Dec 2012
Posts: 41
Reputation: 0
Default Re: anticheat not working

Thanks buddy. Works.
__________________
PDChaseOfficial is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Working AntiCheat? TheMightyEddy Scripting Help 5 03/04/2012 04:13 PM
Weapon anticheat - Not working. Whizion Help Archive 4 01/08/2010 01:52 AM
Simple Anticheat Check not working BP13 Help Archive 5 28/02/2010 03:09 PM
AntiCheat not working Robbin237 Help Archive 0 04/04/2009 08:12 AM


All times are GMT. The time now is 01:55 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.