[Weapon Anti Cheat] Please Help
#1

Hello guys,

I want to make some kind of weapon anti cheat but I want it so that if the player tried spawning a gun using the normal:
Code:
GivePlayerWeapon(playerid, weaponid, ammo);
They would get their weapons reset using:
Code:
ResetPlayerWeapons(playerid);
So I want to know how I can change the normal GivePlayerWeapon to something like GivePlayerWeaponAnti so that they cant spawn the weapons . Please help and thanks a lot! and if it can be made simple I would love it since I am a new pawn learner please help and thanks.
Reply
#2

Search for: public OnPlayerChangeWeapon(playerid, oldweapon, newweapon)

Do it listed as this:
Code:
public OnPlayerChangeWeapon(playerid, oldweapon, newweapon)
{
	new string[256];
    if(gPlayerLogged[playerid] && IsPlayerConnected(playerid))
 	{
		if(!IsPlayerNPC(playerid))
		{
		    if(!(PlayerInfo[playerid][pAdmin] >= 3))
		    {
	            new weap=GetPlayerWeapon(playerid);
	            //new ammo=GetPlayerAmmo(playerid);
	            if(weap > 0 && weap != 46)
	            {
	            	if(HaveWeapon(playerid,weap) != weap && HaveAdminWeapon(playerid,weap) != weap && weap != 25 && weap != 46)
	             	{
	             	    new WeaponName[65];
	             	    GetWeaponName(weap,WeaponName,64);
	                  	format(string, sizeof(string), "Hack: %s (%d) has a desynced %s",PlayerName(playerid),playerid,WeaponName);
	                  	//UpdateWarnings(string);
	                  	ABroadCast(COLOR_YELLOW,string, 1);
	                }
	            }
			}
		}
	}
}
That makes you see a warning of someone hacking when he "hacks" a gun using the giveadminweapon system. Althought it can have some mayor buggs. But you can change the message into a ResetPlayerWeapons(playerid);
Reply
#3

But I still want normal players to be able to buy and use guns I just wanna change the GivePlayerWeapon to something else to prevent the hacker from spawning a weapon, please anyone know how to do that? Or no? ?
Reply
#4

This only detects the player HACKED guns, if you want it to not to be showed, you gotta make the guns save in your char.
Reply
#5

Okay so umm I create a:

Code:
pWeapon,
under eNum?

Then I make it something like this in OnPlayerDisconnect?:

Code:
new pWeapons;
pSkins = GetPlayerWeapon(playerid);
dini_IntSet(file, "Weapon",pWeapons);
And in OnPlayerConnect I do this?:

Code:
GivePlayerWeapon(playerid, dini_Int(file, "Weapon"));
Is that right? And if it is wouldnt the player still be able to spawn a weapon and make it become saved in their Dini file? Also how can I save the ammo of that weapon? Thanks for help and im sorry im really new to the scripting .
Reply
#6

Quote:
Originally Posted by XoSarahMoX
View Post
Okay so umm I create a:

Code:
pWeapon,
under eNum?

Then I make it something like this in OnPlayerDisconnect?:

Code:
new pWeapons;
pSkins = GetPlayerWeapon(playerid);
dini_IntSet(file, "Weapon",pWeapons);
And in OnPlayerConnect I do this?:

Code:
GivePlayerWeapon(playerid, dini_Int(file, "Weapon"));
Is that right? And if it is wouldnt the player still be able to spawn a weapon and make it become saved in their Dini file? Also how can I save the ammo of that weapon? Thanks for help and im sorry im really new to the scripting .
That wont stop them spawning a weapon, dude. You can spawn any weapons you want, without getting banned or anything, and leave, and it justs gets the weapon id and next time when he logins (even without hacks), he will get his before hacked weapons by server itself.
Reply
#7

Quote:
Originally Posted by KeyWay
View Post
That wont stop them spawning a weapon, dude. You can spawn any weapons you want, without getting banned or anything, and leave, and it justs gets the weapon id and next time when he logins (even without hacks), he will get his before hacked weapons by server itself.
Well Show "HER" a Example dude ...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)