Need some help with opening a *specific* user file
#1

To be more specific, how to I open a file for a specific player without knowing there account name ? example: "/Users/playersname.txt" if I dont know the users name 'playersname' how could the file be opened?

heres what I want to be able to do:
Код:
//getting player name
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));

//putting that player name into a path
new File:example = fopen("/Users/name.txt", io_read);
so if the name of the person inside the variable 'name' was 'cool', the path to his file would be "/Users/cool.txt"

Sorry if this is confusing! I am extremely confused my self and don't know if this is even possible.
Reply
#2

Of course it's possible.. here is an example.

pawn Код:
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(str,sizeof(str),"/Users/%s.txt",name);
new File:example = fopen(str, io_read);
Reply
#3

Quote:
Originally Posted by Crazymax
Посмотреть сообщение
Of course it's possible.. here is an example.

pawn Код:
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(str,sizeof(str),"/Users/%s.txt",name);
new File:example = fopen(str, io_read);
I get: error 017: undefined symbol "str"
Reply
#4

Try this.

pawn Код:
new str, name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(str,sizeof(str),"/Users/%s.txt",name);
new File:example = fopen(str, io_read);
Reply
#5

Quote:
Originally Posted by Danny1
Посмотреть сообщение
Try this.

pawn Код:
new str, name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(str,sizeof(str),"/Users/%s.txt",name);
new File:example = fopen(str, io_read);
LOL. Str is string, not integer.
pawn Код:
new str[50], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(str,sizeof(str),"/Users/%s.txt",name);
new File:example = fopen(str, io_read);
Reply
#6

I didn't know sorry.I thinking is that string or not but I decide wrong.
Reply
#7

Quote:
Originally Posted by Danny1
Посмотреть сообщение
Try this.

pawn Код:
new str, name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(str,sizeof(str),"/Users/%s.txt",name);
new File:example = fopen(str, io_read);
Quote:
Originally Posted by [MG]Dimi
Посмотреть сообщение
LOL. Str is string, not integer.
pawn Код:
new str[50], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(str,sizeof(str),"/Users/%s.txt",name);
new File:example = fopen(str, io_read);
Thank you both

rep+ to you guys
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)