SA-MP Forums Archive
problem with "fexist", "fcreate"... - 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: problem with "fexist", "fcreate"... (/showthread.php?tid=74174)



problem with "fexist", "fcreate"... - darkot - 20.04.2009

Hi all,

I created a FS for registration (with /login and /register).
I use dini and dudb.
But i want to change all function used by dini to function used with "fcreate", "fexist", "fopen" ...

That is my callback OnPlayerConnect. How to change function in bold to function file ?

public OnPlayerConnect(playerid)
{
new PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
if (!udb_Exists(PName(playerid)))
{
SendClientMessage(playerid,0xFFFF00AA,"Create an account with /register");
}
if (udb_Exists(PName(playerid)))
{
SendClientMessage(playerid,0xFFFF00AA,"Login to your account with /login");
}
PLAYERLIST_authed[playerid] = false;
return false;
}

Thanks all !

PS: Sorry for my bad english, i'm french !


Re: problem with "fexist", "fcreate"... - Klutty - 20.04.2009

pawn Код:
public OnPlayerConnect(playerid)
{
new PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
if (!udb_Exists(PName(playerid))
{
SendClientMessage(playerid,0xFFFF00AA,"Create an account with /register");
}
if (udb_Exists(PName(playerid))
{
SendClientMessage(playerid,0xFFFF00AA,"Login to your account with /login");
}
PLAYERLIST_authed[playerid] = false;
return false;
}
Try that.


Re: problem with "fexist", "fcreate"... - darkot - 20.04.2009

No it's not the problem.

I want to change !udb_Exists(PName(playerid) to if(fexist..)
But i don't know the right code...

Thanks.


Re: problem with "fexist", "fcreate"... - darkot - 20.04.2009

Nobody can help me ?

++


Re: problem with "fexist", "fcreate"... - Donny_k - 20.04.2009

They are just a wrapper for the file functions, take a look in the includes at the source code.


Re: problem with "fexist", "fcreate"... - darkot - 20.04.2009

I think you don't understand ...

Код:
public OnPlayerConnect(playerid)
{
	new PlayerName[MAX_PLAYER_NAME];
	GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
	if (!fexist("%d.txt", PName)){ SendClientMessage(playerid,0xFFFF00AA,"Create an account: /register");}
	if (fexist("%d.txt", PName)){ SendClientMessage(playerid,0xFFFF00AA,"Connect to your account: /login");}
	PLAYERLIST_authed[playerid] = false;
  return false;
}
There is errors .. from if (!fexist("%d.txt", PName))

How i can remove errors ?

Thanks


Re: problem with "fexist", "fcreate"... - yom - 20.04.2009

Maybe read functions parameters...

fexist only require a filename as parameter. Use format() for formatting the filename.

pawn Код:
new string[MAX_PLAYER_NAME + 5];
GetPlayerName(playerid, string, MAX_PLAYER_NAME);
format(string, sizeof string, "%s.txt", string);

if (!fexist(string))
{
  //file dont exist
}



Re: problem with "fexist", "fcreate"... - darkot - 21.04.2009

Thanks, it works, but how i do this one. I've test but don't work.

Код:
public OnPlayerDisconnect(playerid)
{
new string[MAX_PLAYER_NAME + 5];
GetPlayerName(playerid, string, MAX_PLAYER_NAME);
format(string, sizeof string, "%s.txt", string);
if(fexist(string))
{
new tmp[256];
new monaie = GetPlayerMoney(playerid);
new File:hFile;
format(tmp, sizeof(tmp), "Monaie=%s \r\n",monaie);
hFile = fopen("%s.txt", io_append);
fwrite(hFile, tmp);
fclose(hFile);
}
PLAYERLIST_authed[playerid] = false;
return false;
}
Thanks again


Re: problem with "fexist", "fcreate"... - yom - 21.04.2009

pawn Код:
public OnPlayerDisconnect(playerid)
{
  new string[256];
  GetPlayerName(playerid, string, MAX_PLAYER_NAME);
  format(string, sizeof string, "%s.txt", string);
  new File:hFile = fopen(string, io_append);

  if (hFile)
  {
    format(string, sizeof string, "Monaie=%d\r\n", GetPlayerMoney(playerid));
    fwrite(hFile, string);
    fclose(hFile);
  }

  PLAYERLIST_authed[playerid] = false;
  return false;
}



Re: problem with "fexist", "fcreate"... - darkot - 21.04.2009

Thanks

Is exist a function to create one I've need for my register function ...