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

Adt_Trie errors


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ecca
Sexy Santa
Join Date: Jan 2011
Old 01-20-2012 , 15:11   Adt_Trie errors
Reply With Quote #1

Hi, trying to make a simple thing that stores a players steamid and then kick him if it find him in the gettrievalue

PHP Code:
#include <adt_trie>

new Handle:g_hDenyArray INVALID_HANDLE;
new 
String:tKey[] = "players"

public OnMapStart()
{
    
g_hDenyArray CreateTrie();
}

public 
OnClientPostAdminCheck(client)
{    
    new 
String:steamid[30];
    
GetClientAuthString(clientsteamidsizeof(steamid));
    
    if (
GetTrieValue(g_hDenyArraysteamidtKey))
    {
       
//ACTION
    
}
}

public 
OnClientDisconnect(client)
{
    new 
String:steamid[30];
    
GetClientAuthString(clientsteamidsizeof(steamid));
    
    
SetTrieString(g_hDenyArraytKey,  steamid);

But i get error on thisone

if (GetTrieValue(g_hDenyArray, steamid, tKey))
__________________

Last edited by ecca; 01-20-2012 at 15:12.
ecca is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 01-20-2012 , 15:25   Re: Adt_Trie errors
Reply With Quote #2

A trie is for storing key/value pairs. If you're just storing values (in this case, strings), you may want to use an adt_array along with FindStringInArray.

Specifically, the logic for using an adt_array would look like this:
PHP Code:
#include <adt_array>

new Handle:g_hDenyArray INVALID_HANDLE;

public 
OnPluginStart()
{
    new 
stringSize ByteCountToCells(30);
    
g_hDenyArray CreateArray(stringSize);
}

public 
OnMapStart()
{
    
ClearArray(g_hDenyArray);
}

public 
OnClientPostAdminCheck(client)
{    
    new 
String:steamid[30];
    
GetClientAuthString(clientsteamidsizeof(steamid));
    
    if (
FindStringInArray(g_hDenyArraysteamid) != -1)
    {
       
//ACTION
    
}
}

public 
OnClientDisconnect(client)
{
    new 
String:steamid[30];
    
GetClientAuthString(clientsteamidsizeof(steamid));
    
    new 
position FindStringInArray(g_hDenyArraysteamid);
    if (
position == -1)
    {
        
PushArrayString(g_hDenyArraysteamid);
    }

Side note: I also adjusted it to clear the array every map change instead of repeatedly creating it.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 01-20-2012 at 15:27.
Powerlord is offline
ecca
Sexy Santa
Join Date: Jan 2011
Old 01-20-2012 , 15:43   Re: Adt_Trie errors
Reply With Quote #3

Oh thank you ;) fixed it
__________________
ecca 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 15:27.


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