1
2
ID:272810
Mar 11 2009, 10:01 am
|
|
I wanna be able to add "list entries" to a .txt file, and then load those entries into a list var in DM. I have no idea how to go about this :\
|
Mar 11 2009, 10:03 am
|
|
You best show us the format you want for the text file.
|
In response to Stephen001
|
|
Uhh >.< Line breaks?
//example info in the .txt file //when loaded into the list var... |
In response to Spunky_Girl
|
|
By using file2text(), copytext(), and findtext() or text2ascii().
|
In response to Popisfizzy
|
|
I tried the below code, with the even further below lines in the .txt file, yet it still booted me when I hosted in DD and joined :(
client/New() Spunky_Girl |
In response to Spunky_Girl
|
|
client/New() works only so far but when you have a code specified to do something (boot someone off) it will do it if returned true or false depending on what you want.
|
In response to Robotyoshi
|
|
Sorry but you're absolutely no help. I have it checking to see if it can't find src's key in the .txt file. findtext() returns a text string or null. Since it's booting me, it's returning null (false). I want to know why, and then how to fix that.
|
In response to Spunky_Girl
|
|
/* |
In response to Spunky_Girl
|
|
You should have noticed that you don't get the output message, however. That "boot" would remain even if you entirely removed the del call - it stems from incorrect usage of client/New(). This proc's return value is checked and is meaningful - it is the mob to connect the player to, or any other value to not connect him to any and disallow the connection. In your override, albeit you're calling the default action, you're discarding its return value, and ultimately returning null (the default value of the . var). You can 'forward' the parent proc's return value and return it in an override by simply using return ..() or a similar statement.
Alternatively, you could use world/IsBanned() to do this checking and block connections through there before a client is created, since you only need the key. Note this does not however work on the host. Also note checking for a word or entry in a bunch of text directly is not completely reliable - since it simply checks if the text you're looking for is there, it will still find it even if it's a part of another word or entry. For example, a person with the key Dude would be allowed in if the key CoolDude is allowed, because his key can be found amidst the text, even though it's actually in a separate key. |
In response to Kaioken
|
|
Kaioken wrote:
Also note checking for a word or entry in a bunch of text directly is not completely reliable - since it simply checks if the text you're looking for is there, it will still find it even if it's a part of another word or entry. For example, a person with the key Dude would be allowed in if the key CoolDude is allowed, because his key can be found amidst the text, even though it's actually in a separate key. Using Pop's method, if I did my own sort of "hashing" method, would it work to prevent the "Dude-CoolDude" mix-up? //entry in .txt file |
In response to Spunky_Girl
|
|
Or, more easily, make sure that every one has a linebreak at the end (meaning the end of the TXT would need an extra line), and just search ckey + "\n".
Also, that's about as much hashing as it is cryptography. |
In response to Popisfizzy
|
|
So the list of ckeys would look like...?
spunkygirl |
In response to Spunky_Girl
|
|
No, it would look like this:
popisfizzy Note the extra linebreak on the last line. |
In response to Popisfizzy
|
|
Oh, of course xD
I'm still connecting! Even when I log on with a totally different key. I hosted it on my shell server and not DD this time. Am I doing something wrong? No messages are appearing, so the .txt file is being found... var/reference_file = "Savefile/keys.txt" |
In response to Spunky_Girl
|
|
You're using the ckey in the file, right? Also, output the value of file_data and see what it shows.
|
In response to Popisfizzy
|
|
Oh my... I'm either totally stupid, or I just had a blond moment >_>
I forgot to "include" the file the snippets are in ;p Thanks Pop! xD |
I'm astonished that not a single person mentioned params2list and list2params.
|
In response to Schnitzelnagler
|
|
Perhaps because it is much less pretty than using other methods of separation such as linebreaks? :P More suitable for other mediums than text files, I think, but of course whatever floats your boat. Also, learning in a non-built-in-proc kind of way is still more beneficial since one learns how to accomplish the matter more generally, and so is not limited to params format or anything. >.>
|
In response to Kaioken
|
|
Would it be beneficial to know how to use parameters in this case for other game programming languages? (such as C++)
|
In response to Spunky_Girl
|
|
yes parameters are very important in other game programming especially with outside files it is very much needed when calling .dll files or the like and parameters or "arguments" are one of the basic needs for function to function communication in C++
|
1
2