Giving a model a weapon
Posted: Fri Aug 14, 2026 9:24 pm
Code: Select all
// Create the weapon entity
new iEntWeapon = create_entity( "info_target" );
// Set the entity's class
entity_set_string( iEntWeapon, EV_SZ_classname, "weaponbox" );
// Set it to follow (so it will follow its owner)
entity_set_int( iEntWeapon, EV_INT_movetype, MOVETYPE_FOLLOW );
// Make the weapon solid
entity_set_int( iEntWeapon, EV_INT_solid, SOLID_NOT );
// Set the owner of the weapon to be the entity you want to have the weapon
entity_set_edict( iEntWeapon, EV_ENT_aiment, iEntOwner );
// Assign the weapon entity a model
entity_set_model( iEntWeapon, "models/p_m4a1.mdl" );Code: Select all
new szWeaponModels[31][32] =
{
"models/p_knife.mdl", // 0
"models/p_deagle.mdl", // 1
"models/p_glock18.mdl", // 2
"models/p_p228.mdl", // 3
"models/p_usp.mdl", // 4
"models/p_flashbang.mdl", // 5
"models/p_hegrenade.mdl", // 6
"models/p_smokegrenade.mdl", // 7
"models/p_xm1014.mdl", // 8 CT T
"models/p_m3.mdl", // 9 CT T
"models/p_m3super90.mdl", // 10 CT T
"models/p_awp.mdl", // 11 CT T
"models/p_m249.mdl", // 12 CT T
"models/p_scout.mdl", // 13 CT T
"models/p_ump45.mdl", // 14 CT T
"models/p_mp5.mdl", // 15 CT T
"models/p_p90.mdl", // 16 CT T
"models/p_c4.mdl", // 17
"models/p_elite.mdl", // 18
"models/p_galil.mdl", // 19 T
"models/p_ak47.mdl", // 20 T
"models/p_sg552.mdl", // 21 T
"models/p_g3sg1.mdl", // 22 T
"models/p_mac10.mdl", // 23 T
"models/p_shield.mdl", // 24
"models/p_fiveseven.mdl", // 25
"models/p_famas.mdl", // 26 CT
"models/p_aug.mdl", // 27 CT
"models/p_m4a1.mdl", // 28 CT
"models/p_sg550.mdl", // 29 CT
"models/p_tmp.mdl" // 30 CT
};