AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved get_pdata_int(ent, m_iId, 4) returns invalid value (https://forums.alliedmods.net/showthread.php?t=329843)

Natsheh 01-10-2021 05:37

get_pdata_int(ent, m_iId, 4) returns invalid value
 
PHP Code:

public plugin_init()
{
    for(new 
i=CSW_P228szClassname[32]; <= CSW_P90i++)
    {
        if((
get_weaponname(iszClassnamecharsmax(szClassname)) > 7) && ((1<<i) & (CSW_ALL_PISTOLS|CSW_ALL_GRENADES|(1<<CSW_KNIFE))))
        {
            
RegisterHam(Ham_Item_DeployszClassname"fw_weapon_deploy"true);
        }
        else if(
szClassname[0] != 0)
        {
            
RegisterHam(Ham_Item_DeployszClassname"fw_weapon_remove"true);
        }
    }
}

public 
fw_weapon_deploy(ent)
{
    new 
id pev(entpev_owner), ent;
    
    if(
id && (ent=ENT_PLAYER[id]) > 0)
    {
        
engfunc(EngFunc_SetModelent"");
        
        new 
aWeapons[32], szWeaponName[32], wpnum 0currwpn;
        
get_user_weapons(idaWeaponswpnum);
        
        const 
m_iId 43
        currwpn 
= (1<<get_pdata_int(entm_iId4)); // get used weapon...
        
        
for(new 0szString[64], szClassname[32]; wpnumi++)
        {
            
client_print(idprint_chat"currwpn: %d WpnID: %d"get_pdata_int(entm_iId4), aWeapons[i]);
            if( ( (
1<<aWeapons[i]) & ( (0xFFFFFF & ~0x000001) & ~(currwpn|CSW_ALL_PISTOLS|CSW_ALL_GRENADES|(1<<CSW_KNIFE)) ) ) > 0)
            {
                if(
get_weaponname(aWeapons[i], szClassnamecharsmax(szClassname)) > 7) {
                    
formatex(szStringcharsmax(szString), "models/w_%s.mdl"szClassname[7]);
                    
engfunc(EngFunc_SetModelentszString);
                    break;
                }
            }
        }
    }
}

public 
fw_weapon_remove(ent)
{
    new 
id pev(entpev_owner), ent;
    
    if(
id && (ent=ENT_PLAYER[id]) > 0)
    {
        
engfunc(EngFunc_SetModelent"");
    }



Outputs :-
Code:


currwpn: 0 WpnID: 4
currwpn: 0 WpnID: 9
currwpn: 0 WpnID: 25
currwpn: 0 WpnID: 26
currwpn: 0 WpnID: 28
currwpn: 0 WpnID: 29


meta list

Code:


Currently loaded plugins:
      description      stat pend  file              vers      src  load  unlod
 [ 1] AMX Mod X        RUN  -    amxmodx_mm.dll    v1.9.0.5  ini  Start ANY 
 [ 2] POD-Bot mm      RUN  -    podbot_mm.dll    vV3B22    ini  Chlvl ANY 
 [ 3] FakeMeta        RUN  -    fakemeta_amxx.dl  v1.9.0.5  pl1  ANY  ANY 
 [ 4] Ham Sandwich    RUN  -    hamsandwich_amxx  v1.9.0.5  pl1  ANY  ANY 
 [ 5] CSX              RUN  -    csx_amxx.dll      v1.9.0.5  pl1  ANY  ANY 
 [ 6] CStrike          RUN  -    cstrike_amxx.dll  v1.9.0.5  pl1  ANY  ANY 
 [ 7] Fun              RUN  -    fun_amxx.dll      v1.9.0.5  pl1  ANY  ANY 
7 plugins, 7 running


Bugsy 01-10-2021 10:10

Re: get_pdata_int(ent, m_iId, 4) returns invalid value
 
Your problem is here:
Code:

public fw_weapon_deploy(ent)
{
        new id = pev(ent, pev_owner), ent;


Natsheh 01-10-2021 10:17

Re: get_pdata_int(ent, m_iId, 4) returns invalid value
 
lmao i see, i was wondering why i had alot of invalid outputs, the compiler is stupid but it should give warnings about such problems..

Bugsy 01-10-2021 10:26

Re: get_pdata_int(ent, m_iId, 4) returns invalid value
 
Yeah, I wish the compiler would catch duplicate variable definitions. It can drive you crazy trying to figure out why code is not working when you know it is otherwise correct.


All times are GMT -4. The time now is 14:08.

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