Raised This Month: $ Target: $400
 0% 

Weaponbox Data


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Phant
Veteran Member
Join Date: Sep 2009
Location: New Jersey
Old 11-15-2013 , 10:23   Weaponbox Data
Reply With Quote #1

Hello. I used the search, but can not find exactly what I want.

I can hook weaponbox spawn:
PHP Code:
RegisterHam(Ham_Spawn"weaponbox""weaponbox_spawn"1
And now I have three questions:
  1. How I can check if weaponbox == M4A1 (or any another weapon)?
  2. How I can replace (change) model of weaponbox?
  3. How I can check if weaponbox with M4A1 (or USP) weapon have enabled silencer?
I try do first:
PHP Code:
public weaponbox_spawn(weaponBox)
{
    new 
iWeapon get_pdata_cbase(weaponBox354)
    
client_print(0print_chat"weaponbox: %i"iWeapon)    

I got "-1" value for all weaponbox'es .

I try do second:
PHP Code:
public weaponbox_spawn(weaponBox)
{
    
engfunc(EngFunc_SetModelweaponBox"models/w_ak47.mdl")

I guess this code should replace all weaponboxes models with AK47 model. But this does not work .

Thanks!

Last edited by Phant; 11-15-2013 at 10:25.
Phant is offline
Send a message via ICQ to Phant
Phant
Veteran Member
Join Date: Sep 2009
Location: New Jersey
Old 11-16-2013 , 04:17   Re: Weaponbox Data
Reply With Quote #2

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
 
#define PLUGIN "Test"
#define VERSION "0.0"
#define AUTHOR "KORD_12.7"
 
#define IsValidPev(%0) (pev_valid(%0) == 2)
 
#define m_rgpPlayerItems_CWeaponBox 34
 
public plugin_init()
{
        
register_plugin(PLUGINVERSIONAUTHOR)
       
        
RegisterHam(Ham_Spawn"weaponbox""Weaponbox_Spawn_Post"true);
        
register_forward(FM_SetModel"FakeMeta_SetModel"false);
       
        
state WeaponBox_Disabled;
}
 
public 
Weaponbox_Spawn_Post(const iWeaponBox)
{
        if (
IsValidPev(iWeaponBox))
        {
                
state (IsValidPev(pev(iWeaponBoxpev_owner))) WeaponBox_Enabled;
        }
       
        return 
HAM_IGNORED;
}
 
public 
FakeMeta_SetModel(const iEntity) <WeaponBox_Enabled>
{
        
state WeaponBox_Disabled;
       
        if (!
IsValidPev(iEntity))
        {
                return 
FMRES_IGNORED;
        }
       
        
#define MAX_ITEM_TYPES  6
       
        
for (new iiItemMAX_ITEM_TYPESi++)
        {
                
iItem get_pdata_cbase(iEntitym_rgpPlayerItems_CWeaponBox i4);
               
                if (
IsValidPev(iItem/* && needed weapon check */)
                {
                        
//engfunc(EngFunc_SetModel, iEntity, "MY_MODEL.mdl");
                        
return FMRES_SUPERCEDE;
                }
        }
       
        return 
FMRES_IGNORED;
}
 
public 
FakeMeta_SetModel(const iEntity) <WeaponBox_Disabled>
{
        return 
FMRES_IGNORED;

Code by (thanks to) KORD_12.7.
Phant is offline
Send a message via ICQ to Phant
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-16-2013 , 12:03   Re: Weaponbox Data
Reply With Quote #3

SetModel is sent twice on weaponbox
When weaponbox is spawned, you can't retrieve storage and model.

What you can do without hooking weaponbox spawn is :

On SetModel, check if entity class is "weaponbox", and check is model is not weaponbox.mdl, then you can work on that weaponx and its pdatas.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod 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 23:17.


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