AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   CSW_SHIELD id (https://forums.alliedmods.net/showthread.php?t=194757)

OvidiuS 08-30-2012 21:27

CSW_SHIELD id
 
What is weapon id of shield?

Code:
#define CSW_SHIELD      2
or
Code:
#define CSW_SHIELD      35

ConnorMcLeod 08-31-2012 00:45

Re: CSW_SHIELD id
 
Both are custom things coders are using.
Shield is not a weapon and has no weapon index in game code.
What do you need ?

OvidiuS 08-31-2012 08:02

Re: CSW_SHIELD id
 
Quote:

Originally Posted by ConnorMcLeod (Post 1787541)
Both are custom things coders are using.
Shield is not a weapon and has no weapon index in game code.
What do you need ?

After a little thinking, it doesn't even matter what is the id.
You are right.
Anyway i need to block weapon pickup for specific class.
Part of code:
Code:
new const global_ClassWeapons[ CLASSES ] = {     (1<<CSW_AWP)|(1<<CSW_DEAGLE),     (1<<CSW_DEAGLE),     (1<<CSW_AK47)|(1<<CSW_M4A1),     (1<<CSW_M249),     (1<<CSW_UMP45)|(1<<CSW_TMP),     (1<<CSW_MP5NAVY)|(1<<CSW_ELITE),     (1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN),     (1<<CSW_SG552)|(1<<CSW_ELITE),     (1<<CSW_M3)|(1<<CSW_UMP45),     (1<<CSW_DEAGLE),     (1<<CSW_P90)|(1<<CSW_DEAGLE),     (1<<CSW_SG552)|(1<<CSW_TMP),     (1<<CSW_AUG),     (1<<CSW_G3SG1)|(1<<CSW_DEAGLE),     (1<<CSW_P90),     (1<<CSW_MAC10),     (1<<CSW_GALIL)|(1<<CSW_FAMAS),     (1<<CSW_M4A1)|(1<<CSW_FIVESEVEN),     (1<<CSW_AK47)|(1<<CSW_ELITE),     (1<<CSW_GALIL)|(1<<CSW_MP5NAVY),     (1<<CSW_UMP45)|(1<<CSW_DEAGLE),     (1<<CSW_M4A1),     (1<<CSW_M4A1),     (1<<CSW_XM1014)|(1<<CSW_FAMAS),     (1<<CSW_AK47)|(1<<CSW_ELITE),     (1<<CSW_SHIELD)|(1<<CSW_DEAGLE),     (1<<CSW_TMP)|(1<<CSW_DEAGLE),     (1<<CSW_AK47)|(1<<CSW_XM1014) } public plugin_init( ) {     RegisterHam( Ham_Touch, "armoury_entity", "ham_Touch_weapon" );     RegisterHam( Ham_Touch, "weapon_shield", "ham_Touch_weapon" );     RegisterHam( Ham_Touch, "weaponbox", "ham_Touch_weapon" );         new const sWorldModels[ ][ ] =     {         "models/w_p228.mdl", "models/w_scout.mdl", "models/w_xm1014.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", "models/w_shield.mdl"     }     new const iWeaponIds[ ] =     {         CSW_P228, CSW_SCOUT, CSW_XM1014, CSW_MAC10, CSW_AUG, CSW_ELITE, CSW_FIVESEVEN, CSW_UMP45         CSW_SG550, CSW_GALIL, CSW_FAMAS, CSW_USP, CSW_GLOCK18, CSW_AWP, CSW_MP5NAVY, CSW_M249, CSW_M3, CSW_M4A1,         CSW_TMP, CSW_G3SG1, CSW_DEAGLE, CSW_SG552, CSW_AK47, CSW_P90, CSW_SHIELD     }         for( new i = 0; i < sizeof iWeaponIds; i++ )         TrieSetCell( global_tWeapons, sWorldModels[ i ], iWeaponIds[ i ] ) } public ham_Touch_weapon( iWeapon, id ) {     if( !g_boolConnected[ id ] )         return HAM_IGNORED;     new sModel[ 32 ];     pev( iWeapon, pev_model, sModel, charsmax( sModel ) );     if( TrieKeyExists( global_tWeapons, sModel ) )     {         new iValue;         if( TrieGetCell( global_tWeapons, sModel, iValue ) )         {             if( !( 1 & ( global_ClassWeapons[ global_iClass[ id ] ] >> iValue ) ) )                 return HAM_SUPERCEDE;         }     }     return HAM_IGNORED; }

ConnorMcLeod 08-31-2012 13:06

Re: CSW_SHIELD id
 
Problem with using the same callback for the 3 hooks is that you can't figure what you are touching.
This method is fine if you don't need to filter what you are touching.
Use 3 different callbacks gonna make your life easier, also will allow you to remove model check that is a poor method.

OvidiuS 08-31-2012 15:51

Re: CSW_SHIELD id
 
Quote:

Originally Posted by ConnorMcLeod (Post 1787933)
Problem with using the same callback for the 3 hooks is that you can't figure what you are touching.
This method is fine if you don't need to filter what you are touching.
Use 3 different callbacks gonna make your life easier, also will allow you to remove model check that is a poor method.

Misread, i get it now https://forums.alliedmods.net/images...ayFoxEmote.png

EDIT: hm, i dont see the advantage of this. Can you explain it :S


All times are GMT -4. The time now is 05:52.

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