View Single Post
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 01-07-2018 , 15:40   Re: FM Touch Entity
Reply With Quote #10

Quote:
Originally Posted by HamletEagle View Post
Have an array with all the ARM_* strings(new const something[][]). Then in plugin_init use TrieSetCell with something[i] as key and the value of ARM_* constant as value.
Then when you read from file you need TrieGetCell.
I get the first part but when I read the file, if I use TrieSetArray it requires a key to save the data, what key to put?

PHP 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
}

new const 
g_szValues[ ][ ] =
{
    
"ARM_MP5",
    
"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"
}

new 
Trie:g_tWeaponTrie;

public 
plugin_init( )
{
    
g_tWeaponTrie TrieCreate( );

    for( new 
isizeof g_szValuesi++ )
    {
        for( new 
iValue=ARM_MP5iValue <= ARM_SMOKEGRENADEiValue++ )
        {
            
TrieSetCellg_tWeaponTrieg_szValues], iValue );
        }
    }

Quote:
Originally Posted by HamletEagle View Post
Alternatively, you could do that without weaponbox/armoury_entity at all. Create some dummy entity(info_target) and set the weapon index that your entity will contain in a pev value like pev_iuser1. Hook touch, retrieve the CSW_* index from pev_iuser1, get it's name with get_weaponname and use give item, then remove the dummy entity.
That way you can put any weapon in there and you don't need to deal with complicated weaponbox code.
Wouldn't that cause any glitches? As you're setting different values to pev_iuser1. Wouldn't it be better creating a variable that will hold the values instead of pev_iuser1 and then looping through all entities?
__________________

Last edited by edon1337; 01-07-2018 at 15:41.
edon1337 is offline