Y_Ini problem: - 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: Y_Ini problem: (
/showthread.php?tid=215540)
Y_Ini problem: -
Mean - 23.01.2011
pawn Code:
CMD:register(playerid, params[])
{
new file[256],n[MAX_PLAYER_NAME];
GetPlayerName(playerid,n,MAX_PLAYER_NAME);
format(file,sizeof(file),"mAdmin/Users/%s.txt",n);
if(fexist(file))
return SendClientMessage(playerid,YELLOW,"You are already registered!");
if(PInfo[playerid][Regged] == 1)
return SendClientMessage(playerid,LIGHTBLUE,"You are already registered!");
if(PInfo[playerid][Logged] == 1)
return SendClientMessage(playerid,ORANGE,"You are already registered, and logged in!");
new INI:PlayerAcc = INI_Open(file);
if(!isnull(params))
{
if(!fexist(file))
{
INI_WriteString(PlayerAcc,"Password",params);
INI_WriteInt(PlayerAcc,"Regged",1);
INI_WriteInt(PlayerAcc,"Logged",0);
INI_WriteInt(PlayerAcc,"Level",0);
INI_WriteInt(PlayerAcc,"Score",GetPlayerScore(playerid));
INI_WriteInt(PlayerAcc,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(PlayerAcc,"Deaths",0);
INI_WriteInt(PlayerAcc,"Kills",0);
SendClientMessage(playerid,ORANGE,"You have just registered, Please use /login [password] to login!");
PInfo[playerid][Regged] = 1;
return 1;
}
}
else
{
SendClientMessage(playerid,GREY,"USAGE: /register <Password>");
return 1;
}
return 1;
}
The problem is that, it doesn't create a file. No file gets created in my mAdmin/Users.
Re: Y_Ini problem: -
Zh3r0 - 23.01.2011
File must be .ini not .txt
So this
pawn Code:
format(file,sizeof(file),"mAdmin/Users/%s.txt",n);
becomes
pawn Code:
format(file,sizeof(file),"mAdmin/Users/%s.ini",n);
Re: Y_Ini problem: -
Mean - 23.01.2011
No, still the same
Re: Y_Ini problem: -
Zh3r0 - 23.01.2011
Ah yeah, you need to close the file.
So
pawn Code:
//[...]
INI_WriteInt(PlayerAcc,"Deaths",0);
INI_WriteInt(PlayerAcc,"Kills",0);
INI_Close( PlayerAcc ); //<-- this.
SendClientMessage(playerid,ORANGE,"You have just registered, Please use /login [password] to login!");
PInfo[playerid][Regged] = 1;
Re: Y_Ini problem: -
Mean - 23.01.2011
Oh lol, forgot that. Okay testing.
EDIT: It works, thanks!