Raised This Month: $ Target: $400
 0% 

Solved Get weapon's entity id, from weapon ID


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Natsheh
Veteran Member
Join Date: Sep 2012
Old 12-08-2020 , 18:37   Re: Get weapon's entity id, from weapon ID
Reply With Quote #1

Engine
Code:
get_player_weapon_entity(id, CSW_ID) {     static ent, szClassname[24]; ent = -1;     get_weaponname(CSW_ID, szClassname, charsmax(szClassname));     while ( (ent=find_ent_by_class(ent, szClassname)) > 0 && entity_get_edict(ent, EV_ENT_owner) != id ) { }         return ent; }


Or most common sense.

Code:
ent = find_ent_by_owner(-1, "weapon_class", owner);

or
Hamsandwich

PHP Code:
new g_user_weapon_ent_pointer[32][32];

public 
plugin_init()
{
    
    for ( new 
i=CSW_P228<= CSW_P90i++)
    {
        if(
get_weaponname(iszWpncharsmax(szWpn)))
        {
            
RegisterHam(Ham_Item_AddToPlayerszWpn"fw_weapon_addtoplayer_post"true);
            
RegisterHam(Ham_Item_KillszWpn"fw_weapon_kill_post"true);
        }
    }
}


public 
fw_weapon_addtoplayer_post(entplayer)
{
    static 
szClassname[32];
    
entity_get_string(entEV_SZ_classnameszClassnamecharsmax(szClassname));
    
g_user_weapon_ent_pointer[player 1][ get_weaponid(szClassname)-] = ent;
}

public 
fw_weapon_kill_post(ent)
{
    new 
player entity_get_edict(entEV_ENT_owner);
    
    static 
szClassname[32];
    
entity_get_string(entEV_SZ_classnameszClassnamecharsmax(szClassname));
    
    
g_user_weapon_ent_pointer[player 1][ get_weaponid(szClassname)-] = 0;

__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 12-09-2020 at 12:55. Reason: Code updated
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
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:26.


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