02.08.2012, 17:48
Hello, I've got a problem regarding my admin system. When someone enters the server and doesn't /register, it shows that they have 30-40 more hours than they should. Please tell me how to solve this bug. Thank you.
dcmd_register(playerid,params[])
{
if (PlayerInfo[playerid][LoggedIn] == 1) return SendClientMessage(playerid,red,"ACCOUNT: You are already registered and logged in.");
if (udb_Exists(PlayerName2(playerid))) return SendClientMessage(playerid,red,"ACCOUNT: This account already exists, please use '/login [password]'.");
if (strlen(params) == 0) return SendClientMessage(playerid,red,"ACCOUNT: Correct usage: '/register [password]'");
if (strlen(params) < 4 || strlen(params) > 20) return SendClientMessage(playerid,red,"ACCOUNT: Password length must be greater than three characters");
if (udb_Create(PlayerName2(playerid),params))
{
new file[256],name[MAX_PLAYER_NAME], tmp3[100];
new strdate[20], year,month,day; getdate(year, month, day);
GetPlayerName(playerid,name,sizeof(name)); format(file,sizeof(file),"/ladmin/users/%s.sav",udb_encode(name));
GetPlayerIp(playerid,tmp3,100); dini_Set(file,"ip",tmp3);
dini_Set(file,"password",params);
dUserSetINT(PlayerName2(playerid)).("registered",1);
format(strdate, sizeof(strdate), "%d/%d/%d",day,month,year);
dini_Set(file,"RegisteredDate",strdate);
dUserSetINT(PlayerName2(playerid)).("loggedin",1);
dUserSetINT(PlayerName2(playerid)).("banned",0);
dUserSetINT(PlayerName2(playerid)).("level",0);
dUserSetINT(PlayerName2(playerid)).("vip",0);
dUserSetINT(PlayerName2(playerid)).("LastOn",0);
dUserSetINT(PlayerName2(playerid)).("money",0);
dUserSetINT(PlayerName2(playerid)).("kills",0);
dUserSetINT(PlayerName2(playerid)).("deaths",0);
dUserSetINT(PlayerName2(playerid)).("hours",0);
dUserSetINT(PlayerName2(playerid)).("minutes",0);
dUserSetINT(PlayerName2(playerid)).("seconds",0);
PlayerInfo[playerid][LoggedIn] = 1;
PlayerInfo[playerid][Registered] = 1;
SendClientMessage(playerid, green, "ACCOUNT: You are now registered, and have been automaticaly logged in");
PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
return 1;
}
return 1;
}
#if defined USE_STATS
dcmd_stats(playerid,params[]) {
new rankid = pRank[playerid];
new plName[MAX_PLAYER_NAME];
GetPlayerName(playerid, plName, sizeof(plName));
new rank[20];
if(pRank[playerid] == 0) { rank = "Newbie"; }
else if(pRank[playerid] == 1) { rank = "Baby Killa'"; }
else if(pRank[playerid] == 2) { rank = "Soldier"; }
else if(pRank[playerid] == 3) { rank = "Gangsta'"; }
else if(pRank[playerid] == 4) { rank = "Underboss"; }
else if(pRank[playerid] == 5) { rank = "Tha' Boss"; }
new string[9999],sA[1024],sM[1024],sD[1024],sS[1024], sL[1024], sI[1024],file[256],P1Logged[4],P1Register[4],RegDate[256], pDeaths, player1, h, m, s;
if(!strlen(params)) player1 = playerid;
else player1 = strval(params);
format(file,sizeof(file),"/ladmin/users/%s.sav",udb_encode(PlayerName2(player1)));
if(strlen(dini_Get(file,"RegisteredDate")) < 3) RegDate = "n/a"; else RegDate = dini_Get(file,"RegisteredDate");
if(PlayerInfo[player1][LoggedIn] == 1) P1Logged = "Yes"; else P1Logged = "No";
if(fexist(file)) P1Register = "Yes"; else P1Register = "No";
if(IsPlayerConnected(player1)) {
new year,month,day; getdate(year, month, day);
TotalGameTime(player1, h, m, s);
if(PlayerInfo[player1][Deaths] == 0) pDeaths = 1; else pDeaths = PlayerInfo[player1][Deaths];
format(sA, sizeof(sA), ""O"Player Money: "V"["R"$"L"%d"V"]\n"O"Player Score: "V"["L"%d"V"]\n"O"Player Skin: "V"["L"%d"V"]",GetPlayerMoney(player1),GetPlayerScore(player1),GetPlayerSkin(player1));
format(sD, sizeof(sD), ""O"Warnings: "V"["L"%d"V"]\n"O"Register Date: "V"["L"%s"V"]\n"O"Register: "V"["L"%s"V"]\n"O"Login: "V"["L"%s"V"]\n"O"Coins("R"Monede"O"): "V"["L"%d"V"]",PlayerInfo[player1][Warnings],RegDate,P1Register,P1Logged,pInfo[playerid][Coins]);
format(sI, sizeof(sI), ""O"Rank: "V"["L"%d"V"] "V"("R"%s"V")\n"O"Admin Level: "V"["L"%d"V"]\n"O"Vip Level: "V"["L"%d"V"]",rankid,rank,PlayerInfo[player1][Level],PlayerInfo[player1][Vip]);
format(sM, sizeof(sM), ""O"Player Kills: "V"["L"%d"V"]\n"O"Player Deaths: "V"["L"%d"V"]\n"O"Player Ratio: "V"["L"%0.2f"V"]",PlayerInfo[player1][Kills],PlayerInfo[player1][Deaths],Float:PlayerInfo[player1][Kills]/Float:pDeaths);
format(sS, sizeof(sS), ""O"Player Time: "O"hrs"V"["L"%d"V"] "O"mins"V"["L"%d"V"] "O"secs"V"["L"%d"V"]",h,m,s);
format(string, sizeof(string),"%s\n\t"G"Date:"L"%d"G"*"L"%d"G"*"L"%d "V"["G"%s"V"]"R"'s Stats\n%s\n%s\n%s\n%s\n%s\n%s\n%s",sL,year,month,day,PlayerName2(player1),sL,sM,sA,sS,sI,sD,sL);
return ShowPlayerDialog(playerid, 9999, 0, "Player Stats", string, "Ok", "");
} else return SendClientMessage(playerid, red, "Player Not Connected!");
}
#endif