Problem With Anti-2Shot (Sawns)
#1

Hello, im using the following code in my server for anti 2-shot.

Using the "OnPlayerUpdate" func.
PHP код:
public OnPlayerUpdate(playerid)
{
// anti 2 shot
    
static
        
s_iState,
        
s_iSpecialAction
    
;
    
s_iState GetPlayerStateplayerid );
    
s_iSpecialAction GetPlayerSpecialActionplayerid );
    if ( 
s_iState == PLAYER_STATE_ONFOOT && ( s_iSpecialAction == SPECIAL_ACTION_NONE || s_iSpecialAction == SPECIAL_ACTION_DUCK ) )
    {
        static
            
s_iWeapon,
            
s_iAmmo
        
;
        
s_iWeapon GetPlayerWeaponplayerid );
        
s_iAmmo GetPlayerAmmoplayerid );
        if ( 
g_cPreviousWeaponplayerid } != s_iWeapon )
        {
            if ( 
g_cPreviousWeaponplayerid } == WEAPON_SAWEDOFF )
            {
                if ( 
Bit_Getg_abIsSawnoffClipUsedplayerid ) )
                {
                    static
                        
s_iWeaponState
                    
;
                    
s_iWeaponState GetPlayerWeaponStateplayerid );
                    if ( ( 
s_iWeaponState == WEAPONSTATE_MORE_BULLETS || s_iWeaponState == WEAPONSTATE_LAST_BULLET ) && g_cFiredShotsplayerid } != )
                    {
                        
Bit_Letg_abThisBitchDidntReloadplayerid );
                        
g_iReloadEvadeTimeplayerid ] = GetTickCount( );
                    }
                }
                
g_cFiredShotsplayerid } = 0;
            }
            else if ( 
s_iWeapon == WEAPON_SAWEDOFF )
            {
                if ( 
Bit_Getg_abThisBitchDidntReloadplayerid ) )
                {
                    if ( 
GetTickCount( ) - g_iReloadEvadeTimeplayerid ] < PUNISH_THRESOLD )
                    {
                        new
                            
Float:fVX,
                            
Float:fVY,
                            
Float:fVZ
                        
;
                        
GetPlayerVelocityplayeridfVXfVYfVZ );
                        if ( 
floatabsfVZ ) < 0.15 )
                        {
                        new 
string[256];
                        if(
sWarns[playerid] == 0)
                        {
                        
sWarns[playerid]++;
                        
GameTextForPlayer(playerid"~r~2 shots Detected!"35003);
                        
format(stringsizeof(string), "(SERVER COMPLAINT) %s (%d) May Be Possibly Using 2 Shots."PlayerInfo[playerid][pName],playerid);
                        
SendClientMessageToAdmins(COLOR_ADMINstring);
                        
PlayerInfo[playerid][pWarnTime] = 80;
                        }
                        else
                        if(
sWarns[playerid] == 1)
                        {
                         if(
PlayerInfo[playerid][pWarnTime] < 1)
                        {
                        
sWarns[playerid]++;
                        
format(stringsizeof(string), "(SERVER COMPLAINT) %s (%d) May Be Possibly Using 2 Shots."PlayerInfo[playerid][pName],playerid);
                        
SendClientMessageToAdmins(COLOR_ADMINstring);
                        
PlayerInfo[playerid][pWarnTime] = 140;
                        }
                        }
                        else
                        if(
sWarns[playerid] == 2)
                        {
                        if(
PlayerInfo[playerid][pWarnTime] < 1)
                        {
                        
sWarns[playerid]++;
                        
format(stringsizeof(string), "(SERVER COMPLAINT) %s (%d) May Be Possibly Using 2 Shots."PlayerInfo[playerid][pName],playerid);
                        
SendClientMessageToAdmins(COLOR_ADMINstring);
                        
PlayerInfo[playerid][pWarnTime] = 240;
                        }
                        }
                          else
                        if(
sWarns[playerid] == 3)
                        {
                        if(
PlayerInfo[playerid][pWarnTime] < 1)
                        {
                        
sWarns[playerid]++;
                        
format(stringsizeof(string), "(SERVER COMPLAINT) %s (%d) May Be Possibly Using 2 Shots."PlayerInfo[playerid][pName],playerid);
                        
SendClientMessageToAdmins(COLOR_ADMINstring);
                        
PlayerInfo[playerid][pWarnTime] = 520;
                        }
                        }
                          else
                        if(
sWarns[playerid] == 4)
                        {
                        if(
PlayerInfo[playerid][pWarnTime] < 1)
                        {
                        
format(stringsizeof(string), "(SERVER COMPLAINT) %s (%d) May Be Possibly Using 2 Shots."PlayerInfo[playerid][pName],playerid);
                        
SendClientMessageToAdmins(COLOR_ADMINstring);
                        
PlayerInfo[playerid][pWarnTime] = 720;
                        }
                        }
                        }
                    }
                    
Bit_Vetg_abThisBitchDidntReloadplayerid );
                }
            }
            
g_cPreviousWeaponplayerid } = s_iWeapon;
        }
        if ( 
s_iWeapon == WEAPON_SAWEDOFF )
        {
            if ( 
g_iSawnoffAmmoplayerid ] == -)
                
g_iSawnoffAmmoplayerid ] = GetPlayerAmmoplayerid );
            else
            {
                if ( 
GetPlayerWeaponStateplayerid ) == WEAPONSTATE_RELOADING )
                {
                    if ( 
Bit_Getg_abIsSawnoffClipUsedplayerid ) )
                        
Bit_Vetg_abIsSawnoffClipUsedplayerid );
                }
                else
                {
                    if ( 
g_iSawnoffAmmoplayerid ] != s_iAmmo )
                    {
                        if ( 
s_iAmmo g_iSawnoffAmmoplayerid ] )
                        {
                            
Bit_Letg_abIsSawnoffClipUsedplayerid );
                            
g_cFiredShotsplayerid } += g_iSawnoffAmmoplayerid ] - s_iAmmo;
                        }
                        else
                        {
                            
g_cFiredShotsplayerid } = 0;
                            
Bit_Vetg_abIsSawnoffClipUsedplayerid );
                        }
                        
g_iSawnoffAmmoplayerid ] = s_iAmmo;
                    }
                }
            }
        }
        else if ( 
g_iSawnoffAmmoplayerid ] != -|| Bit_Getg_abIsSawnoffClipUsedplayerid ) )
        {
            
g_iSawnoffAmmoplayerid ] = -1;
            
Bit_Vetg_abIsSawnoffClipUsedplayerid );
            
g_cFiredShotsplayerid } = 0;
        }
    }
    else if ( 
g_iSawnoffAmmoplayerid ] != -|| Bit_Getg_abIsSawnoffClipUsedplayerid ) )
    {
        
g_iSawnoffAmmoplayerid ] = -1;
        
Bit_Vetg_abIsSawnoffClipUsedplayerid );
        
g_cFiredShotsplayerid } = 0;
    }
    return 
1;


There is a problem in this code, it give the false warning for anti 2-shot whenever the player switches the sawns not to 2-shot but to use the other weap..


Like if someone shoots 3 bullets from sawns and then scrolls to other weap (it will give warning)

I want to make it like, when someone switches the sawns and then scroll back to sawns then it should give the warning, not when some one switches to other weapon.

Any help?
Reply


Messages In This Thread
Problem With Anti-2Shot (Sawns) - by Airman123 - 20.04.2015, 08:44
Re: Problem With Anti-2Shot (Sawns) - by Banana_Ghost - 21.04.2015, 05:08
Re: Problem With Anti-2Shot (Sawns) - by Airman123 - 23.04.2015, 09:47
Re: Problem With Anti-2Shot (Sawns) - by ball - 23.04.2015, 11:13
Re: Problem With Anti-2Shot (Sawns) - by Airman123 - 24.04.2015, 07:43

Forum Jump:


Users browsing this thread: 2 Guest(s)