Hi,
I'm trying to create a custom made entity, such as in fy_ maps, no, I'm not going with armoury_entity.
I decided to use Orpheu and learn in the meantime, but after all I'm still a beginner with it.
Why does this code give me an AK47? I'm trying to make it spawn an AK47 in my origin not give me it.. What am I missing?
PHP Code:
#include < amxmodx >
#include < fakemeta >
#include < engine >
#include < cstrike >
#include < hamsandwich >
#include < orpheu >
#define XO_CWEAPONBOX 4
const m_iId = 43;
new const WeaponBoxModels[ ][ ] =
{
"", "models/w_p228.mdl", "",
"models/w_scout.mdl", "", "models/w_xm1014.mdl",
"models/w_c4.mdl", "models/w_mac10.mdl", "models/w_aug.mdl", "",
"models/w_elite.mdl", "models/w_fiveseven.mdl", "models/w_ump45.mdl",
"models/w_sg550.mdl", "models/w_galil.mdl", "models/w_famas.mdl",
"models/w_usp.mdl", "models/w_glock18.mdl", "models/w_awp.mdl",
"models/w_mp5.mdl", "models/w_m249.mdl", "models/w_m3.mdl",
"models/w_m4a1.mdl", "models/w_tmp.mdl", "models/w_g3sg1.mdl",
"", "models/w_deagle.mdl", "models/w_sg552.mdl", "models/w_ak47.mdl",
"", "models/w_p90.mdl", "", ""
}
public plugin_init( )
{
register_clcmd( "say /create", "OnCreate" );
}
public OnCreate( id )
{
new Float:fOrigin[ 3 ];
pev( id, pev_origin, fOrigin );
new iClassString = engfunc( EngFunc_AllocString, "weaponbox" );
new iWeaponEntity = create_entity( "weapon_ak47" );
new OrpheuFunction:HandleCreateNamedEntityFunc = OrpheuGetFunction( "CREATE_NAMED_ENTITY" );
new iEntity = OrpheuCall( HandleCreateNamedEntityFunc, iClassString );
new OrpheuFunction:HandlePackWeaponFunc;
HandlePackWeaponFunc = OrpheuGetFunction( "PackWeapon", "CWeaponBox" );
OrpheuCall( HandlePackWeaponFunc, iEntity, iWeaponEntity );
set_pdata_int( iWeaponEntity, m_iId, cs_get_weapon_id( iWeaponEntity ), XO_CWEAPONBOX );
new iWeaponId = cs_get_weapon_id( iWeaponEntity );
if( WeaponBoxModels[ iWeaponId ][ 0 ] != EOS )
{
engfunc( EngFunc_SetModel, iWeaponEntity, WeaponBoxModels[ iWeaponId ] );
ExecuteHam( Ham_Spawn, iWeaponEntity );
set_pev( iWeaponEntity, pev_origin, fOrigin );
}
}
Thanks!
__________________