Stats are not always saving with my register and login (dudb, DINI and dutils)
#1

I never fixed this and tried a lot... I hope someone can help me. The problem is that when you register for the first time and play a bit, making kills and earning cash, dying sometimes, and log out, and log in later you'll only have your password, no other stats are saving, until you play again for the 2nd time and then it will save, and I want it to save directly the first time, I don't want to losing stats. Can anyone help or correct my script?

pawn Code:
new gPlayerClass[MAX_PLAYERS];
new Killed[MAX_PLAYERS];
new gPlayerJailed[MAX_PLAYERS];

enum PlayerInfo
{
    pAdmin,
    pDeaths,
    pKills,
}

new pInfo[MAX_PLAYERS][PlayerInfo];

new LoggedIn[MAX_PLAYERS];
new Registered[MAX_PLAYERS];
new IsPlayerMuted[MAX_PLAYERS];

new tmp2[MAX_STRING];
new giveplayerid;
new gSpectateID[MAX_PLAYERS];
new gSpectateType[MAX_PLAYERS];
new InfoMessage;
new temp;
pawn Code:
public OnPlayerConnect(playerid)
{
//SendClientMessage(playerid,COLOR_GREY, "SERVER: You are not registered! Use /register [password] to create an account.");

    SetPlayerColor(playerid, COLOR_LIGHTGREY); // Set the player's color to inactive
   
    pInfo[playerid][pAdmin] = 0;
    pInfo[playerid][pDeaths] = 0;
    pInfo[playerid][pKills] = 0;
  LoggedIn[playerid] = 0;
  IsPlayerMuted[playerid] = 0;
  gPlayerJailed[playerid] = 0;

    new PName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, PName, MAX_PLAYER_NAME);

    if(!udb_Exists(PName))
    {
      Registered[playerid] = 0;
        SystemMsg(playerid,"SERVER: You are not registered. Use /register [password] to create an account.");
    }
    else
    {
      Registered[playerid] = 1;
        SystemMsg(playerid,"SERVER: This nickname is registered, please login by using /login [password] to receive your stats.");
    }
   
  new string[256], pname[MAX_PLAYER_NAME];
  GetPlayerName(playerid, pname, sizeof(pname));
  format(string, sizeof(string), "%s has joined the server.", pname);
  SendClientMessageToAll(0xECF2B1FF, string);
   
    /*if(fsearch(KICKPORTAL, PName, true))
  {
    new second, minute, hour, day, month, year, str[128];
      SystemMessage(playerid, "Your name has been banned from this server.");
        gettime(hour, minute, second);
        getdate(year, month, day);
        format(str, sizeof(str), "Player %s tried to join server with banned name on %d/%d/%d at %d:%d:%d.", PName, month, day, year, hour, minute, second);
      KickPlayer(playerid, "");
    }*/

   
    SetVehicleParamsForPlayer(tram,playerid,0,0);
   
    return 1;

}

public OnPlayerDisconnect(playerid, reason)
{
    new string[128], pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, sizeof(pname));
   
  switch(reason){
    case 0:format(string,sizeof(string),"%s has left the server. (Timeout)",pname);
    case 1:format(string,sizeof(string),"%s has left the server. (Leaving)",pname);
    case 2:format(string,sizeof(string),"%s has left the server. (Kicked)",pname);
    }
    SendClientMessageToAll(0xECF2B1FF, string);
   
  if(Registered[playerid])
    {
      new playername[MAX_PLAYER_NAME];
      GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
    dUserSetINT(playername).("Money",GetPlayerMoney(playerid));
    dUserSetINT(playername).("Kills",pInfo[playerid][pKills]);
    dUserSetINT(playername).("Deaths",pInfo[playerid][pDeaths]);
    dUserSetINT(playername).("Admin",pInfo[playerid][pAdmin]);
    }
    gPlayerJailed[playerid] = 0;
    return 1;
}
pawn Code:
dcmd_register(playerid,params[])
{
    new playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
  if(udb_Exists(playername)) return SystemMsg(playerid,"[SERVER] Account already exists, please use /login [password].");
    if(strlen(params)==0) return SystemMsg(playerid,"USAGE: /register [password]");
    if(udb_Create(playername,params))
    {
        SystemMsg(playerid,"Account successfully created. Login with /login [password] now.");
    }
    return 1;
}

dcmd_login(playerid,params[])
{
    if(LoggedIn[playerid] == 1) return SystemMsg(playerid,"You are already logged in!");
  new playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
    if(!udb_Exists(playername)) return SystemMsg(playerid,"Account doesn't exist, please use /register [password].");
    if(strlen(params)==0) return SystemMsg(playerid,"USAGE: /login [password]");
    if(udb_CheckLogin(playername,params)) // Login was correct
    {
    LoggedIn[playerid] = 1;
        GivePlayerMoney(playerid,dUserINT(playername).("money"));
        pInfo[playerid][pAdmin] = dUserINT(playername).("Admin");
        pInfo[playerid][pDeaths] = dUserINT(playername).("deaths");
        pInfo[playerid][pKills] = dUserINT(playername).("kills");
        SetPlayerScore(playerid,pInfo[playerid][pKills] + GetPlayerScore(playerid));

        if(pInfo[playerid][pAdmin] == 0)
        {
            SystemMsg(playerid,"You are now logged in, welcome back!");
            return 1;
        }
        else if(pInfo[playerid][pAdmin] == 1)
        {
            SystemMsg(playerid,"You are now logged in [Admin level 1].");
            return 1;
        }
        else if(pInfo[playerid][pAdmin] == 2)
        {
            SystemMsg(playerid,"You are now logged in [Admin level 2].");
            return 1;
        }
        else if(pInfo[playerid][pAdmin] == 3)
        {
            SystemMsg(playerid,"You are now logged in [Admin level 3].");
            return 1;
        }
        else if(pInfo[playerid][pAdmin] == 4)
        {
            SystemMsg(playerid,"You are now logged in [Admin level 4].");
            return 1;
        }
        else if(pInfo[playerid][pAdmin] == 5)
        {
            SystemMsg(playerid,"You are now logged in [Admin level 5].");
            return 1;
        }
        return SystemMsg(playerid,"You have successfully logged into your account!");
    }
  return SystemMsg(playerid,"Wrong password!");

}
Reply
#2

Under OnPlayerDisconnect replace

pawn Code:
if(Registered[playerid])
with

pawn Code:
if(LoggedIn[playerid] == 1)
Reply
#3

Quote:
Originally Posted by MadeMan
Under OnPlayerDisconnect replace

pawn Code:
if(Registered[playerid])
with

pawn Code:
if(LoggedIn[playerid] == 1)
This makes it even worse...
Reply
#4

Quote:
Originally Posted by DarkPhoenix
This makes it even worse...
What do you mean?
Reply
#5

Quote:
Originally Posted by MadeMan
Quote:
Originally Posted by DarkPhoenix
This makes it even worse...
What do you mean?
More stats will be lost.
Reply
#6

bump
Reply
#7

Quote:

dcmd_register(playerid,params[])
{
new playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
if(udb_Exists(playername)) return SystemMsg(playerid,"[SERVER] Account already exists, please use /login [password].");
if(strlen(params)==0) return SystemMsg(playerid,"USAGE: /register [password]");
if(udb_Create(playername,params))
{
SystemMsg(playerid,"Account successfully created. Login with /login [password] now.");
}
return 1;
}

I think you must add the stats at register like admin level = 0 with dUserSetINT(playername).("Admin", 0); etc......
Reply
#8

May not be fixed! I need help.

Quote:
Originally Posted by |)ЂΩ†{−}ЂR™ – Dare To Die
Quote:

dcmd_register(playerid,params[])
{
new playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
if(udb_Exists(playername)) return SystemMsg(playerid,"[SERVER] Account already exists, please use /login [password].");
if(strlen(params)==0) return SystemMsg(playerid,"USAGE: /register [password]");
if(udb_Create(playername,params))
{
SystemMsg(playerid,"Account successfully created. Login with /login [password] now.");
}
return 1;
}

I think you must add the stats at register like admin level = 0 with dUserSetINT(playername).("Admin", 0); etc......
Don't know how.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)