Raised This Month: $51 Target: $400
 12% 

[CSGO (Solved)] Block Player Reload Command


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 08-19-2015 , 09:34   [CSGO (Solved)] Block Player Reload Command
Reply With Quote #1

I am wondering how I can block +reload/ -reload player command in CSGO, because I want to block this command for those who have Unlimited Clip feature enabled.

RegConsoleCmd("(+|-)reload", OnReload) and then returning Plugin_Handled or Stop doesn't work.

Thanks.

Last edited by claudiuhks; 08-20-2015 at 02:28.
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
TheUnderTaker
Senior Member
Join Date: Dec 2013
Location: Israel
Old 08-19-2015 , 11:05   Re: [CSGO] Block Player Reload Command
Reply With Quote #2

If it doesn't work for you, apperantly it's client side, I'm unsure cause i'm not a programmer for cs:go.
__________________
SourcePawn, C# and C++ Programmer.

My plugin list
TheUnderTaker is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 08-19-2015 , 11:08   Re: [CSGO] Block Player Reload Command
Reply With Quote #3

Have you tried SDKHook_Reload ?

-> https://sm.alliedmods.net/new-api/sdkhooks/__raw
KissLick is offline
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 08-20-2015 , 00:52   Re: [CSGO] Block Player Reload Command
Reply With Quote #4

Quote:
Originally Posted by KissLick View Post
Have you tried SDKHook_Reload ?

-> https://sm.alliedmods.net/new-api/sdkhooks/__raw
Tested and doesn't work.

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

public OnPluginStart()
{
    
CreateTimer(0.33TimerReload_TIMER_REPEAT);
}

public 
Action:OnWpnReload(Weapon)
{
    static 
Owner 0;

    if (
Weapon != INVALID_ENT_REFERENCE && IsValidEdict(Weapon))
    {
        
Owner GetEntProp(WeaponProp_Send"m_hOwner");

        if (
Owner != INVALID_ENT_REFERENCE && Owner >= && Owner <= MaxClients && \
            
IsClientInGame(Owner) && IsPlayerAlive(Owner))
            return 
Plugin_Stop;
    }

    return 
Plugin_Continue;
}

public 
OnEntityCreated(Entity, const String:className[])
{
    if (
Entity != INVALID_ENT_REFERENCE && IsValidEdict(Entity) && StrContains(className"Weapon"false) != -1)
        
SDKHook(EntitySDKHook_ReloadOnWpnReload);
}

public 
OnEntityDestroyed(Entity)
{
    if (
Entity != INVALID_ENT_REFERENCE)
        
SDKUnhook(EntitySDKHook_ReloadOnWpnReload);
}

public 
Action:TimerReload(Handle:pTimer)
{
    static 
Weapon 0Client 0String:Class[64];

    for (
Client 1Client <= MaxClientsClient++)
    {
        if (!
IsClientInGame(Client) || !IsPlayerAlive(Client))
            continue;

        
Weapon GetEntPropEnt(ClientProp_Send"m_hActiveWeapon");

        if (
Weapon != INVALID_ENT_REFERENCE && IsValidEdict(Weapon) && GetEdictClassname(Weapon, Class, sizeof(Class)))
        {
            if (
StrContains(Class, "Knife"false) == -&& \
                
StrContains(Class, "Taser"false) == -&& \
                
StrContains(Class, "Grenade"false) == -&& \
                
StrContains(Class, "Flash"false) == -&& \
                
StrContains(Class, "Smoke"false) == -&& \
                
StrContains(Class, "Incendiary"false) == -&& \
                
StrContains(Class, "Molotov"false) == -&& \
                
StrContains(Class, "Projectile"false) == -&& \
                
StrContains(Class, "Defuse"false) == -&& \
                
StrContains(Class, "Kit"false) == -&& \
                
StrContains(Class, "Zeus"false) == -&& \
                
StrContains(Class, "Bang"false) == -&& \
                
StrContains(Class, "Decoy"false) == -1)
            {
                
SetEntProp(WeaponProp_Send"m_iClip1"32);
                
SetEntProp(WeaponProp_Send"m_iClip2"32);
            }
        }
    }


Last edited by claudiuhks; 08-20-2015 at 00:54.
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
Potato Uno
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
Old 08-20-2015 , 00:58   Re: [CSGO] Block Player Reload Command
Reply With Quote #5

Quote:
Originally Posted by TheUnderTaker View Post
If it doesn't work for you, apperantly it's client side, I'm unsure cause i'm not a programmer for cs:go.
It's DEFINITELY not client side since the server needs to be informed if a client loads a clip.

Do you need to use a command listener maybe? (Just guessing.)
Potato Uno is offline
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 08-20-2015 , 01:09   Re: [CSGO] Block Player Reload Command
Reply With Quote #6

Quote:
Originally Posted by Potato Uno View Post
Do you need to use a command listener maybe? (Just guessing.)
I've tried with AddCommandListener(CmdReload, "(+|-)reload"), and still doesn't work. If this is what you mean.
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 08-20-2015 , 01:24   Re: [CSGO] Block Player Reload Command
Reply With Quote #7

Code:
Owner = GetEntProp(Weapon, Prop_Send, "m_hOwner");
should probably be

Code:
Owner = GetEntPropEnt(Weapon, Prop_Send, "m_hOwner");
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Icon315
Junior Member
Join Date: Dec 2014
Old 08-20-2015 , 02:23   Re: [CSGO] Block Player Reload Command
Reply With Quote #8

This should work, I used it for a paintball game I made. It will still run the reload animation for the client, since that part is client side, but it will not reload their weapon.
PHP Code:
#include <sdkhooks> 
#include <sdktools> 

public Action:OnPlayerRunCmd(client, &buttons)
{
    if(!(
buttons IN_RELOAD))
    {
        return 
Plugin_Continue;
    }
    else
    {
        
buttons &= ~IN_RELOAD;
        return 
Plugin_Changed;
    }


Last edited by Icon315; 08-20-2015 at 02:24. Reason: removed the weapon check
Icon315 is offline
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 08-20-2015 , 02:27   Re: [CSGO] Block Player Reload Command
Reply With Quote #9

Quote:
Originally Posted by Powerlord View Post
Code:
Owner = GetEntProp(Weapon, Prop_Send, "m_hOwner");
should probably be

Code:
Owner = GetEntPropEnt(Weapon, Prop_Send, "m_hOwner");
Thank God, hon. It did really work! Appreciate!
Where's the Thank button when you need it...

Quote:
Originally Posted by Icon315 View Post
This should work, I used it for a paintball game I made. It will still run the reload animation for the client, since that part is client side, but it will not reload their weapon.
Thank you too.

Last edited by claudiuhks; 08-20-2015 at 02:28.
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 08-20-2015 , 13:29   Re: [CSGO (Solved)] Block Player Reload Command
Reply With Quote #10

And since that apparently was the solution, I'll mention one more thing:

If a netprop or datamap has an h before the name (i.e. m_hSomething) it requires GetEntPropEnt because it's wrapped in a EHandle/CHandle on the server side. Which is similar to a SourceMod reference, but slightly different.

Actually, does SourceMod even have a function to convert from a Source reference to a SourceMod reference? I think MakeCompatEntRef is to go the other direction (SourceMod reference to Source reference).
__________________
Not currently working on SourceMod plugin development.
Powerlord 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 20:23.


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