Anti Weapon Hack only for ID 0 -
Julian12345 - 04.06.2011
Hello guys
I have an anti weapon hack but strangely it only detects the forbidden weapons from id 0.
Does anyone know why?
Re: Anti Weapon Hack only for ID 0 -
Jay. - 04.06.2011
how about showing the code? xd
Re: Anti Weapon Hack only for ID 0 -
Backwardsman97 - 04.06.2011
You probably have a for loop where you're returning inside of it. That way it'd only scan player 0 and then end the loop.
AW: Anti Weapon Hack only for ID 0 -
Julian12345 - 04.06.2011
pawn Code:
forward WeaponHackCheck(playerid);
pawn Code:
public OnFilterScriptInit()
{
SetTimer("WeaponHackCheck", 1000, true);
return 1;
}
pawn Code:
public WeaponHackCheck(playerid)
{
if(GetPlayerWeapon(playerid) == 16 && AccInfo[playerid][vip] == 0 || GetPlayerWeapon(playerid) == 35 && AccInfo[playerid][vip] == 0 || GetPlayerWeapon(playerid) == 36 && AccInfo[playerid][vip] == 0 || GetPlayerWeapon(playerid) == 37 && AccInfo[playerid][vip] == 0 || GetPlayerWeapon(playerid) == 38 && AccInfo[playerid][vip] == 0 || GetPlayerWeapon(playerid) == 39 && AccInfo[playerid][vip] == 0)
{
for(new i=0;i<50;i++)
{
new PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, PlayerName, MAX_PLAYER_NAME);
new var;
new warned = strval(PlayerName);
new str[128], string3[100];
new lbweapon[64];
AccInfo[warned][HackWarnings]++;
var=GetPlayerWeapon(i);
GetWeaponName(var,lbweapon,sizeof(lbweapon));
if( AccInfo[warned][HackWarnings] == 5)
{
format(str,sizeof(str),"%s has automatically been kicked [Reason: Weapon Hack (%s)]",PlayerName,lbweapon);
SendClientMessageToAll(red,str);
SaveIn("KickLog",str);
Kick(warned);
return AccInfo[warned][HackWarnings] = 0;
}
else
{
var=GetPlayerWeapon(i);
format(str, sizeof (str), "Admin Chat: WARNING: %s has a %s || Warning: %d/5", pName(warned),lbweapon,AccInfo[warned][HackWarnings]);
MessageToAdmins(orange,str);
format(string3, sizeof (string3), "WARNING: Weapon Hacks are not allowed! || Warning: %d/5",AccInfo[warned][HackWarnings]);
return SendClientMessage(playerid,red,string3);
}
}
}
return 1;
}
Re: Anti Weapon Hack only for ID 0 -
Backwardsman97 - 04.06.2011
That code is very inefficient and won't even work for anyone but playerid 0. You can't pass a playerid parameter if you're calling the timer in OnGameModeInit. The script doesn't know which playerid to use so it just uses 0. Also, if a player has an illegal weapon, it just adds to his warnings once a second until it gets to five.
AW: Anti Weapon Hack only for ID 0 -
Julian12345 - 04.06.2011
Backwardsman, can you show me how to fix this code or can you rewrite it so that it works?
Would be very nice
Re: Anti Weapon Hack only for ID 0 -
sim_sima - 04.06.2011
This is not the sulution, but i would recommend you using GetPlayerWeaponData in stead of GetPlayerWeapon.
AW: Anti Weapon Hack only for ID 0 -
Julian12345 - 04.06.2011
Well, I need a solution sim_sima. D:
Can somebody rewrite this so that it works? Unfortunately Backwardsman went off.
Re: Anti Weapon Hack only for ID 0 -
Backwardsman97 - 04.06.2011
Well I don't really understand what you're doing here.
pawn Code:
new warned = strval(PlayerName);
AccInfo[warned][HackWarnings]++;
You use the integer equivalent of the player's name as the index for AccInfo? Why not just use the playerid? Like this.
pawn Code:
AccInfo[playerid][HackWarnings]++;
Re: AW: Anti Weapon Hack only for ID 0 -
sim_sima - 05.06.2011
Quote:
Originally Posted by Julian12345
Well, I need a solution sim_sima. D:
Can somebody rewrite this so that it works? Unfortunately Backwardsman went off. 
|
I just helped you making it better.