AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Weaponbox Data (https://forums.alliedmods.net/showthread.php?t=229817)

Phant 11-15-2013 10:23

Weaponbox Data
 
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!

Phant 11-16-2013 04:17

Re: Weaponbox Data
 
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.

ConnorMcLeod 11-16-2013 12:03

Re: Weaponbox Data
 
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.


All times are GMT -4. The time now is 23:17.

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