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

Solved 2D Array in Enum | cs_get_weapon_id in FM_SetModel


Post New Thread Reply   
 
Thread Tools Display Modes
Natsheh
Veteran Member
Join Date: Sep 2012
Old 01-21-2018 , 10:54   Re: 2D Array in Enum | cs_get_weapon_id in FM_SetModel
Reply With Quote #21

Can you show your file format?
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 01-21-2018 , 11:05   Re: 2D Array in Enum | cs_get_weapon_id in FM_SetModel
Reply With Quote #22

It works for me, I used a dummy config like:
PHP Code:
V_AK47 models/v_m4a1.mdl
P_AK47 
models/p_m4a1.mdl
W_AK47 
models/w_m4a1.mdl

V_AUG 
models/v_awp.mdl
P_AUG 
models/p_awp.mdl
W_AUG 
models/w_awp.mdl

V_AWP 
models/v_ak47.mdl
P_AWP 
models/p_ak47.mdl
W_AWP 
models/w_ak47.mdl 
__________________
HamletEagle is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 01-21-2018 , 11:12   Re: 2D Array in Enum | cs_get_weapon_id in FM_SetModel
Reply With Quote #23

Quote:
Originally Posted by HamletEagle View Post
It works for me, I used a dummy config like:
PHP Code:
V_AK47 models/v_m4a1.mdl
P_AK47 
models/p_m4a1.mdl
W_AK47 
models/w_m4a1.mdl

V_AUG 
models/v_awp.mdl
P_AUG 
models/p_awp.mdl
W_AUG 
models/w_awp.mdl

V_AWP 
models/v_ak47.mdl
P_AWP 
models/p_ak47.mdl
W_AWP 
models/w_ak47.mdl 
Yeah, it's working perfectly fine now, I forgot to change the keys that's why it wasn't working. Thanks for your effort Hamlet!
__________________
edon1337 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 01-21-2018 , 11:26   Re: 2D Array in Enum | cs_get_weapon_id in FM_SetModel
Reply With Quote #24

g_szWeapons is not needed, do a loop from CSW_P228 to CSW_P90 and use get_weaponname to retrieve the weapon_* name. If you want to skip pistols or whatever use a bitsum:
PHP Code:
new Bitsum = (<< CSW_DEAGLE) | (<< CSW_P228) | .... 
PHP Code:
//in for
if(Bitsum & (<< i))
{
     continue

__________________

Last edited by HamletEagle; 01-21-2018 at 11:26.
HamletEagle is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 01-21-2018 , 13:31   Re: 2D Array in Enum | cs_get_weapon_id in FM_SetModel
Reply With Quote #25

Quote:
Originally Posted by HamletEagle View Post
g_szWeapons is not needed, do a loop from CSW_P228 to CSW_P90 and use get_weaponname to retrieve the weapon_* name. If you want to skip pistols or whatever use a bitsum:
PHP Code:
new Bitsum = (<< CSW_DEAGLE) | (<< CSW_P228) | .... 
PHP Code:
//in for
if(Bitsum & (<< i))
{
     continue

I actually thought about that, but looked at get_weaponname native and, there was an 'id' as the first parameter, so it confused me with player ID, and just sticked to the hard-coded method.

Am I in the right way of setting the w_ model?

PHP Code:
public fw_FMSetModelPreiEntszModel[ ] )
{
    if( ! 
pev_validiEnt ) )
    return 
FMRES_IGNORED;
    
    new 
szClassName32 ], iDataModelType ];
    
peviEntpev_classnameszClassNamecharsmaxszClassName ) );
    
    if( 
equalszClassName"weaponbox" ) )
    {        
        if( ! 
equalszModel"models/w_weaponbox.mdl" ) )
        {
            new 
iWeaponID GetWeaponBoxWeaponTypeiEnt );
            new 
szWeaponName32 ];
            
get_weaponnameiWeaponIDszWeaponNamecharsmaxszWeaponName ) );
            
            
replaceszWeaponNamecharsmaxszWeaponName ), "weapon_""" );
            
trimszWeaponName );
            
            if( 
TrieGetArrayg_tWeaponModelsszWeaponNameiDatasizeof iData ) )
            {
                if( 
iDatawModel ][ ] )
                {
                    
engfuncEngFunc_SetModeliEntiDatawModel ] );
                    return 
FMRES_SUPERCEDE;
                }
            }
        }
    }
    
    else if( 
equalszClassName"armoury_entity" ) )
    {        
        new 
iWeaponID cs_get_armoury_typeiEnt );
        new 
szWeaponName32 ];
        
get_weaponnameiWeaponIDszWeaponNamecharsmaxszWeaponName ) );
        
        
replaceszWeaponNamecharsmaxszWeaponName ), "weapon_""" );
        
trimszWeaponName );
        
        if( 
TrieGetArrayg_tWeaponModelsszWeaponNameiDatasizeof iData ) )
        {
            if( 
iDatawModel ][ ] )
            {
                
engfuncEngFunc_SetModeliEntiDatawModel ] );
                return 
FMRES_SUPERCEDE;
            }
        }
    }
    return 
FMRES_IGNORED;

EDIT: It works, just for weaponbox entities, so only after I pick it up and then drop it, it doesn't work for armoury_entity entities.
__________________

Last edited by edon1337; 01-21-2018 at 13:56.
edon1337 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 01-21-2018 , 16:02   Re: 2D Array in Enum | cs_get_weapon_id in FM_SetModel
Reply With Quote #26

Debug your code, see where it fails. Does it even gets called for armoury_entity?
If it doesn't, try hookoing FM_SetModel in plugin_precache.
__________________
HamletEagle is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 01-21-2018 , 16:09   Re: 2D Array in Enum | cs_get_weapon_id in FM_SetModel
Reply With Quote #27

Quote:
Originally Posted by HamletEagle View Post
Debug your code, see where it fails. Does it even gets called for armoury_entity?
If it doesn't, try hookoing FM_SetModel in plugin_precache.
Hooking it in plugin_precache worked. Thanks a bunch man, you don't realise how amazing you are
__________________
edon1337 is offline
E1_531G
Senior Member
Join Date: Dec 2017
Old 01-24-2018 , 11:24   Re: 2D Array in Enum | cs_get_weapon_id in FM_SetModel
Reply With Quote #28

Quote:
Originally Posted by edon1337 View Post
What's the matter with you, douchebag? Who asked for you to come here and act like a d*ck? No offense but you're closed-minded and an idiot. Now get outta here.
I did not offend you. But, you wrote four bad words to me. Am i still an idiot?
You just set yourself up as a complete imbecile.

And why do i always meet backward people...?? Don't know.

Will moderators do something?
I see such words as: douchebag, d*ck, closed-minded, idiot.
All in one post.
__________________
My English is A0
E1_531G is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 01-24-2018 , 14:46   Re: 2D Array in Enum | cs_get_weapon_id in FM_SetModel
Reply With Quote #29

Quote:
Originally Posted by E1_531G View Post
Here you write string not array. Don't you see?

Go and read about how to use Trie***Array().

And, you have luck, Hamlet helps you, but you are incredible slow and blind...
I had nothing with you and you just jumped at me?
Yes, I'm gonna call you a douchebag, because anyone who acts like that deserves to be called that.
Don't spam this thread anymore. End of the topic.
__________________
edon1337 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 16:46.


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