problem with "fexist", "fcreate"...
#1

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 !
Reply
#2

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.
Reply
#3

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.
Reply
#4

Nobody can help me ?

++
Reply
#5

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

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
Reply
#7

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
}
Reply
#8

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
Reply
#9

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;
}
Reply
#10

Thanks

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

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)