ID:154580
Feb 20 2001, 5:33 am
|
|
I'm making some administrative tools for my game, how would you make it so that if your key is in a text files such as "admin.txt" that it adds -{Admin} to your name?
|
In response to Deadron
|
|
Ok i'm not sure if this coude should work or not but here's what i have:
proc/seeadmin() dd_file2list("admin.mej",) if(usr.key in listText) usr.name += "-{Admin}" else if(usr.name += "-{Admin}" && usr.key not in listText) usr.name -= "-{Admin}" return It's supposed to look at the list and if the usr's key is on the list then it should add "-{Admin}". If their key isn't on the list and they have "-{Admin}" in their name it should be removed. Deadron, i'm not exactly sure how to use dd_file2list() so i just guessed. Thanks |
In response to Spastic
|
|
On 2/20/01 9:42 am Spastic wrote:
Ok i'm not sure if this coude should work or not but here's what i have: Ack the download page has out of date documentation (will be fixed when the new developer forum system Tom is doing is in place). In the meantime there is documentation for everything in the library in the HTML document that comes with the library -- you can also see it on the Deadron site. In short, the function returns a list in which each item is one line of the file. So your function, is close, but would change slightly to look like this: proc/seeadmin() var/list/listText = dd_file2list("admin.mej") if(usr.key in listText) & amp;nbsp; usr.name += "-{Admin}" For the part where you remove the admin string from a non-admin user, that code won't work (you can't use -= with text, to my knowledge). However, there is a Deadron library function for that too! usr.name = dd_replacetext (usr.name, "-{Admin}", "" ) |
In response to Deadron
|
|
Thanks your one of the greatest!
Kevin On 2/20/01 2:58 pm Deadron wrote: On 2/20/01 9:42 am Spastic wrote: |
In response to Spastic
|
|
On 2/20/01 3:14 pm Spastic wrote:
Thanks your one of the greatest! I appreciate your using the library! It's inspiring me to work on the next release, which has some cool new functions (like sorting lists of text) and will get rid of some old functions that just confuse things. |
That's a good way to do it.
You can look up the file2text() command to see how to read in a file.
You might also check out the Deadron library, which contains the dd_file2list() command. It will read each line of the file into a list, making it easy for you to look at each line.