SA-MP Forums Archive
Need a bit of help at Dini. - 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: Need a bit of help at Dini. (/showthread.php?tid=75897)



Need a bit of help at Dini. - shitbird - 03.05.2009

Allright, so Me and a Friend, is doing this Stunting server together, and for some reason, it doesnt Save the files when you exit the server, nor does it read it apparently, when you log in, or maybe it's just one of them, i just dont get it... can anyone take a look at the code and see if there is anything wrong?... Thanks.

REGISTER:

Код:
dcmd_register(playerid, params[])
{
  new file[256], pName[MAX_PLAYER_NAME];
  GetPlayerName(playerid, pName, sizeof(pName));
  format(file, sizeof(file), "%s.ini", pName);
  if(!strlen(params)) return SendClientMessage(playerid, COLOR_RED, "USAGE:/register [Password]");
  if(dini_Exists(file)) return SendClientMessage(playerid, COLOR_RED, "You are already registered!");
  dini_Create(file);
  dini_IntSet(file, "HashPW", udb_hash(params));
  dini_IntSet(file, "Admin", 0);
  dini_IntSet(file, "Score", GetPlayerScore(playerid));
  dini_IntSet(file, "Money", GetPlayerMoney(playerid));
  new string[128];
  format(string, sizeof(string), "You succesfully registered the nickname %s", pName);
  SendClientMessage(playerid, COLOR_YELLOW, string);
  IsPlayerLoggedIn[playerid] = 1;
  SendClientMessage(playerid, COLOR_YELLOW, "You have been automatically Logged in!");
  return true;
}
LOGIN:
Код:
dcmd_login(playerid, params[])
{
  new file[256];
  new string[128], pName[MAX_PLAYER_NAME];
  GetPlayerName(playerid, pName, sizeof(pName));
  format(file, sizeof(string), "%s.ini", pName);
  if(!strlen(params)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /login [Password]");
  if(!dini_Exists(file)) return SendClientMessage(playerid, COLOR_RED, "You are not registered!");
  if(IsPlayerLoggedIn[playerid]) return SendClientMessage(playerid, COLOR_RED, "You are already Logged in!");
  new tmp[256];
  tmp = dini_Get(file, "HashPW");
  if(udb_hash(params) != strval(tmp))
  {
    format(string, sizeof(string), "You specified the wrong Password for %s!", pName);
    SendClientMessage(playerid, COLOR_RED, string);
  }
  else
  {
    IsPlayerLoggedIn[playerid] = 1;
    IsPlayerAdminX[playerid] = dini_Int(file, "Admin");
    GivePlayerMoney(playerid,dini_Int(file, "Money")-GetPlayerMoney(playerid));
    SetPlayerScore(playerid,dini_Int(file, "Score")-GetPlayerScore(playerid));
    SendClientMessage(playerid, COLOR_GREEN, "You have succesfully Logged in!");
    printf("%s (%i) Logged in.", pName, playerid);
  }
  return true;
}
DISCONNECT
Код:
public OnPlayerDisconnect(playerid, reason)
{
  new pName[MAX_PLAYER_NAME], string[128], file[256];
  format(file, sizeof(file), "%s.ini", pName);
  if (IsPlayerLoggedIn[playerid])
  {
  	dini_IntSet(file, "Score", GetPlayerScore(playerid));
  	dini_IntSet(file, "Money", GetPlayerMoney(playerid));
  }
  GetPlayerName(playerid, pName, sizeof(pName));
	switch(reason)
 	{
    case 0: format(string, sizeof(string), "%s has left the United Stunting Alliance server. (Lost Connection)", pName);
    case 1: format(string, sizeof(string), "%s has left the United Stunting Alliance server. (Leaving)", pName);
    case 2: format(string, sizeof(string), "%s has left the United Stunting Alliance server. (Kicked/Banned)", pName);
  }
  SendClientMessageToAll(COLOR_RED, string);
  printf(string);
  return true;
}



Re: Need a bit of help at Dini. - HB - 03.05.2009

You have to encode the names as far as I know.


Re: Need a bit of help at Dini. - shitbird - 03.05.2009

What do you mean 'Encode'?.


Re: Need a bit of help at Dini. - HB - 03.05.2009

Quote:
Originally Posted by Mikkel
What do you mean 'Encode'?.
Well, it requires the plugin dudb. Instead of "file" you use "udb_encode(file)".

I might be wrong..


Re: Need a bit of help at Dini. - Andom - 04.05.2009

Try to use file instead of dini, no combinations!


Re: Need a bit of help at Dini. - DracoBlue - 04.05.2009

First let's track down the issue.

Do you get any of the messages you made when doing /register? Are there any *.ini-files in your scriptfiles folder?

- Draco


Re: Need a bit of help at Dini. - shitbird - 04.05.2009

Quote:
Originally Posted by DracoBlue
First let's track down the issue.

Do you get any of the messages you made when doing /register? Are there any *.ini-files in your scriptfiles folder?

- Draco
It shows the Messages fine, it Compiles fine, the problem is that, when you log off it doesnt save anything, and when you try to connect to the server, it says you are already logged in, it's quite a fatal error due to the fact i forced every client to log off at OnPlayerDisconnect, even tho i did that, it still says it's already logged in.

I'm doing a total re-write at the moment, but if you can tell me any info about the error, if you can locate it, it would be nice.


Re: Need a bit of help at Dini. - Think - 04.05.2009

i know the problem, you used a variable (pName[MAX_PLAYERS] and now your trying to create and read an other file (pname) just add [playerid] after each pname and it'll work


Re: Need a bit of help at Dini. - DracoBlue - 04.05.2009

Quote:
Originally Posted by Pandabeer1337
i know the problem, you used a variable (pName[MAX_PLAYERS] and now your trying to create and read an other file (pname) just add [playerid] after each pname and it'll work
MAX_PLAYERS is just the size of the string. It's kinda pointless to use MAX_PLAYERS here - better MAX_PLAYER_NAME.

- Dracp


Re: Need a bit of help at Dini. - pen_theGun - 04.05.2009

Quote:
Originally Posted by Mikkel
when you log off it doesnt save anything, and when you try to connect to the server, it says you are already logged in, it's quite a fatal error due to the fact i forced every client to log off at OnPlayerDisconnect, even tho i did that, it still says it's already logged in.
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
  ........
  if (IsPlayerLoggedIn[playerid])
  {
    dini_IntSet(file, "Score", GetPlayerScore(playerid));
    dini_IntSet(file, "Money", GetPlayerMoney(playerid));
  }
  IsPlayerLoggedIn[playerid]=0; // IsPlayerLoggedIn[playerid]=false ?!
}