users.txt, How wood i read and write in it?
#1

Ok , lets say i made users.txt in my scripfiles and then i would want something like this

Код:
Username,Password,Adminlevel,Score
and so on so that it saves stats. I know how to make the saving e.t.c, but how do i make a list like that and read from it?

like...

Код:
var1,string1,val2
and put that in one List variable?
Reply
#2

That is impossible,you can only have it like this:

var1
var2
var3
Reply
#3

Actually im pretty sure i saw it in a script. i done some research but didnt find anything. so im sure its possible some way. Like multiple lines with
Код:
Var1,String1,String1,Var1
(Example) and then read all of em
Reply
#4

You can make one line but that it will be hard to overview, when you will need to edit some stuffs manual.

Im sure that on this forum there have many stats saving tutorials
Reply
#5

It's possible, but a bad idea. You would have to loop through every line of the file preceding somebody's player information, which could possibly cause a hang.
Reply
#6

Yeah well i atent to use it for 'admins.txt'
Reply
#7

Lolz, just use sscanf for that.
Reply
#8

Im kinda not a pro, can you pl0x show a example?
Reply
#9

Basic:
pawn Код:
new
    var1,
    var2,
    var3;

new resultline[256];
fread(file, resultline);

sscanf(resultline, "p<,>iii", var1, var2, var3);
If you use an enum for your data, it can be done even simpler (requires the sscanf2 plugin, though).
Please read the sscanf topic here: https://sampforum.blast.hk/showthread.php?tid=120356
Reply
#10

hmm. Thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)