Anti Cheat
#1

I trying to make a weapon anticheat but i have a little problem....
If I use the new fuction to give someone a weapon it also give me a kick....
help please
this is my script:
Код:
forward WeaponTimer();
public WeaponTimer()
{
	new string[256], str1[256], str2[256], str3[256];
	new username[MAX_PLAYER_NAME];
	for(new i=0; i<MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i))
		{
		    for(new w = 0; w < 13; w++)
		    {
  				new tweap, tammo;
  				GetPlayerWeaponData(i, w ,tweap ,tammo);
  				format(str1,sizeof(str1),"wslot%d",w);
  				format(str2,sizeof(str2),"weap%d",tweap);
				if(GetPVarInt(i,str1) != tweap)
				{
					GetPlayerName(i,username,sizeof(username));
					format(string, 256, "AdmWarning: [%d]%s just try to spawn a weapon",i,username);
					ABroadCast(COLOR_LIGHTRED,string,1);
					Kick(i);
				}
			}
		}
	}
}
Код:
stock YAN_GiveWeapon(playerid,weapon,ammo)
{
	new str[10];
	format(str,sizeof(str),"weap%d",weapon); 
	SetPVarInt(playerid,str,1); 
	format(str,sizeof(str),"wslot%d",GetWeaponSlot(weapon)); 
	SetPVarInt(playerid,str,weapon);
	GivePlayerWeapon(playerid,weapon,ammo);
}
plese a little help guys!
Reply
#2

first of all, why the hell are you using [256] for everything?? Are you mad?

pawn Код:
new string[128], str1[60], str2[60], str3[60]; // Maybe even less...
Create a variable giving permission to a player using the weapons,
Reply
#3

what do you mean permission?
for that I have this:
Код:
	format(str,sizeof(str),"weap%d",weapon); 
	SetPVarInt(playerid,str,1);
it's says me if the player have the weapon or not.....
and ok i change it to [60]
Reply
#4

ok when i do that:
Код:
public WeaponTimer()
{
	new string[128], str1[60], str2[60], str3[60];
	new username[MAX_PLAYER_NAME];
	for(new i=0; i<MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i))
		{
  				format(str1,sizeof(str1),"wslot%d",GetWeaponSlot(GetPlayerWeapon(i)));
  				format(str2,sizeof(str2),"weap%d",GetPlayerWeapon(i));
  				if(GetPVarInt(i,str1) != 1)
  				{
					if(GetPVarInt(i,str1) != GetPlayerWeapon(i))
					{
						GetPlayerName(i,username,sizeof(username));
						format(string, 256, "AdmWarning: [%d]%s just try to spawn a weapon",i,username);
						ABroadCast(COLOR_LIGHTRED,string,1);
						Kick(i);
					}
				}
		}
	}
}
it work me fine but GetPlayerWeaponData is more affective because it's get the all weapons that he have and what i did now the cheater will need to change to the weapon ge spawns....../=
Reply
#5

I don't understand you. Can you explain it more clearly? please i'm from Poland : )
Reply
#6

look when I use GetPlayerWeaponData it's kick me also if I use YAN_GiveWeapon.
now if I use GetPlayerWeapon to compare the real weapon and the weapon from the cheats it's work fine and do the right job.

now,
the only problem in GetPlayerWeapon that it's only check what weapon you have right now, and GetPlayerWeaponData check all your all weapon in one time.......
Reply
#7

I'll give you an example because i hate PVars.

pawn Код:
GetPlayerWeaponData(i, w, CheckActuallyWeapons, CheckActuallyAmmo);
            if(CheckActuallyWeapons != PlayerWeapons)
            {
                Kick(i);
            }
I just prefer to use variables not Pvars. I think i can't help you with Pvars.
Reply
#8

But cheater can't use this weapon anyway if you use the second code.
Reply
#9

ok but now i found new problem.....
sometimes players that don't have cheats get banned and I cheack that all GivePlayerWeapon replaced.....
maybe that happend because this:
Код:
forward YAN_ResetPlayerWeapons(playerid);
public YAN_ResetPlayerWeapons(playerid)
{
	new str[10];
	for(new w = 0; w<= 42; w++)
	{
	    format(str,sizeof(str),"weap%d",w);
	    if(GetPVarInt(playerid,str) == 1)
			DeletePVar(playerid,str);
	}
	for(new s = 0; s <= 12; s++)
	{
	    format(str,sizeof(str),"wslot%d",s);
	    if(GetPVarInt(playerid,str) != -1)
			DeletePVar(playerid,str);
	}
	return 1;
}
Reply
#10

Quote:
Originally Posted by Riddick94
Посмотреть сообщение
I'll give you an example because i hate PVars.

pawn Код:
GetPlayerWeaponData(i, w, CheckActuallyWeapons, CheckActuallyAmmo);
            if(CheckActuallyWeapons != PlayerWeapons)
            {
                Kick(i);
            }
I just prefer to use variables not Pvars. I think i can't help you with Pvars.
can you give a code with a variables use? some base that I can deal...
Reply
#11

someone? please help
Reply
#12

Код:
forward WeaponTimer();
public WeaponTimer()
{
	new string[256], str1[256], str2[256], str3[256];
	new username[MAX_PLAYER_NAME];
	for(new i=0; i<MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i))
		{
		    for(new w = 0; w < 13; w++)
		    {
  				new tweap, tammo;
  				GetPlayerWeaponData(i, w ,tweap ,tammo);
  				format(str1,sizeof(str1),"wslot%d",w);
  				format(str2,sizeof(str2),"weap%d",tweap);
				if(GetPVarInt(i,str2) != 1 && tweap != 0)// I've changed THIS line!
				{
					GetPlayerName(i,username,sizeof(username));
					format(string, 256, "AdmWarning: [%d]%s just try to spawn a weapon",i,username);
					ABroadCast(COLOR_LIGHTRED,string,1);
					Kick(i);
				}
			}
		}
	}
}
I've changed just one line, it has been commented!
Just let me know if this works out for you though
(I don't know about the rest of you, but this code blew my mind, maybe I should've waken up completely first...)

Also: You should continue to use PVars where ever possible, it's much easier & more effective
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)