This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

Anti Deagle Spray/Spam


Post New Thread Reply   
 
Thread Tools Display Modes
Author
DiogoOnAir
Senior Member
Join Date: Jul 2018
Location: Portugal
Plugin ID:
6252
Plugin Version:
1.0
Plugin Category:
General Purpose
Plugin Game:
Counter-Strike: GO
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    This plugin blocks deagle spray!!
    Old 09-10-2018 , 15:33   Anti Deagle Spray/Spam
    Reply With Quote #1

    New Version with bug fixes.Now the plugin is working well!

    About Plugin and cvars:

    -This plugin don t have any cvar
    -This blocks deagle spam/spray.


    Bugs:

    I don t finded any bugs
    If you find send me message in steam or reply there

    Plugin And Me:

    Mine Github
    Mine Steam profile
    Plugin Download



    Suggestions are welcome!

    Last edited by DiogoOnAir; 04-07-2019 at 15:28.
    DiogoOnAir is offline
    mug1wara
    AlliedModders Donor
    Join Date: Jun 2018
    Old 09-10-2018 , 15:50   Re: Anti Deagle Spray/Spam
    Reply With Quote #2

    hiya

    There were some minor issues I would have a look at, for eg; you're mixing old and new syntax, you're using dynamic arrays when not necessary, you get the client's userid from nothing, e.t.c.

    Other than that xd, it's looking pretty solid.

    Here's a "fixed" version:
    PHP Code:
    #include <sourcemod>
    #include <sdkhooks>
    #include <sdktools>
    #include <smlib>

    #pragma semicolon 1

    #define PLUGIN_NAME             "AntiDeagle Spray"
    #define PLUGIN_AUTHOR             "DiogoOnAir"
    #define PLUGIN_DESCRIPTION        "AntiDeagleSpray"
    #define PLUGIN_VERSION             "1.0"

    public Plugin myinfo =
    {
        
    name                =    PLUGIN_NAME,
        
    author                =    PLUGIN_AUTHOR,
        
    description            =    PLUGIN_DESCRIPTION,
        
    version                =    PLUGIN_VERSION,
    };

    public 
    OnPluginStart()
    {
        
    HookEvent("weapon_fire"Event_WeaponFire);
    }

    public 
    void Event_WeaponFire(Event event, const char[] sEventNamebool bDontBroadcast)
    {
        
    // Get the client
        
    int client GetClientOfUserId(event.GetInt("userid"));
        
        
    // Check if our sir is valid
        
    if (IsClientInGame(client))
        {
            
    // Array to store the client's weapon in
            
    char sWeapon[32];
            
    // Get the client's weapon and store it in the array
            
    GetClientWeapon(clientsWeaponsizeof(sWeapon));
            
            
    // If the client has a deagle
            
    if (StrEqual(sWeapon"weapon_deagle"))
                
    // Trigger this timer, pass the client's userid to the callback, it's safer
                
    CreateTimer(0.5ChangeKnifeGetClientUserId(client));
        }
    }

    public 
    Action ChangeKnife(Handle timerint data)
    {
        
    // since we've got the client's userid stored in the "data" var, we somehow have to get the actual client from that userid
        
    int client GetClientOfUserId(data);
        
        if (
    IsClientInGame(iClient))
            
    // set the client's weapon to a grenade, because counting starts at 0, for knife; simply change 3 with 2
            
    Client_SetActiveWeapon(clientGetPlayerWeaponSlot(client3));

    Cheers!
    mug1wara is offline
    DiogoOnAir
    Senior Member
    Join Date: Jul 2018
    Location: Portugal
    Old 09-10-2018 , 19:09   Re: Anti Deagle Spray/Spam
    Reply With Quote #3

    Okk Thanks i will update it
    DiogoOnAir is offline
    Ilusion9
    Veteran Member
    Join Date: Jun 2018
    Location: Romania
    Old 09-11-2018 , 05:50   Re: Anti Deagle Spray/Spam
    Reply With Quote #4

    Stop using IsClientInGame after GetClientOfUserId. It's a waste of time. Just check if client != 0.

    https://sm.alliedmods.net/new-api/cl...ClientOfUserId
    If the client is not in game, his userid is invalid.

    Also, weapon_fire has a field called 'weapon'
    https://wiki.alliedmods.net/Counter-...ts#weapon_fire

    PHP Code:
    #include <sourcemod> 
    #include <sdkhooks> 
    #include <sdktools> 
    #include <smlib> 

    #pragma semicolon 1 

    #define PLUGIN_NAME             "AntiDeagle Spray" 
    #define PLUGIN_AUTHOR             "DiogoOnAir" 
    #define PLUGIN_DESCRIPTION        "AntiDeagleSpray" 
    #define PLUGIN_VERSION             "1.0" 

    public Plugin myinfo 

        
    name                =    PLUGIN_NAME
        
    author                =    PLUGIN_AUTHOR
        
    description            =    PLUGIN_DESCRIPTION
        
    version                =    PLUGIN_VERSION
    }; 

    public 
    OnPluginStart() 

        
    HookEvent("weapon_fire"Event_WeaponFire); 


    public 
    void Event_WeaponFire(Event event, const char[] sEventNamebool bDontBroadcast
    {
        
    char sWeapon[65];
        
    event.GetString("weapon"sWeaponsizeof(sWeapon));
        
        if (
    StrEqual(sWeapon"weapon_deagle")) 
        {
            
    CreateTimer(0.5ChangeKnifeevent.GetInt("userid")); 
        }


    public 
    Action ChangeKnife(Handle timerint data

        
    int client GetClientOfUserId(data); 
         
        if (
    client
        {
            
    Client_SetActiveWeapon(clientGetPlayerWeaponSlot(client3));
        }


    Last edited by Ilusion9; 09-11-2018 at 05:57.
    Ilusion9 is offline
    mug1wara
    AlliedModders Donor
    Join Date: Jun 2018
    Old 09-11-2018 , 09:38   Re: Anti Deagle Spray/Spam
    Reply With Quote #5

    You’re partly right.

    But, when passing client userid to callback, especially on timers; you have to validate the client multiple times.

    To my defense; I normalized the code in 60 sec, leave the man be.
    mug1wara is offline
    Ilusion9
    Veteran Member
    Join Date: Jun 2018
    Location: Romania
    Old 09-11-2018 , 11:21   Re: Anti Deagle Spray/Spam
    Reply With Quote #6

    Quote:
    Originally Posted by mug1wara View Post
    You’re partly right.

    But, when passing client userid to callback, especially on timers; you have to validate the client multiple times.

    To my defense; I normalized the code in 60 sec, leave the man be.
    You send the userid as parameter and in the callback you get the index. All validations are made in GetClientOfUserId. If that client is not valid, then the function will return 0. When the client disconnects, his userid will be invalid for GetClientOfUserId.

    Last edited by Ilusion9; 09-11-2018 at 11:21.
    Ilusion9 is offline
    mug1wara
    AlliedModders Donor
    Join Date: Jun 2018
    Old 09-11-2018 , 11:55   Re: Anti Deagle Spray/Spam
    Reply With Quote #7

    "especially on timers; you have to validate the client multiple times." - I quote myself.

    What if the client disconnects?

    Now, let's not start an argument alright? I'm done with this.
    mug1wara is offline
    Ilusion9
    Veteran Member
    Join Date: Jun 2018
    Location: Romania
    Old 09-11-2018 , 12:45   Re: Anti Deagle Spray/Spam
    Reply With Quote #8

    Quote:
    Originally Posted by mug1wara View Post
    "especially on timers; you have to validate the client multiple times." - I quote myself.

    What if the client disconnects?

    Now, let's not start an argument alright? I'm done with this.
    and how you validate the client multiple times when that function validate the client multiple times?
    so you force a thing that already happened, and that thing will be always true.

    PHP Code:

    public Action ChangeKnife(Handle timerint data

        
    int client GetClientOfUserId(data); 
         
        if (
    client// true or false
        
    {
            if (
    IsClientInGame(client)) // always true. waste of cpu.
            
    {
                
    Client_SetActiveWeapon(clientGetPlayerWeaponSlot(client3));
            }
        }

    Ilusion9 is offline
    mug1wara
    AlliedModders Donor
    Join Date: Jun 2018
    Old 09-11-2018 , 16:07   Re: Anti Deagle Spray/Spam
    Reply With Quote #9

    Guess were going to argue even further, okay.

    Aaaaaaas is the clieeent miiiight leaaave in the meantiiime.

    You’re more then welcome to argue privately, but you’ve got to understand that this isn’t the right place to do it.

    Edit:

    I am too blaming myself.

    Last edited by mug1wara; 09-11-2018 at 16:10.
    mug1wara is offline
    Reply



    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off

    Forum Jump


    All times are GMT -4. The time now is 12:37.


    Powered by vBulletin®
    Copyright ©2000 - 2024, vBulletin Solutions, Inc.
    Theme made by Freecode