Weapon hack check
#1

Hello.

I am experiencing unexpected weapon hack warnings from a system that I scripted. It is using variables for all 13 weapon slots.

This is where the weapons are given:

PHP Code:
stock GivePlayerValidWeapon(playeridweaponidammo)
{
    switch(
weaponid)
    {
        case 
01:
        {
            
PlayerInfo[playerid][pGuns][0] = weaponid;
            
GivePlayerWeapon(playeridweaponidammo);
        }
        case 
.. 9:
        {
            
PlayerInfo[playerid][pGuns][1] = weaponid;
            
GivePlayerWeapon(playeridweaponidammo);
        }
        case 
222324:
        {
            
PlayerInfo[playerid][pGuns][2] = weaponid;
            
GivePlayerWeapon(playeridweaponidammo);
        }
        case 
252627:
        {
            
PlayerInfo[playerid][pGuns][3] = weaponid;
            
GivePlayerWeapon(playeridweaponidammo);
        }
        case 
282932:
        {
            
PlayerInfo[playerid][pGuns][4] = weaponid;
            
GivePlayerWeapon(playeridweaponidammo);
        }
        case 
3031:
        {
            
PlayerInfo[playerid][pGuns][5] = weaponid;
            
GivePlayerWeapon(playeridweaponidammo);
        }
        case 
3334:
        {
            
PlayerInfo[playerid][pGuns][6] = weaponid;
            
GivePlayerWeapon(playeridweaponidammo);
        }
        case 
35 .. 38:
        {
            
PlayerInfo[playerid][pGuns][7] = weaponid;
            
GivePlayerWeapon(playeridweaponidammo);
        }
        case 
16171839:
        {
            
PlayerInfo[playerid][pGuns][8] = weaponid;
            
GivePlayerWeapon(playeridweaponidammo);
        }
        case 
414243:
        {
            
PlayerInfo[playerid][pGuns][9] = weaponid;
            
GivePlayerWeapon(playeridweaponidammo);
        }
        case 
10 .. 15:
        {
            
PlayerInfo[playerid][pGuns][10] = weaponid;
            
GivePlayerWeapon(playeridweaponidammo);
        }
        case 
444546:
        {
            
PlayerInfo[playerid][pGuns][11] = weaponid;
            
GivePlayerWeapon(playeridweaponidammo);
        }
        case 
40:
        {
            
PlayerInfo[playerid][pGuns][12] = weaponid;
            
GivePlayerWeapon(playeridweaponidammo);
        }
    }
    return 
1;

This is located under my 1 second timer right now because of testing, I can use it under OnPlayerUpdate too with checking if the player's current weapon is different to his last one:

PHP Code:
new weapon[13], ammo[13];
for(new 
w=013w++)
{
    
GetPlayerWeaponData(iwweapon[w], ammo[w]);
    if(
weapon[w] != PlayerInfo[i][pGuns][w] && weapon[w] != 0)
    {
        
ExecuteHackerAction(iweapon[w]);
    }

^^ I have tried using if and else if here too for checking each slot and each weapon. Still the same problem. I found out using a loop is the same but a lot shorter and not complicated.

This isn't that important but here you go:

PHP Code:
stock ExecuteHackerAction(playeridweaponid)
{
    new 
string[144];
    
format(string,sizeof(string)," ** AdmWarning: {FFFF00}%s (ID %d) is possibly weapon hacking %s (ID %d)"GetName(playerid), playeridGetGunName(weaponid), weaponid);
    
ABroadcast(COLORREDstring1);
    
format(string,sizeof(string),"Possible weapon hack (%s)",GetGunName(weaponid));
    
AddAutomatedFlag(playeridstring);
    
format(string,sizeof(string),"%s has possibly weapon hacked %s (ID %s)"GetName(playerid), GetGunName(weaponid), weaponid);
    
Log("logs/hacks.txt"string);
    return 
1;

An example where the unexpected warning gets triggered is the tazer, givegun, takeguns and weapon pickups:

PHP Code:
if(PlayerState[playerid][pTazer] == 0)
        {
            
GetPlayerWeaponData(playerid2tazerlastweapons[0][playerid], tazerlastweapons[1][playerid]);
            if(
PlayerInfo[playerid][pGuns][2]) RemovePlayerWeapon(playeridPlayerInfo[playerid][pGuns][2]);
            
PlayerState[playerid][pTazer] = 1;
            
format(msg,sizeof(msg)," * %s unholsters their tazer."GetName(playerid));
            
ProxDetector(20.0playeridmsgCOLORRP);
            
GivePlayerValidWeapon(playerid2360000);
        }
        else
        {
            
RemovePlayerWeapon(playerid23);
            
GivePlayerValidWeapon(playeridtazerlastweapons[0][playerid], tazerlastweapons[1][playerid]);
            
PlayerInfo[playerid][pGuns][2] = tazerlastweapons[0][playerid];
            
PlayerState[playerid][pTazer] = 0;
            
format(msg,sizeof(msg)," * %s holsters their tazer."GetName(playerid));
            
ProxDetector(20.0playeridmsgCOLORRP);
        } 
PHP Code:
CMD:givegun(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] >= 3)
    {
        new 
targetidgunammo;
        new 
msg[144];
        if(
PlayerInfo[playerid][pAdminDuty] == && PlayerInfo[playerid][pAdmin] < 4) return SendMessage(playeridCOLORERROR,"AdmCmd: You must be on duty to do this. (/aduty)");
        if(
sscanf(params,"uii"targetidgunammo)) return SendMessage(playerid, -1,"USAGE: /givegun <playerid/partofname> <weaponid> <ammo>");
        if(
targetid == INVALID_PLAYER_ID) return SendMessage(playerid,COLORERROR,"AdmCmd: That player is not connected.");
        if(
InDuel[targetid]) return SendMessage(playerid,COLORERROR,"AdmCmd: That player is currently in a duel, try again later.");
        if(
PlayerState[targetid][pPrisoned] == || PlayerState[targetid][pAdmJail] == 1) return SendMessage(playerid,COLORERROR,"AdmCmd: That player is currently in jail, try again later.");
        if(
IsPlayerNPC(targetid)) return SendMessage(playerid,COLORERROR,"AdmCmd: You can't give weapons to an NPC.");
        if(
gun 46 || gun 1) return SendMessage(playerid, -1,"{00FFFF}AdmCmd:{FFFFFF} Valid weapon IDs: 1 - 46");
        if(
ammo 99999 || ammo 1) return SendMessage(playerid, -1,"{00FFFF}AdmCmd:{FFFFFF} Valid ammo: 1 - 99999");
        
GivePlayerValidWeapon(targetidgunammo);
        
format(msg,sizeof(msg)," *** AdmCmd:{FFFFFF} You have given a(n) %s (ID %d) with %d ammo to %s."GetGunName(gun), gunammoGetName(targetid));
        
SendMessage(playeridCOLORALmsg);
        
format(msg,sizeof(msg),"Admin %s has given you a(n) %s (ID %d) with %d ammo."GetName(playerid), GetGunName(gun), gunammo);
        
SendMessage(targetidCOLORWHITEmsg);
        
format(msg,sizeof(msg),"[GIVEGUN] %s has given %s a(n) %s (ID %d) with %d ammo"GetName(playerid), GetName(targetid), GetGunName(gun), gunammo);
        
Log("logs/admin.txt"msg);
        
ABroadcast(COLORLIGHTREDmsg4);
    } else return 
SendMessage(playeridCOLORERROR"You must be atleast a Head Admin to use this!");
    return 
1;

PHP Code:
CMD:takeguns(playerid,params[])
{
    new 
targetid;
    new 
msg[144];
    if(
PlayerInfo[playerid][pAdmin] >= 2)
    {
        if(
PlayerInfo[playerid][pAdminDuty] == && PlayerInfo[playerid][pAdmin] < 4) return SendMessage(playeridCOLORERROR,"AdmCmd: You must be on duty to do this. (/aduty)");
        if(
sscanf(params,"u",targetid)) return SendMessage(playerid,COLORWHITE,"{00FFFF}AdmCmd:{FFFFFF} /takeguns <playerid/partofname>");
        if(
targetid == INVALID_PLAYER_ID) return SendMessage(playerid,COLORERROR,"AdmCmd: That player is not connected.");
        if(
PlayerInfo[targetid][pAdminDuty] == && PlayerInfo[playerid][pAdmin] != 4) return SendMessage(playeridCOLORERROR,"AdmCmd: You can't do this to an on duty admin.");
        if(
InDuel[targetid]) return SendMessage(playerid,COLORERROR,"AdmCmd: That player is currently in a duel, try again later.");
        if(
PlayerInfo[targetid][pHunted] == 1) return SendMessage(playerid,COLORERROR,"AdmCmd: That player is currently hunted, try again later.");
        if(
IsPlayerNPC(targetid)) return SendMessage(playerid,COLORERROR,"AdmCmd: You can't take away guns from NPCs.");
        
ResetPlayerWeaponsEx(targetid);
        
format(msgsizeof(msg), " *** AdmCmd:{FFFFFF} You have taken away %s's weapons."GetName(targetid));
        
SendMessage(playeridCOLORALmsg);
        
format(msgsizeof(msg), "Admin %s has taken away your weapons."GetName(playerid));
        
SendMessage(targetidCOLORERRORmsg);
        
format(msg,sizeof(msg),"[TAKEGUNS] %s has taken away %s's weapons"GetName(playerid), GetName(targetid));
        
Log("logs/admin.txt"msg);
        
ABroadcast(COLORLIGHTREDmsg4);
    } else return 
SendMessage(playeridCOLORERROR"You must be atleast a Lead Admin to use this!");
    return 
1;

PHP Code:
for(new 0MAX_GUNDROPi++)
        {
            if(
pickupid == WeaponDrop[i][dPickup] && WeaponDrop[i][dWeapon] > 0)
            {
                for(new 
w=0;w<12;w++)
                {
                    
GetPlayerWeaponData(playeridwweaponammo);
                    if((
WeaponDrop[i][dWeapon] == WEAPON_DEAGLE && PlayerState[playerid][pTazer] == 1) ||
                    (
WeaponDrop[i][dWeapon] == WEAPON_SHOTGUN && weapon == WEAPON_SHOTGSPA) ||
                    (
WeaponDrop[i][dWeapon] == WEAPON_SHOTGUN && weapon == WEAPON_SAWEDOFF) ||
                    (
WeaponDrop[i][dWeapon] == WEAPON_SHOTGSPA && weapon == WEAPON_SHOTGUN) ||
                    (
WeaponDrop[i][dWeapon] == WEAPON_SHOTGSPA && weapon == WEAPON_SAWEDOFF) ||
                    (
WeaponDrop[i][dWeapon] == WEAPON_SAWEDOFF && weapon == WEAPON_SHOTGUN) ||
                    (
WeaponDrop[i][dWeapon] == WEAPON_SAWEDOFF && weapon == WEAPON_SHOTGSPA) ||
                    (
WeaponDrop[i][dWeapon] == WEAPON_AK47 && weapon == WEAPON_M4) ||
                    (
WeaponDrop[i][dWeapon] == WEAPON_M4 && weapon == WEAPON_AK47) ||
                    (
WeaponDrop[i][dWeapon] == WEAPON_UZI && weapon == WEAPON_MP5) ||
                    (
WeaponDrop[i][dWeapon] == WEAPON_UZI && weapon == WEAPON_TEC9) ||
                    (
WeaponDrop[i][dWeapon] == WEAPON_TEC9 && weapon == WEAPON_MP5) ||
                    (
WeaponDrop[i][dWeapon] == WEAPON_TEC9 && weapon == WEAPON_UZI) ||
                    (
WeaponDrop[i][dWeapon] == WEAPON_MP5 && weapon == WEAPON_UZI) ||
                    (
WeaponDrop[i][dWeapon] == WEAPON_MP5 && weapon == WEAPON_TEC9) ||
                    (
WeaponDrop[i][dWeapon] == WEAPON_SNIPER && weapon == WEAPON_RIFLE) ||
                    (
WeaponDrop[i][dWeapon] == WEAPON_RIFLE && weapon == WEAPON_SNIPER) ||
                    (
WeaponDrop[i][dWeapon] == WEAPON_GRENADE && weapon == WEAPON_TEARGAS) ||
                    (
WeaponDrop[i][dWeapon] == WEAPON_GRENADE && weapon == WEAPON_MOLTOV) ||
                    (
WeaponDrop[i][dWeapon] == WEAPON_MOLTOV && weapon == WEAPON_GRENADE) ||
                    (
WeaponDrop[i][dWeapon] == WEAPON_MOLTOV && weapon == WEAPON_TEARGAS) ||
                    (
WeaponDrop[i][dWeapon] == WEAPON_TEARGAS && weapon == WEAPON_MOLTOV) ||
                    (
WeaponDrop[i][dWeapon] == WEAPON_TEARGAS && weapon == WEAPON_GRENADE))
                    {
                        
SendMessage(playeridCOLORERROR"You already have a similar weapon to this one. Use /dropgun.");
                        return 
1;
                    }
                }
                
GivePlayerValidWeapon(playeridWeaponDrop[i][dWeapon], WeaponDrop[i][dAmmo]);
                
DestroyPickup(WeaponDrop[i][dPickup]);
                
WeaponDrop[i][dWeapon] = 0;
                
WeaponDrop[i][dSpawnedTime] = 0;
                
WeaponDrop[i][dAmmo] = 0;
                
PlayerPlaySound(playerid10520.00.00.0);
            }
        } 
This is the remove player weapon function:

PHP Code:
stock RemovePlayerWeapon(playeridweaponid)
{
    new 
plyWeapons[13][2];
    for(new 
013s++)
    {
        new 
wepammo;
        
GetPlayerWeaponData(playeridswepammo);
        if(
wep != weaponid)
        {
            
GetPlayerWeaponData(playeridsplyWeapons[s][0], plyWeapons[s][1]);
        }
        else
        {
            
PlayerInfo[playerid][pGuns][s] = 0;
        }
    }
    
ResetPlayerWeaponsEx(playerid);
     for(new 
013s++)
    {
        
GivePlayerValidWeapon(playeridplyWeapons[s][0], plyWeapons[s][1]);
    }
    return 
1;

And the resetplayerweaponsex:

PHP Code:
stock ResetPlayerWeaponsEx(playerid)
{
    
ResetPlayerWeapons(playerid);
    for(new 
013i++)
    {
        
PlayerInfo[playerid][pGuns][i] = 0;
    }
    return 
1;

Anyone have an idea why this is happening? Please help me down below. Thank you
Reply


Messages In This Thread
Weapon hack check - by iamjems - 29.12.2016, 14:23
Re: Weapon hack check - by HydraHumza - 29.12.2016, 14:43
Re: Weapon hack check - by iamjems - 29.12.2016, 15:38
Re: Weapon hack check - by denNorske - 29.12.2016, 23:01
Re: Weapon hack check - by iamjems - 30.12.2016, 01:20
Re: Weapon hack check - by denNorske - 30.12.2016, 01:55
Re: Weapon hack check - by iamjems - 30.12.2016, 10:08
Re: Weapon hack check - by iamjems - 30.12.2016, 10:53
Re: Weapon hack check - by BlackBank - 30.12.2016, 14:30
Re: Weapon hack check - by cessil - 30.12.2016, 14:45
Re: Weapon hack check - by iamjems - 30.12.2016, 18:17
Re: Weapon hack check - by iamjems - 19.02.2017, 16:27

Forum Jump:


Users browsing this thread: 1 Guest(s)