Raised This Month: $ Target: $400
 0% 

Weapon Index from EntID?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 08-13-2011 , 12:34   Weapon Index from EntID?
Reply With Quote #1

Hello, is there any way around to detect weapon index from the world entity id?
Backstabnoob is offline
Owyn
Veteran Member
Join Date: Nov 2007
Old 08-13-2011 , 12:54   Re: Weapon Index from EntID?
Reply With Quote #2

PHP Code:
#define offset_cs_get_weapon_id(%1)            get_pdata_int(%1, m_iId, 4) 
__________________
☜ Free Mozy ☂backup\҉sync user
Quote:
Американский форум - Задаёшь вопрос, потом тебе отвечают.
Израильский форум - Задаёшь вопрос, потом тебе задают вопрос.
Русский форум - Задаёшь вопрос, потом тебе долго рассказывают, какой ты мудак.
Owyn is offline
Send a message via ICQ to Owyn
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 08-13-2011 , 13:01   Re: Weapon Index from EntID?
Reply With Quote #3

Okay, and any way how to use it in FM_SetModel? It looks like I won't be able to destroy only deagle whenever dropped, because when I compared the model it was w_weaponbox.mdl instead of w_deagle.
Backstabnoob is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 08-13-2011 , 14:15   Re: Weapon Index from EntID?
Reply With Quote #4

FM_SetModel gets you a entity id, so you can use that define function on it.

And no, it can't have w_weaponbox.mdl model because then it would look like a big green can (drops from HLDM on death), it's got "weaponbox" classname but the model is models/w_<weapon_name>.mdl, so revise your code
__________________
Hunter-Digital is offline
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 08-13-2011 , 16:09   Re: Weapon Index from EntID?
Reply With Quote #5

PHP Code:
public forward_set_model(entidmodel[]) 
{
    
    
    if (!
is_valid_ent(entid))
        return 
FMRES_IGNORED

    
new id entity_get_edict(entidEV_ENT_owner)
    if (!
id || !is_user_connected(id) || is_user_alive(id))
        return 
FMRES_IGNORED

    client_print
(idprint_chat"weapon model: %s"model)
        
    new 
weaponid cs_get_weapon_id(entid)
    
    
client_print(idprint_chat"%d"weaponid)
        
    if (
weaponid == CSW_DEAGLE
    {
        
kill_entity(entid)
        return 
FMRES_IGNORED
    
}

    return 
FMRES_IGNORED

weaponid = 0, weaponmodel w_weaponbox.mdl

try it yourself
Backstabnoob is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-13-2011 , 17:01   Re: Weapon Index from EntID?
Reply With Quote #6

Because you are hooking the weapon box.
Try finding it's containing weapons.

Code:
stock getWeaponBoxEnts(weaponBox, ents[], entSize) {     if(entSize < 1 || !pev_valid(weaponBox)) {         return 0;     }         new maxEnts = global_get(glb_maxEntities);     new numEnts = 0;         for(new ent = get_maxplayers() + 1; ent <= maxEnts && numEnts < entSize; ent++) {         if(pev_valid(ent) && pev(ent, pev_owner) == weaponBox) {             ents[numEnts++] = ent;         }     }         return numEnts; }

Code:
// dropped weapon forward new weapons[32]; new numWeapons = getWeaponBoxEnts(entid, weapons, sizeof(weapons)); new class[32]; for(new i = 0; i < numWeapons; i++) {     pev(weapons[i], pev_classname, class, charsmax(class));     client_print(id, print_chat, "Dropped %s", class); }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] 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 03:21.


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