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

[Tries] Messing up with me


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 06-06-2015 , 10:23   [Tries] Messing up with me
Reply With Quote #1

Am i drunk or the code is just fine?
Because this is not working properly..

PHP Code:
#include <amxmodx>
#include <amxmisc>

new Trie:g_tStaffTrie:g_tChatTags

public plugin_init()
{
    
g_tStaff TrieCreate()
    
g_tChatTags TrieCreate()
    
    
Staff_Preparation()
    
    
register_clcmd("test""cmdTest")
}
 
public 
cmdTest(id)
{
    new 
szID[35]
    
get_user_authid(idszIDcharsmax(szID))
    
    new 
iType = -1
    
    TrieGetCell
(g_tStaffszIDiType)
    
    
console_print(id"%s %d"szIDiType// Is printing the right Steam ID, yet iType is -1
}

Staff_Preparation()
{
    new 
szFile[70]
    
get_configsdir(szFilecharsmax(szFile))
    
format(szFilecharsmax(szFile), "%s/users.ini"szFile)
    
    new 
File fopen(szFile"rt")
        
    if(
File)
    {
        new 
Data[225], szID[35], szType[2], szChat[25]
        new 
iStaffType
        
        
while(!feof(File))
        {
            
fgets(FileDatacharsmax(Data))
            
trim(Data)
            
            if(!
Data[0] || Data[0] == ';')
                continue
                
            
remove_quotes(Data)
            
            
parse(DataszIDcharsmax(szID), szTypecharsmax(szType), szChatcharsmax(szChat))
            
            
iStaffType str_to_num(szType)
            
            
log_amx("[TEST] %s %d %s"szIDiStaffTypeszChat// This is printing just fine, being iType 4
            
TrieSetCell(g_tStaffszIDiStaffType)
            
TrieSetString(g_tChatTagsszIDszChat)
        }
        
        
fclose(File)
    }

__________________
Jhob94 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-06-2015 , 10:29   Re: [Tries] Messing up with me
Reply With Quote #2

If nothing is set, it means likely lookup has failed, something you can check with the return value of TrieGetCell.

If it fails, and that you are sure value is originally properly set, then it's either the original steam ID has a typo or maybe szID buffer length is too short.

Anyway, just a matter to debug, so add prints.
__________________
Arkshine is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-06-2015 , 10:51   Re: [Tries] Messing up with me
Reply With Quote #3

Working for me.
PHP Code:
//Users.ini entry
"STEAM_0:0:11111" "3" "abcdefghijklmnopqrstu" "ce" 

//After 'test' command
STEAM_0:0:11111 3 
__________________

Last edited by Bugsy; 06-06-2015 at 10:52.
Bugsy is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 06-06-2015 , 11:09   Re: [Tries] Messing up with me
Reply With Quote #4

Well, changed debug (at read file loop), this is what i get:
PHP Code:
log_amx("[TEST] %s"szID)

TrieSetCell(g_tStaffszIDiStaffType)
log_amx("[TEST] %d"iStaffType)

TrieSetString(g_tChatTagsszIDszChat)
log_amx("[TEST] %s"szChat
Logs:
Code:
L 06/06/2015 - 17:02:15: [staff.amxx] [TEST] STEAM_0:1:78004107 
L 06/06/2015 - 17:02:15: [staff.amxx] [TEST] 4
L 06/06/2015 - 17:02:15: [staff.amxx] [TEST] ADMIN
From console command:
Code:
test 
STEAM_0:1:78004107 -1
Edit
users.ini:
Code:
"STEAM_0:1:78004107" "4" "ADMIN"
Well, should i used something else than tries?

And by the way, i tried TrieKeyExists instead of TrieGetCell and not working either..
__________________

Last edited by Jhob94; 06-06-2015 at 11:23.
Jhob94 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-06-2015 , 11:58   Re: [Tries] Messing up with me
Reply With Quote #5

Your code is right as it is working fine for me. Is your amxmodx build old?

Tested again and working exactly as it should
Code:
Bugsy is joining the Terrorist force
test
STEAM_0:0:11111 3
__________________

Last edited by Bugsy; 06-06-2015 at 11:59.
Bugsy is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 06-06-2015 , 12:53   Re: [Tries] Messing up with me
Reply With Quote #6

Iam using 1.8.2 i guess. I installed 1.8.3 somewhere but i dont think it was this server. I will install back my vip system and check if it is working since it used to work and the only diference from this staff thing is that i get steamid via sql
__________________
Jhob94 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-06-2015 , 13:18   Re: [Tries] Messing up with me
Reply With Quote #7

Quote:
Originally Posted by Jhob94 View Post
Iam using 1.8.2 i guess.
What? You don't know? Are you using 1.8.2 or not?
__________________
fysiks is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 06-06-2015 , 13:37   Re: [Tries] Messing up with me
Reply With Quote #8

Quote:
Originally Posted by fysiks View Post
What? You don't know? Are you using 1.8.2 or not?
I am not sure, i have several test servers

Anyway, Uchiha Arkshine just activated his new eye. Congratz
__________________
Jhob94 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-06-2015 , 13:42   Re: [Tries] Messing up with me
Reply With Quote #9

Quote:
Originally Posted by Jhob94 View Post
I am not sure, i have several test servers
Wow, that's a lame excuse. There exists a command called "amxx version".
__________________
fysiks is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-06-2015 , 13:56   Re: [Tries] Messing up with me
Reply With Quote #10

Even if the trie library is completely different in 1.8.3, it should still work fine in 1.8.2.

You did not output return value of natives, it could help to narrow down the issue. But I feel like you should triple check what you're testing.
__________________

Last edited by Arkshine; 06-06-2015 at 14:06.
Arkshine 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 16:31.


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