Działa na tej samej zasadzie co fm_give_item (Fakemeta) oraz give_item
(Fun)
GiveNamedItem( id, const pszName[ ] ) { new iEnt = create_entity( pszName ); if( !iEnt ) { log_amx( "NULL Ent in GiveNamedItem!" ); return; } new Float:fVecOrigin[ 3 ]; entity_get_vector( id, EV_VEC_origin, fVecOrigin ); entity_set_vector( iEnt, EV_VEC_origin, fVecOrigin ); entity_set_int( iEnt, EV_INT_spawnflags, entity_get_int( iEnt, EV_INT_spawnflags ) | SF_NORESPAWN ); DispatchSpawn( iEnt ); fake_touch( iEnt, id ); }
Przykład:
#include <amxmodx> #include <engine> #include <hamsandwich> public plugin_init() { RegisterHam( Ham_Spawn, "player", "Ham_Spawn_Post", 1 ); } public Ham_Spawn_Post( id ) { if ( !is_user_alive( id ) ) return HAM_IGNORED; if( get_user_flags( id ) & ADMIN_LEVEL_H ) GiveNamedItem( id, "weapon_awp" ); else GiveNamedItem( id, "weapon_scout" ); return HAM_IGNORED; } GiveNamedItem( id, const pszName[ ] ) { new iEnt = create_entity( pszName ); if( !iEnt ) { log_amx( "NULL Ent in GiveNamedItem!" ); return; } new Float:fVecOrigin[ 3 ]; entity_get_vector( id, EV_VEC_origin, fVecOrigin ); entity_set_vector( iEnt, EV_VEC_origin, fVecOrigin ); entity_set_int( iEnt, EV_INT_spawnflags, entity_get_int( iEnt, EV_INT_spawnflags ) | SF_NORESPAWN ); DispatchSpawn( iEnt ); fake_touch( iEnt, id ); }