Raised This Month: $ Target: $400
 0% 

Solved Get weapon's entity id, from weapon ID


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
GasmoN
Member
Join Date: Jul 2014
Old 12-09-2020 , 11:16   Re: Get weapon's entity id, from weapon ID
Reply With Quote #3

Thank you, this is how I fixed this

At the end of every round, I added pf_check_weapon_life()
If anyone know any better way, I would like to hear it.
PHP Code:
public zp_fw_gamemodes_end() // Round just ended.
{
    
pf_check_weapon_life();
}

stock pf_check_weapon_life()
{
    new 
i;
    
    for(
1<= g_maxplayersi++)
    {
        if(
is_user_alive(i))
        {
            
pf_check_user_inventory(i);
        }
    }
}

stock pf_check_user_inventory(id
{
    new 
weapons[32], num
    get_user_weapons
(idweaponsnum)
    
    for (new 
0numi++) 
    {
        if (
weapons[i] > 0
        {
            new 
iEnt pf_find_weapon_ent_id(idweapons[i]);
            new 
iEntLife entity_get_int(iEntENT_INDENT_LIFE);
            
            switch(
iEntLife)
            {
                case 
ENT_KEY_LIFE_ONEROUND:
                {
                    
fm_strip_user_gun(idweapons[i]);
                }
            }            
        }
    }
}

stock pf_find_weapon_ent_id(idCSW_ID)
{
    static 
entszClassname[24]; ent = -1;
    
get_weaponname(CSW_IDszClassnamecharsmax(szClassname));
    
    while ((
ent find_ent_by_class(entszClassname)) > && entity_get_edict(entEV_ENT_owner) != id) { }
    return (
ent && entity_get_edict(entEV_ENT_owner) == id) ? ent:0;


Last edited by GasmoN; 12-09-2020 at 11:17.
GasmoN is offline
 


Thread Tools
Display Modes

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:26.


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