OnPlayerWeaponShot
#1

Hey, my Anti Cheat is kicking innocent players and now I think I understood why
That's the code
PHP Code:
public OnPlayerWeaponShot(playeridweaponidhittypehitidFloat:fXFloat:fYFloat:fZ)
{
    new 
string[24];
    
format(stringsizeof(string), "debug: %d, %d"GetPlayerAmmo(playerid), PlayerInfo[playerid][pWeaponAmmo][GetWeaponSlot(weaponid)]);
    print(string);
    
PlayerInfo[playerid][pWeaponAmmo][GetWeaponSlot(weaponid)]--;
    
format(stringsizeof(string), "debug: %d, %d"GetPlayerAmmo(playerid), PlayerInfo[playerid][pWeaponAmmo][GetWeaponSlot(weaponid)]);
    print(string);
    return 
1;

That's the anti hack code
PHP Code:
forward WeaponHack();
public 
WeaponHack()
{
    new 
weaponidammokeysudlr;
    foreach(new 
playerid Player)
    {
        
weaponid GetPlayerWeapon(playerid); ammo GetPlayerAmmo(playerid);
        if(
weaponid != PlayerInfo[playerid][pWeapon][GetWeaponSlot(weaponid)] || ammo != PlayerInfo[playerid][pWeaponAmmo][GetWeaponSlot(weaponid)]) Kick(playerid);
    }
    return 
1;

Now, I think I got the problem
I debugged it, and I found out that first - It's decreased from the Array
PHP Code:
PlayerInfo[playerid][pWeaponAmmo][GetWeaponSlot(weaponid)]--; 
And only after that, its decreased from my GetPlayerAmmo()

Here is the debug
(First line: debug: GetPlayerAmmo() || WeaponAmmo Array)
(Second line (After Array--: debug: GetPlayerAmmo() || WeaponAmmo Array)

Code:
debug: 300, 300
debug: 300, 299
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)