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

[CS:GO/DHooks] Hooking GetMaxClip1 - invisible weapons?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
pcmaster
AlliedModders Donor
Join Date: Sep 2009
Old 02-21-2016 , 07:22   [CS:GO/DHooks] Hooking GetMaxClip1 - invisible weapons?
Reply With Quote #1

Hello,

I am currently working on a plugin which allows you to set custom clip sizes (the one you "use").
For that, I am using DHooks to hook CBaseCombatWeapon::GetMaxClip1.

It works mostly (the ammo is correctly overriden), but my main problem is that ALL weapons (primary, secondary, knife) become invisible when the plugin is active.

Upon unloading, they become fully visible again.

Relevant code:
PHP Code:
    Handle gameConf LoadGameConfigFile("clip_manager.games");
    
    
int offsetMax GameConfGetOffset(gameConf"GetMaxClip1");
    
delete gameConf;
    
    
g_hMaxClip1 DHookCreate(offsetMaxHookType_EntityReturnType_IntThisPointer_CBaseEntityOnGetClip1);
[..]

public 
void OnEntityCreated(int entity, const char[] classname)
{
    if(
StrContains(classname"knife") == -&& StrContains(classname"grenade") == -1)
    {
        
DHookEntity(g_hMaxClip1trueentityOnHookRemoved);
    }
}

public 
MRESReturn OnGetClip1(int pThisHandle hReturn)
{
    
DHookSetReturn(hReturn200);
    return 
MRES_Supercede;

I already tried EntityRenderMode to NORMAL, but that doesn't change anything.
In the disassembly I have seen that the original function accesses the weapon script file, maybe I forgot to initialize something?

Any help would be appreciated!
</span>
__________________
Stopped hosting servers as of November 2018, no longer active around here.
pcmaster is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 02-21-2016 , 08:37   Re: [CS:GO/DHooks] Hooking GetMaxClip1 - invisible weapons?
Reply With Quote #2

You can have a look at this one. Doesn't work well with single shell reloading shotguns (yet), but does what you want to accomplish.
https://github.com/peace-maker/smrpg...de_clipsize.sp
__________________
Peace-Maker is offline
pcmaster
AlliedModders Donor
Join Date: Sep 2009
Old 02-21-2016 , 09:01   Re: [CS:GO/DHooks] Hooking GetMaxClip1 - invisible weapons?
Reply With Quote #3

Seems like I have found the issue.. I was hooking too much stuff.
My initial check in OnEntityCreated filtered out HEs/Knives, but not other entites, like game managers and such..

Now it works perfectly.
__________________
Stopped hosting servers as of November 2018, no longer active around here.
pcmaster 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:59.


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