01.08.2016, 17:51
PHP код:
SavePlayer(playerid)
{
new PlayerName[24];
GetPlayerName(playerid,PlayerName,24);
new file[256]; format(file,256,"/ladmin/users/%s.sav",udb_encode(PlayerName));
if(PlayerInfo[playerid][LoggedIn] == 1)
{
dUserSetINT(PlayerName2(playerid)).("money",GetPlayerMoney(playerid));
dUserSetINT(PlayerName2(playerid)).("Score",GetPlayerScore(playerid)); //Here is the code
dUserSetINT(PlayerName2(playerid)).("kills",PlayerInfo[playerid][Kills]);
dUserSetINT(PlayerName2(playerid)).("deaths",PlayerInfo[playerid][Deaths]);
}
}
LoginPlayer(playerid)
{
if(ServerInfo[GiveMoney] == 1) {ResetPlayerMoney(playerid); GivePlayerMoney(playerid, dUserINT(PlayerName2(playerid)).("money") ); }
dUserSetINT(PlayerName2(playerid)).("loggedin",1);
PlayerInfo[playerid][Deaths] = (dUserINT(PlayerName2(playerid)).("deaths"));
PlayerInfo[playerid][Kills] = (dUserINT(PlayerName2(playerid)).("kills"));
PlayerInfo[playerid][BTLevel] = (dUserINT(PlayerName2(playerid)).("btlevel"));
PlayerInfo[playerid][Level] = (dUserINT(PlayerName2(playerid)).("level"));
PlayerInfo[playerid][VipLevel] = (dUserINT(PlayerName2(playerid)).("viplevel"));
PlayerInfo[playerid][PMBlock] = (dUserINT(PlayerName2(playerid)).("PMBlock"));
SetPlayerScore(playerid,dUserINT(PlayerName2(playerid)).("Score")); // And here also
PlayerInfo[playerid][Registered] = 1;
PlayerInfo[playerid][LoggedIn] = 1;
}
CMD:register(playerid,params[])
{
if (PlayerInfo[playerid][LoggedIn] == 1) return SendClientMessage(playerid,COLOR_RED,"ACCOUNT: You are already registered and logged in.");
if (udb_Exists(PlayerName2(playerid))) return SendClientMessage(playerid,COLOR_RED,"ACCOUNT: This account already exists, please use '/login [password]'.");
if (strlen(params) == 0) return SendClientMessage(playerid,COLOR_RED,"ACCOUNT: Correct usage: '/register [password]'");
if (strlen(params) < 4 || strlen(params) > 20) return SendClientMessage(playerid,COLOR_RED,"ACCOUNT: Password length must be greater than three characters");
if (udb_Create(PlayerName2(playerid),params))
{
new file[256],rname[MAX_PLAYER_NAME], tmp3[100];
new strdate[20], year,month,day;
getdate(year, month, day);
GetPlayerName(playerid,rname,sizeof(rname));
format(file,sizeof(file),"/ladmin/users/%s.sav",udb_encode(rname));
GetPlayerIp(playerid,tmp3,100);
dini_Set(file,"ip",tmp3);
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)).("LastOn",0);
dUserSetINT(PlayerName2(playerid)).("money",0);
dUserSetINT(PlayerName2(playerid)).("kills",0);
dUserSetINT(PlayerName2(playerid)).("deaths",0);
dUserSetINT(PlayerName2(playerid)).("Score",0); // and here in cmd
dUserSetINT(PlayerName2(playerid)).("Bank",PlayerInfo[playerid][bank]);
PlayerInfo[playerid][LoggedIn] = 1;
PlayerInfo[playerid][Registered] = 1;
SavePlayer(playerid);
LoginPlayer(playerid);
LoadPlayer(playerid);
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;
}