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

Setting a key more than 1 value (Tries)?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
lucas_7_94
Leche Loco
Join Date: Mar 2009
Location: Argentina
Old 02-07-2012 , 22:37   Setting a key more than 1 value (Tries)?
Reply With Quote #1

Example that i try to do.

Code:
enum _:Type {     Name[ 64 ],     Class[ 64 ],     Access[ 64 ] } new const szAdminInfo[ ][ Type ] = {     { "Luqqas", "Developer", "Full" }     // more more more } new Trie:AdminInfo

The key is Luqqas, but , how i can set more than 1 value in the key ?

Thanks For all!
__________________
ATWWMH - MiniDuels
Madness is like gravity, just need a little push.
lucas_7_94 is offline
Send a message via Skype™ to lucas_7_94
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-07-2012 , 23:06   Re: Setting a key more than 1 value (Tries)?
Reply With Quote #2

You have to put all info into one string. Then you have to parse it everytime you need the info.
__________________
fysiks is offline
lucas_7_94
Leche Loco
Join Date: Mar 2009
Location: Argentina
Old 02-07-2012 , 23:24   Re: Setting a key more than 1 value (Tries)?
Reply With Quote #3

Can you make a little example please ? thanks for answer.
__________________
ATWWMH - MiniDuels
Madness is like gravity, just need a little push.
lucas_7_94 is offline
Send a message via Skype™ to lucas_7_94
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 02-08-2012 , 00:06   Re: Setting a key more than 1 value (Tries)?
Reply With Quote #4

Code:
enum _:Type {     Name[ 64 ],     Class[ 64 ],     Access[ 64 ] } new const szAdminInfo[ ][ Type ] = {     { "Luqqas", "Developer", "Full" }     // more more more } new Trie:AdminInfo public plugin_init( ) {     AdminInfo = TrieCreate( )         for( new i = 0; i < sizeof( szAdminInfo ); i++ )     {         TrieSetCell( AdminInfo, szAdminInfo[ i ][ Name ], i );     } } // ... new adminIndex if( TrieGetCell( AdminInfo, "Luqqas", adminIndex ) ) {     log_amx( "Other stuff: %s - %s", szAdminInfo[ adminIndex ][ Class ], szAdminInfo[ adminIndex ][ Access ] ); }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!

Last edited by Exolent[jNr]; 02-08-2012 at 00:07.
Exolent[jNr] is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 02-08-2012 , 01:27   Re: Setting a key more than 1 value (Tries)?
Reply With Quote #5

Basically you should use Trie{S/G}etArray, but if you keep a hardcoded array as it is you can stay with the way exolent did.

With array thing (allow dynamic settings with a .cfg or .ini file, else you need to recompile each time you change something) :

PHP Code:
#include <amxmodx>

enum _:Type
{
    Class[ 
64 ],
    
Access64 ]
}

new const 
szAdminInfo[ ][ ] =
{
    { 
"Luqqas""Developer""Full" }
    
// more more more 
}

new 
Trie:AdminInfo

public plugin_init()
{
    
AdminInfo TrieCreate()
    new 
Infos[Type]
    for(new 
ii<sizeof(szAdminInfo); i++)
    {
        
copy(Infos[Class], charsmax(Infos[Class]), szAdminInfo[i][1])
        
copy(Infos[Access], charsmax(Infos[Access]), szAdminInfo[i][2])
        
TrieSetArray(AdminInfoszAdminInfo[i][0], Infossizeof(Infos))
    }
}

public 
client_infochangedid )
{
    new 
name[32]
    
get_user_info(id"name"namecharsmax(name))
    new 
PlayersInfo[Type]
    if( 
TrieGetArray(AdminInfonamePlayersInfosizeof(PlayersInfo)) )
    {
        
// player has entry
    
}

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 02-08-2012 at 01:27.
ConnorMcLeod is offline
Old 02-08-2012, 04:07
lucas_7_94
This message has been deleted by lucas_7_94.
lucas_7_94
Leche Loco
Join Date: Mar 2009
Location: Argentina
Old 02-08-2012 , 04:32   Re: Setting a key more than 1 value (Tries)?
Reply With Quote #6

Well , if i have more info in Type , i can make a loop to set in Info the info ? if you can show example will be really great.
__________________
ATWWMH - MiniDuels
Madness is like gravity, just need a little push.

Last edited by lucas_7_94; 02-08-2012 at 05:31.
lucas_7_94 is offline
Send a message via Skype™ to lucas_7_94
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 02-08-2012 , 07:47   Re: Setting a key more than 1 value (Tries)?
Reply With Quote #7

Quote:
Originally Posted by ConnorMcLeod View Post
Basically you should use Trie{S/G}etArray
Which is broken in 1.8.1.
__________________
hleV is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 02-08-2012 , 08:54   Re: Setting a key more than 1 value (Tries)?
Reply With Quote #8

Feel free to upgrade to 1.8.2-dev. It contains this fix among others.
__________________
Arkshine is offline
lucas_7_94
Leche Loco
Join Date: Mar 2009
Location: Argentina
Old 02-08-2012 , 12:46   Re: Setting a key more than 1 value (Tries)?
Reply With Quote #9

I will to make the question again , because i'm not sure if we can understand me.

Now , if in the case that i have more information in the enum Type , example.

Code:
enum _:Type {     Name[ 64 ],     Class[ 64 ],     Access[ 64 ],     Number1,     Float:Number2,     Number3 }

Its possible to reduce code to prevent make this ? (i think , loop ?)

Code:
copy(Infos[Class], charsmax(Infos[Class]), szAdminInfo[i][1]) copy(Infos[Access], charsmax(Infos[Access]), szAdminInfo[i][2]) copy(Infos[Number1], charsmax(Infos[Number1]), szAdminInfo[i][3]) copy(Infos[Number2], charsmax(Infos[Number2]), szAdminInfo[i][4]) copy(Infos[Number3], charsmax(Infos[Number3]), szAdminInfo[i][5]) TrieSetArray(AdminInfo, szAdminInfo[i][0], Infos, sizeof(Infos))

?
__________________
ATWWMH - MiniDuels
Madness is like gravity, just need a little push.
lucas_7_94 is offline
Send a message via Skype™ to lucas_7_94
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 02-08-2012 , 12:57   Re: Setting a key more than 1 value (Tries)?
Reply With Quote #10

Quote:
Originally Posted by Arkshine View Post
Feel free to upgrade to 1.8.2-dev. It contains this fix among others.
I specifically mentioned that it's broken in 1.8.1, implying my awareness of that not being the case for any newer versions.
__________________

Last edited by hleV; 02-08-2012 at 12:57.
hleV 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 11:57.


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