Raised This Month: $51 Target: $400
 12% 

Solved weaponbox/armoury_entity Touch


Post New Thread Reply   
 
Thread Tools Display Modes
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 01-07-2018 , 16:48   Re: FM Touch Entity
Reply With Quote #11

Quote:
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?
pev_iuser1 is unused, so it won't cause any glitches. When working with entities, that's the easiest and one of the best ways to store data.
Using a variable will not work, because you don't know the range of the indexes.You can do it for players since it's always from 1 to let's say 32, so you can just use 33 as dimension. But how big you make the array for your dummy entities?
__________________

Last edited by HamletEagle; 01-07-2018 at 16:48.
HamletEagle is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 01-07-2018 , 17:03   Re: FM Touch Entity
Reply With Quote #12

Quote:
Originally Posted by HamletEagle View Post
pev_iuser1 is unused, so it won't cause any glitches. When working with entities, that's the easiest and one of the best ways to store data.
Using a variable will not work, because you don't know the range of the indexes.You can do it for players since it's always from 1 to let's say 32, so you can just use 33 as dimension. But how big you make the array for your dummy entities?
Isn't 2048 the max edict number?
__________________
edon1337 is offline
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 01-07-2018 , 18:25   Re: FM Touch Entity
Reply With Quote #13

Quote:
Originally Posted by edon1337 View Post
Isn't 2048 the max edict number?
1365 for maxplayers = 32.
__________________
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 01-08-2018 , 02:40   Re: weaponbox/armoury_entity Touch
Reply With Quote #14

It's a bad way.
__________________
HamletEagle is offline
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 01-08-2018 , 09:16   Re: weaponbox/armoury_entity Touch
Reply With Quote #15

https://forums.alliedmods.net/showthread.php?t=294188
__________________
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 01-08-2018 , 10:16   Re: weaponbox/armoury_entity Touch
Reply With Quote #16

Quote:
Originally Posted by PRoSToTeM@ View Post
Don't really wanna include any module to this plugin.

@HamletEagle

If I'm using Tries, as you and Prostotem@ suggested, what key would I have to set when I'd read the file?

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 } enum _:WeaponData {     Weapon_ArmName,     Float:Weapon_Origin[ 3 ] } 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; new g_iWeapons[ WeaponData ]; public plugin_init( ) {     g_tWeaponTrie = TrieCreate( );     for( new i; i < sizeof g_szValues; i++ )     {         for( new iValue=ARM_MP5; iValue <= ARM_SMOKEGRENADE; iValue++ )         {             TrieSetCell( g_tWeaponTrie, g_szValues[ i ], iValue );         }     }         ReadFile( ); } ReadFile( ) {     new szConfigs[ 32 ], szFormat[ 64 ], szWeaponData[ 256 ], szWeaponArmName[ 32 ], szWeaponOrigin[ 40 ], szOrigin1[ 12 ], szOrigin2[ 12 ], szOrigin3[ 12 ];     get_configsdir( szConfigs, charsmax( szConfigs ) ) ;         formatex( szFormat, charsmax( szFormat ), "%s/SavedCoordinates.txt", szConfigs ) ;         new iFile = fopen( szFormat, "r" ) ;         if( iFile ) {                 while( ! feof( iFile ) ) {                         fgets( iFile, szWeaponData, charsmax( szWeaponData ) ) ;             trim( szWeaponData ) ;                         parse( szWeaponData, szWeaponArmName, charsmax( szWeaponArmName ), szWeaponOrigin, charsmax( szWeaponOrigin ) );                        parse( szWeaponOrigin, szOrigin1, charsmax( szOrigin1 ), szOrigin2, charsmax( szOrigin2 ), szOrigin3, charsmax( szOrigin3 ) );                         g_iWeapons[ Weapon_ArmName ]= str_to_num( szWeaponArmName );             g_iWeapons[ Weapon_Origin ][ 0 ] = _:str_to_float( szOrigin1 );             g_iWeapons[ Weapon_Origin ][ 1 ] = _:str_to_float( szOrigin2 );             g_iWeapons[ Weapon_Origin ][ 2 ] = _:str_to_float( szOrigin3 );            
            ArrayPushArray( g_aWeaponData, g_iWeapons ); // TrieSetArray?
        }         fclose( iFile ) ;     } }
__________________

Last edited by edon1337; 01-08-2018 at 10:17.
edon1337 is offline
E1_531G
Senior Member
Join Date: Dec 2017
Old 01-08-2018 , 11:50   Re: weaponbox/armoury_entity Touch
Reply With Quote #17

Key = ARM_* string.
Value = cellarray entry index.
__________________
My English is A0
E1_531G is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 01-08-2018 , 14:45   Re: weaponbox/armoury_entity Touch
Reply With Quote #18

Quote:
Don't really wanna include any module to this plugin.
Use an unused pev field like pev_iuser1 for the love of God.
__________________

Last edited by HamletEagle; 01-08-2018 at 14:45.
HamletEagle is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 01-09-2018 , 09:51   Re: weaponbox/armoury_entity Touch
Reply With Quote #19

Quote:
Originally Posted by E1_531G View Post
Key = ARM_* string.
Value = cellarray entry index.
Thanks!

I don't know why the output of iArmValue is always 18..
Code:
L 01/09/2018 - 15:47:10: szWeaponArmName: ARM_MP5 | iArmValue: 18 L 01/09/2018 - 15:47:10: szWeaponArmName: ARM_AK47 | iArmValue: 18 L 01/09/2018 - 15:47:10: szWeaponArmName: ARM_M4A1 | iArmValue: 18 L 01/09/2018 - 15:47:10: szWeaponArmName: ARM_P90 | iArmValue: 18 L 01/09/2018 - 15:47:10: szWeaponArmName: ARM_M3 | iArmValue: 18 L 01/09/2018 - 15:47:10: szWeaponArmName: ARM_XM1014 | iArmValue: 18 L 01/09/2018 - 15:47:10: szWeaponArmName: ARM_M249 | iArmValue: 18 L 01/09/2018 - 15:47:10: szWeaponArmName: ARM_MP5 | iArmValue: 18 L 01/09/2018 - 15:47:10: szWeaponArmName: ARM_MP5 | iArmValue: 18
Code:
enum _:WeaponData {     Weapon_ArmName,     Float:Weapon_Origin[ 3 ] } 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 g_iWeapons[ WeaponData ]; new Array:g_aWeaponData; new Trie:g_tWeaponTrie; public plugin_init( ) {     g_aWeaponData = ArrayCreate( WeaponData );     g_tWeaponTrie = TrieCreate( );         for( new i; i < sizeof g_szValues; i++ )     {         for( new iValue=ARM_MP5; iValue <= ARM_SMOKEGRENADE; iValue++ )         {             TrieSetCell( g_tWeaponTrie, g_szValues[ i ], iValue );         }     }         ReadFile( ); } public ReadFile( ) {     new szConfigs[ 32 ], szFormat[ 64 ], szWeaponData[ 256 ], szWeaponArmName[ 32 ], szWeaponOrigin[ 40 ], szOrigin1[ 12 ], szOrigin2[ 12 ], szOrigin3[ 12 ];     get_configsdir( szConfigs, charsmax( szConfigs ) ) ;         formatex( szFormat, charsmax( szFormat ), "%s/SavedCoordinates.txt", szConfigs ) ;         new iFile = fopen( szFormat, "r" ) ;         if( iFile ) {                 while( ! feof( iFile ) ) {                         fgets( iFile, szWeaponData, charsmax( szWeaponData ) ) ;             trim( szWeaponData ) ;                         parse( szWeaponData, szWeaponArmName, charsmax( szWeaponArmName ), szWeaponOrigin, charsmax( szWeaponOrigin ) );                        parse( szWeaponOrigin, szOrigin1, charsmax( szOrigin1 ), szOrigin2, charsmax( szOrigin2 ), szOrigin3, charsmax( szOrigin3 ) )                         new iArmValue;             if( TrieGetCell( g_tWeaponTrie, szWeaponArmName, iArmValue ) )             {
                log_to_file( "Test2.txt", "szWeaponArmName: %s | iArmValue: %d", szWeaponArmName, iArmValue );
                                g_iWeapons[ Weapon_ArmName ] = iArmValue;                 g_iWeapons[ Weapon_Origin ][ 0 ] = _:str_to_float( szOrigin1 );                 g_iWeapons[ Weapon_Origin ][ 1 ] = _:str_to_float( szOrigin2 );                 g_iWeapons[ Weapon_Origin ][ 2 ] = _:str_to_float( szOrigin3 );                                 ArrayPushArray( g_aWeaponData, g_iWeapons );             }         }         fclose( iFile ) ;     } }
__________________

Last edited by edon1337; 01-09-2018 at 09:51.
edon1337 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 01-09-2018 , 10:22   Re: weaponbox/armoury_entity Touch
Reply With Quote #20

Code:
I: g_szValues = "ARM_MP5"
	iValue = ARM_MP5
	.
	.
	.
	iValue = ARM_SMOKEGRENADE // 18
	
II: g_szValues = "ARM_TMP"
	iValue = ARM_MP5
	.
	.
	.
	iValue = ARM_SMOKEGRENADE // 18
You are setting for the same key all possible indexes, one after another. That's why you get only the last one. Get rid of the second for.

And do something like this:
PHP Code:
new const Values[][] =
{
    
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
}

TrieSetCellg_tWeaponTrieg_szValues], Values[i]); 
__________________

Last edited by HamletEagle; 01-09-2018 at 10:22.
HamletEagle is offline
Reply



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 22:55.


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