[HELP] File Path - 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: [HELP] File Path (
/showthread.php?tid=85175)
[HELP] File Path -
Haegon - 06.07.2009
I posted this in Dracoblue's Dini post, but i'm not getting any replies, so I figured I would post here to, as I am in a rush to get this done.
So, I have a problem reading and writing to player files. I use XAdmin, so the path is scriptfiles/xadmin/users/PlayerNameHere.ini
Well, here is my code:
Code:
if(dini_Exists("scriptfiles/xadmin/Users/%s.ini"))
{
dini_IntSet("scriptfiles/xadmin/Users/%s.ini", "Job", 3);
}
It isn't reaching the player files, I don't think. I read something about %s not working with the file path?
How would I go about fixing that?
Thanks. Smiley
Re: [HELP] File Path -
Correlli - 06.07.2009
You don't need to write \scriptfiles\ for the file's name. Everything is saving to scriptfiles by default.
Re: [HELP] File Path -
Haegon - 06.07.2009
Yeah, true. But, is there anything else I am doing wrong? I've been looking around and searching but I can't find anything on the subject.
Re: [HELP] File Path -
yom - 06.07.2009
You have to assign something to %s. Do you think Pawn is smart enough to guess that your %s should be a player name?
pawn Код:
new str[17 + MAX_PLAYER_NAME];
GetPlayerName(playerid, str, MAX_PLAYER_NAME);
format(str, sizeof str, "xadmin/Users/%s.ini", str);
if(dini_Exists(str))
But this will silently crash your server if a player have a name containing forbidden files characters.
Re: [HELP] File Path -
-Sneaky- - 06.07.2009
Quote:
Originally Posted by 0rb
You have to assign something to %s. Do you think Pawn is smart enough to guess that your %s should be a player name?
pawn Код:
new str[18 + MAX_PLAYER_NAME]; GetPlayerName(playerid, str, MAX_PLAYER_NAME); format(str, sizeof str, "xadmin/Users/%s.ini", str);
if(dini_Exists(str))
But this will silently crash your server if a player have a name containing forbidden files characters.
|
Why do you do:
pawn Код:
new str[18 + MAX_PLAYER_NAME];
24 (MAX_PLAYER_NAME) + 18 = 42 but a player's name can only be max 24 characters..
Re: [HELP] File Path -
Haegon - 06.07.2009
This is what I have right now, and I tried to pick up a job in my server and it didn't write it to the file. I'm absolutely clueless about the problem.
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new string[64], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "xadmin/Users/%s.ini", name);
Then further down, once into the commands, I have:
Код:
if(dini_Exists(string))
{
dini_IntSet(string, "Job", 3);
}
Re: [HELP] File Path -
yom - 06.07.2009
Quote:
Originally Posted by Sneaky.
Why do you do:
pawn Код:
new str[18 + MAX_PLAYER_NAME];
24 (MAX_PLAYER_NAME) + 18 = 42 but a player's name can only be max 24 characters..
|
The lenght of "xadmin/Users/" + ".ini".. (which is 17, my bad) so it doesn't waste the 47 unused cells in "new string[64], name[MAX_PLAYER_NAME];"
Re: [HELP] File Path -
-Sneaky- - 06.07.2009
Ah yeah, overlooked it.. my bad
Re: [HELP] File Path -
dice7 - 06.07.2009
There is nothing wrong with your code. The only thing that could come to my mind is that is the file, you're trying to write in, actually created ?
Re: [HELP] File Path -
Haegon - 07.07.2009
It is created. That's what's confusing me. I can't find a single problem with the code. Here is the full code of the area i'm having trouble with:
http://pastebin.com/m5f07d723
That's all of it.