Raised This Month: $ Target: $400
 0% 

Storing Values


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
LordFear
Junior Member
Join Date: Dec 2009
Location: Sweden
Old 12-28-2009 , 10:54   Storing Values
Reply With Quote #1

I'm currently making a Chat Filter plugin for a community. I want it to be as flexible as possible and therefore needs to load the list of words from a file.

My problem is, I don't know how to store the words. Each word will contain a string (the actual word to search for), a value representing what will happen if you say the word (warning, kick or ban) and a last string used to hold the ban length (if ban is chosen).

If I use KeyValues (which I haven't used before but I understand how it works) it would probably look something like:
Code:
"WordList"
{
    "santa"
    {
        "value"        "1"
        "banlenght"    "1440"
    }
    "rudolf"
    {
        "value"        "2"
    }
    "pie"
     {
        "value"        "3"
     }
}
Would that be effective to search through for words on the fly every time someone writes in the chat?
Or would it be better building a file looking like this:
Code:
"santa" 1 1440
"rudolf" 2
"pie" 3
and then store them in one(or more) arrays?


Thanks in advanced!
LordFear is offline
Peoples Army
SourceMod Donor
Join Date: Mar 2007
Old 12-28-2009 , 11:24   Re: Storing Values
Reply With Quote #2

I would use arrays, and also I'm almost certain theres a better way to read and write from a text file, although I suck with read & write
__________________
Peoples Army is offline
LordFear
Junior Member
Join Date: Dec 2009
Location: Sweden
Old 12-28-2009 , 11:45   Re: Storing Values
Reply With Quote #3

Quote:
Originally Posted by Peoples Army View Post
I would use arrays, and also I'm almost certain theres a better way to read and write from a text file, although I suck with read & write

Would you use 3 separate arrays then, one for each value or one multidimensional?
LordFear is offline
FaTony
Veteran Member
Join Date: Aug 2008
Old 12-28-2009 , 12:46   Re: Storing Values
Reply With Quote #4

http://forums.alliedmods.net/showthread.php?t=109510
FaTony is offline
LordFear
Junior Member
Join Date: Dec 2009
Location: Sweden
Old 12-28-2009 , 14:19   Re: Storing Values
Reply With Quote #5

Quote:
Originally Posted by FaTony View Post

Thanks alot!
LordFear 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 17:22.


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