Raised This Month: $ Target: $400
 0% 

[FAQ]armoury_entity


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 11-02-2014 , 05:20   [FAQ]armoury_entity
Reply With Quote #1


I've seen a number of questions related to this topic, so I thought that such a FAQ is welcome.

What is an armoury_entity ? armoury_entity is the weapons that is spawned on the ground (like in fy_snow). This does not include the dropped weapons which are weaponboxes. If you pickup an armoury_entity and drop, it will be no longer an armoury_entity, but an weaponbox ent. An armoury_entity can hold more than one weapon.

Before you begin you need to know the armoury_entity indexs, this is what you will use.

Code:
enum
{
	ARM_MP5, //0
	ARM_TMP,
	ARM_P90,
	ARM_MAC10,
	ARM_AK47,
	ARM_SG552,
	ARM_M4A1,
	ARM_AUG,
	ARM_SCOUT,
	ARM_G3SG1,
	ARM_AWP,
	ARM_M3,
	ARM_XM1014,
	ARM_M249,
	ARM_FLASHBANG,
	ARM_HEGRENADE,
	ARM_KEVLAR,
	ARM_ASSAULT,
	ARM_SMOKEGRENADE //18
}
You can name them whatever you want, but I choosed ARM_WPNNAME. The first one is 0 and the last one is 18.

The models for armoury_entity:
Code:
"models/w_mp5.mdl",       
"models/w_tmp.mdl",        
"models/w_p90.mdl",    
"models/w_mac10.mdl",       
"models/w_ak47.mdl",       
"models/w_sg552.mdl",       
"models/w_m4a1.mdl",       
"models/w_aug.mdl",        
"models/w_scout.mdl",      
"models/w_g3sg1.mdl",      
"models/w_awp.mdl",         
"models/w_m3.mdl",          
"models/w_xm1014.mdl",    
"models/w_m249.mdl",        
"models/w_flashbang.mdl",   
"models/w_hegrenade.mdl",  
"models/w_kevlar.mdl",
"models/w_assault.mdl",     
"models/w_smokegrenade.mdl"
Note that you can't have armoury_entity with c4, knife, pistols, famas and galil.

Some offset that we will use:
Code:
const XO_CArmoury = 4 //diff windows/linux const m_iType = 34 // armoury_entity index( see above enum ) const m_iCount = 35// hold the number of weapons that the armoury_entity will have

Ok, let's begin:

1.Hook touch with an armoury_entity:
Code:
#include <hamsandwich> #include <cstrike> //Hook as pre RegisterHam(Ham_Touch, "armoury_entity", "CBaseEntity_Touch", false) public CBaseEntity_Touch( iTouched, iToucher ) {         //iTouched is the armoury_entity that is touched         //iToucher is the entity index that touch the armoury_entity. It is not 100% a player, you need to check it's classname or use engine's register_touch with allow you to specify the toucher class too.     new armouryIndex = cs_get_armoury_type(iTouched)         //If you need to block return HAM_SUPERCEDE         //If you need to block just for one weapon check if armouryIndex is what you want and supercede        //cs_get_armoury_type return CSW_ indexs and not the one from the above list. }

2.Create an armoury entity:
Code:
enum {     ARM_MP5, //0     ARM_TMP,     ARM_P90,     ARM_MAC10,     ARM_AK47,     ARM_SG552,     ARM_M4A1,     ARM_AUG,     ARM_SCOUT,     ARM_G3SG1,     ARM_AWP,     ARM_M3,     ARM_XM1014,     ARM_M249,     ARM_FLASHBANG,     ARM_HEGRENADE,     ARM_KEVLAR,     ARM_ASSAULT,     ARM_SMOKEGRENADE //18 } stock CreateArmouryEntity( itemType, itemCount, Float: fOrigin[ ] ) {     new armouryEnt = create_entity("armoury_entity")     if(!armouryEnt)     {         return -1     }         if(itemType < ARM_MP5 || itemType > ARM_SMOKEGRENADE)     {         return -1     }         set_pev(armouryEnt, pev_origin, fOrigin)     set_pdata_int(armouryEnt, m_iType, itemType, XO_CArmoury)     set_pdata_int(armouryEnt, m_iCount, itemCount, XO_CArmoury)     dllfunc(DLLFunc_Spawn, armouryEnt)     return armouryEnt }
itemType is the index from the above enum( ARM_ )
itemCount is the number of the weapons that the armoury entity will hold.
fOrigin is the origin where the armoury_entity will be spawned.
The stock above will return -1 on failure/ the armoury index otherwise.

3.Remove all armoury_entity from the map:
Code:
new armouryEnt = -1 while((armouryEnt = find_ent_by_class(armouryEnt, "armoury_entity")) {     remove_entity(armouryEnt) }

I'm waiting for suggestion and comments.

Please check this post: https://forums.alliedmods.net/showpo...8&postcount=10 in order to find out how armoury entities are hidden when they contain 0 weapons and how they are restored.
__________________

Last edited by HamletEagle; 07-26-2015 at 03:25.
HamletEagle is offline
 



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 16:53.


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