SA-MP Forums Archive
reading files with strings in them? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: reading files with strings in them? (/showthread.php?tid=225728)



reading files with strings in them? - YungGee - 14.02.2011

how can i read a dini file with a sting in it?

Like
Код:
new File:example = fopen("%s.txt", io_read);
%s is there name

This dnt work:

Код:
new str[128], f[256], n[24];
GetPlayerName(playerid,n,24);
new File:example = fopen(f,sizeof(f),"%s.txt",n,io_read);
Any help :S


Re: reading files with strings in them? - (SF)Noobanatior - 14.02.2011

pawn Код:
#define USERBASE "Users/%s.txt"
new DBstr[128]
GetPlayerName(playerid, playername, sizeof(playername));
format(DBstr,sizeof(DBstr),USERBASE,udb_encode(playername));
is how i do it with dini
then just...whatever
pawn Код:
dini_Create(DBstr);
dini_IntSet(DBstr, "Password",      udb_hash(tmp));
dini_FloatSet(DBstr, "TimeOnline",          0.0);
dini_IntSet(DBstr, "Bank    ",          30000);



Re: reading files with strings in them? - YungGee - 14.02.2011

dude....i wana know how to open files with strings.....not format them/....


Re: reading files with strings in them? - (SF)Noobanatior - 14.02.2011

that is how you do it if there is something unique in the name then you must format it first so it reads how you want it to
like
pawn Код:
new DBstr[128]
GetPlayerName(playerid, playername, sizeof(playername));
format(DBstr,sizeof(DBstr),%s.txt,playername);
dini_Create(DBstr);