This is my login/register cmds:
PHP код:
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);
// 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)).("LastOn",0);
dUserSetINT(PlayerName2(playerid)).("money",0);
dUserSetINT(PlayerName2(playerid)).("kills",0);
dUserSetINT(PlayerName2(playerid)).("deaths",0);
dUserSetINT(PlayerName2(playerid)).("Bank",PlayerInfo[playerid][bank]);
dUserSetINT(PlayerName2(playerid)).("weed",PlayerInfo[playerid][weed]);
dUserSetINT(PlayerName2(playerid)).("Gang",PlayerInfo[playerid][gang]);
dUserSetINT(PlayerName2(playerid)).("Condoms",PlayerInfo[playerid][condoms]);
dUserSetINT(PlayerName2(playerid)).("inalcatraz",PlayerInfo[playerid][inalcatraz]);
PlayerInfo[playerid][LoggedIn] = 1;
PlayerInfo[playerid][Registered] = 1;
SavePlayer(playerid);
dUserSetINT(PlayerName2(playerid)).("bowner",0);
dUserSetINT(PlayerName2(playerid)).("bowned",0);
dUserSetINT(PlayerName2(playerid)).("vowned",0);
dUserSetINT(PlayerName2(playerid)).("vowner",0);
dUserSetINT(PlayerName2(playerid)).("vowned2",0);
dUserSetINT(PlayerName2(playerid)).("vowner2",0);
dUserSetINT(PlayerName2(playerid)).("vowned3",0);
dUserSetINT(PlayerName2(playerid)).("vowner3",0);
dUserSetINT(PlayerName2(playerid)).("vowned4",0);
dUserSetINT(PlayerName2(playerid)).("vowner4",0);
dUserSetINT(PlayerName2(playerid)).("vowned5",0);
dUserSetINT(PlayerName2(playerid)).("vowner5",0);
dUserSetINT(PlayerName2(playerid)).("vowned6",0);
dUserSetINT(PlayerName2(playerid)).("vowner6",0);
dUserSetINT(PlayerName2(playerid)).("vowned7",0);
dUserSetINT(PlayerName2(playerid)).("vowner7",0);
dUserSetINT(PlayerName2(playerid)).("vowned8",0);
dUserSetINT(PlayerName2(playerid)).("vowner8",0);
dUserSetINT(PlayerName2(playerid)).("vowned9",0);
dUserSetINT(PlayerName2(playerid)).("vowner9",0);
dUserSetINT(PlayerName2(playerid)).("vowned10",0);
dUserSetINT(PlayerName2(playerid)).("vowner10",0);
dUserSetINT(PlayerName2(playerid)).("vowned11",0);
dUserSetINT(PlayerName2(playerid)).("vowner11",0);
dUserSetINT(PlayerName2(playerid)).("vowned12",0);
dUserSetINT(PlayerName2(playerid)).("vowner12",0);
dUserSetINT(PlayerName2(playerid)).("vowned13",0);
dUserSetINT(PlayerName2(playerid)).("vowner13",0);
dUserSetINT(PlayerName2(playerid)).("vowned14",0);
dUserSetINT(PlayerName2(playerid)).("vowner14",0);
dUserSetINT(PlayerName2(playerid)).("vowned15",0);
dUserSetINT(PlayerName2(playerid)).("vowner15",0);
dUserSetINT(PlayerName2(playerid)).("Houseid", -255);
dUserSetINT(PlayerName2(playerid)).("Rentid", -255);
dUserSetINT(PlayerName2(playerid)).("SpawnX", 0);
dUserSetINT(PlayerName2(playerid)).("SpawnY", 0);
dUserSetINT(PlayerName2(playerid)).("SpawnZ", 0);
dUserSetINT(PlayerName2(playerid)).("SpawnInt", 0);
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;
}
CMD:login(playerid,params[])
{
if (PlayerInfo[playerid][LoggedIn] == 1) return SendClientMessage(playerid,COLOR_RED,"ACCOUNT: You are already logged in.");
if (!udb_Exists(PlayerName2(playerid))) return SendClientMessage(playerid,COLOR_RED,"ACCOUNT: Account doesn't exist, please use '/register [password]'.");
if (strlen(params)==0) return SendClientMessage(playerid,COLOR_RED,"ACCOUNT: Correct usage: '/login [password]'");
if (udb_CheckLogin(PlayerName2(playerid),params))
{
new file[256], tmp3[100], string[128], lname[MAX_PLAYER_NAME];
GetPlayerName(playerid,lname,sizeof(lname));
format(file,sizeof(file),"/ladmin/users/%s.sav",udb_encode(lname));
GetPlayerIp(playerid,tmp3,100);
dini_Set(file,"ip",tmp3);
LoginPlayer(playerid);
LoadPlayer(playerid);
PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
if(PlayerInfo[playerid][Level] > 0) {
format(string,sizeof(string),"ACCOUNT: Successfully Logged In. (Level %d)", PlayerInfo[playerid][Level] );
return SendClientMessage(playerid,green,string);
} else return SendClientMessage(playerid,green,"ACCOUNT: Successfully Logged In");
}
return SendClientMessage(playerid,COLOR_RED,"ACCOUNT: Login failed! Incorrect Password");
}
LoginPlayer(playerid)
{
if(ServerInfo[SetScore] == 1) SetPlayerScore(playerid, dUserINT(PlayerName2(playerid)).("score") );
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][Level] = (dUserINT(PlayerName2(playerid)).("level"));
PlayerInfo[playerid][Registered] = 1;
PlayerInfo[playerid][LoggedIn] = 1;
}
PHP код:
LoadPlayer(playerid)
{
new playername[MAX_PLAYER_NAME],file[256];
GetPlayerName(playerid, playername, sizeof(playername));
format(file,256,"/ladmin/users/%s.sav",udb_encode(playername));
if(udb_Exists(PlayerName2(playerid))) {
PlayerInfo[playerid][name] = playername;
PlayerInfo[playerid][pcash] = (dUserINT(PlayerName2(playerid)).("Money"));
PlayerInfo[playerid][bank] = (dUserINT(PlayerName2(playerid)).("Bank"));
PlayerInfo[playerid][bowner] = (dUserINT(PlayerName2(playerid)).("bowner"));
PlayerInfo[playerid][bowned] = (dUserINT(PlayerName2(playerid)).("bowned"));
PlayerInfo[playerid][weed] = (dUserINT(PlayerName2(playerid)).("weed"));
PlayerInfo[playerid][gang] = (dUserINT(PlayerName2(playerid)).("Gang"));
PlayerInfo[playerid][condoms] = (dUserINT(PlayerName2(playerid)).("Condoms"));
PlayerInfo[playerid][inalcatraz] = (dUserINT(PlayerName2(playerid)).("inalcatraz"));
PlayerInfo[playerid][vowned] = (dUserINT(PlayerName2(playerid)).("vowned"));
PlayerInfo[playerid][vowner] = (dUserINT(PlayerName2(playerid)).("vowner"));
PlayerInfo[playerid][vowned2] = (dUserINT(PlayerName2(playerid)).("vowned2"));
PlayerInfo[playerid][vowner2] = (dUserINT(PlayerName2(playerid)).("vowner2"));
PlayerInfo[playerid][vowned3] = (dUserINT(PlayerName2(playerid)).("vowned3"));
PlayerInfo[playerid][vowner3] = (dUserINT(PlayerName2(playerid)).("vowner3"));
PlayerInfo[playerid][vowned4] = (dUserINT(PlayerName2(playerid)).("vowned4"));
PlayerInfo[playerid][vowner4] = (dUserINT(PlayerName2(playerid)).("vowner4"));
PlayerInfo[playerid][vowned5] = (dUserINT(PlayerName2(playerid)).("vowned5"));
PlayerInfo[playerid][vowner5] = (dUserINT(PlayerName2(playerid)).("vowner5"));
PlayerInfo[playerid][vowned6] = (dUserINT(PlayerName2(playerid)).("vowned6"));
PlayerInfo[playerid][vowner6] = (dUserINT(PlayerName2(playerid)).("vowner6"));
PlayerInfo[playerid][vowned7] = (dUserINT(PlayerName2(playerid)).("vowned7"));
PlayerInfo[playerid][vowner7] = (dUserINT(PlayerName2(playerid)).("vowner7"));
PlayerInfo[playerid][vowned8] = (dUserINT(PlayerName2(playerid)).("vowned8"));
PlayerInfo[playerid][vowner8] = (dUserINT(PlayerName2(playerid)).("vowner8"));
PlayerInfo[playerid][vowned9] = (dUserINT(PlayerName2(playerid)).("vowned9"));
PlayerInfo[playerid][vowner9] = (dUserINT(PlayerName2(playerid)).("vowner9"));
PlayerInfo[playerid][vowned10] = (dUserINT(PlayerName2(playerid)).("vowned10"));
PlayerInfo[playerid][vowner10] = (dUserINT(PlayerName2(playerid)).("vowner10"));
PlayerInfo[playerid][vowned11] = (dUserINT(PlayerName2(playerid)).("vowned11"));
PlayerInfo[playerid][vowner11] = (dUserINT(PlayerName2(playerid)).("vowner11"));
PlayerInfo[playerid][vowned12] = (dUserINT(PlayerName2(playerid)).("vowned12"));
PlayerInfo[playerid][vowner12] = (dUserINT(PlayerName2(playerid)).("vowner12"));
PlayerInfo[playerid][vowned13] = (dUserINT(PlayerName2(playerid)).("vowned13"));
PlayerInfo[playerid][vowner13] = (dUserINT(PlayerName2(playerid)).("vowner13"));
PlayerInfo[playerid][vowned14] = (dUserINT(PlayerName2(playerid)).("vowned14"));
PlayerInfo[playerid][vowner14] = (dUserINT(PlayerName2(playerid)).("vowner14"));
PlayerInfo[playerid][vowned15] = (dUserINT(PlayerName2(playerid)).("vowned15"));
PlayerInfo[playerid][vowner15] = (dUserINT(PlayerName2(playerid)).("vowner15"));
}
}
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)).("score",GetPlayerScore(playerid));
dUserSetINT(PlayerName2(playerid)).("money",GetPlayerMoney(playerid));
dUserSetINT(PlayerName2(playerid)).("kills",PlayerInfo[playerid][Kills]);
dUserSetINT(PlayerName2(playerid)).("deaths",PlayerInfo[playerid][Deaths]);
new h, m, s;
TotalGameTime(playerid, h, m, s);
dUserSetINT(PlayerName2(playerid)).("hours", h);
dUserSetINT(PlayerName2(playerid)).("minutes", m);
dUserSetINT(PlayerName2(playerid)).("seconds", s);
new Float:x,Float:y,Float:z, interior;
GetPlayerPos(playerid,x,y,z); interior = GetPlayerInterior(playerid);
dUserSetINT(PlayerName2(playerid)).("x1",floatround(x));
dUserSetINT(PlayerName2(playerid)).("y1",floatround(y));
dUserSetINT(PlayerName2(playerid)).("z1",floatround(z));
dUserSetINT(PlayerName2(playerid)).("interior1",interior);
new weap1, ammo1, weap2, ammo2, weap3, ammo3, weap4, ammo4, weap5, ammo5, weap6, ammo6;
GetPlayerWeaponData(playerid,2,weap1,ammo1);// hand gun
GetPlayerWeaponData(playerid,3,weap2,ammo2);//shotgun
GetPlayerWeaponData(playerid,4,weap3,ammo3);// SMG
GetPlayerWeaponData(playerid,5,weap4,ammo4);// AK47 / M4
GetPlayerWeaponData(playerid,6,weap5,ammo5);// rifle
GetPlayerWeaponData(playerid,7,weap6,ammo6);// rocket launcher
dUserSetINT(PlayerName2(playerid)).("weap1",weap1); dUserSetINT(PlayerName2(playerid)).("weap1ammo",ammo1);
dUserSetINT(PlayerName2(playerid)).("weap2",weap2); dUserSetINT(PlayerName2(playerid)).("weap2ammo",ammo2);
dUserSetINT(PlayerName2(playerid)).("weap3",weap3); dUserSetINT(PlayerName2(playerid)).("weap3ammo",ammo3);
dUserSetINT(PlayerName2(playerid)).("weap4",weap4); dUserSetINT(PlayerName2(playerid)).("weap4ammo",ammo4);
dUserSetINT(PlayerName2(playerid)).("weap5",weap5); dUserSetINT(PlayerName2(playerid)).("weap5ammo",ammo5);
dUserSetINT(PlayerName2(playerid)).("weap6",weap6); dUserSetINT(PlayerName2(playerid)).("weap6ammo",ammo6);
new Float:health; GetPlayerHealth(playerid, Float:health);
new Float:armour; GetPlayerArmour(playerid, Float:armour);
new year,month,day; getdate(year, month, day);
new strdate[20]; format(strdate, sizeof(strdate), "%d.%d.%d",day,month,year);
dUserSetINT(PlayerName2(playerid)).("health",floatround(health));
dUserSetINT(PlayerName2(playerid)).("armour",floatround(armour));
dini_Set(file,"LastOn",strdate);
dUserSetINT(PlayerName2(playerid)).("loggedin",0);
dUserSetINT(PlayerName2(playerid)).("TimesOnServer",(dUserINT(PlayerName2(playerid)).("TimesOnServer"))+1);
dUserSetINT(PlayerName2(playerid)).("Bank",PlayerInfo[playerid][bank]);
dUserSetINT(PlayerName2(playerid)).("bowner",PlayerInfo[playerid][bowner]);
dUserSetINT(PlayerName2(playerid)).("bowned",PlayerInfo[playerid][bowned]);
dUserSetINT(PlayerName2(playerid)).("weed",PlayerInfo[playerid][weed]);
dUserSetINT(PlayerName2(playerid)).("Gang",PlayerInfo[playerid][gang]);
dUserSetINT(PlayerName2(playerid)).("Condoms",PlayerInfo[playerid][condoms]);
dUserSetINT(PlayerName2(playerid)).("inalcatraz",PlayerInfo[playerid][inalcatraz]);
dUserSetINT(PlayerName2(playerid)).("vowned",PlayerInfo[playerid][vowned]);
dUserSetINT(PlayerName2(playerid)).("vowner",PlayerInfo[playerid][vowner]);
dUserSetINT(PlayerName2(playerid)).("vowned2",PlayerInfo[playerid][vowned2]);
dUserSetINT(PlayerName2(playerid)).("vowner2",PlayerInfo[playerid][vowner2]);
dUserSetINT(PlayerName2(playerid)).("vowned3",PlayerInfo[playerid][vowned3]);
dUserSetINT(PlayerName2(playerid)).("vowner3",PlayerInfo[playerid][vowner3]);
dUserSetINT(PlayerName2(playerid)).("vowned4",PlayerInfo[playerid][vowned4]);
dUserSetINT(PlayerName2(playerid)).("vowner4",PlayerInfo[playerid][vowner4]);
dUserSetINT(PlayerName2(playerid)).("vowned5",PlayerInfo[playerid][vowned5]);
dUserSetINT(PlayerName2(playerid)).("vowner5",PlayerInfo[playerid][vowner5]);
dUserSetINT(PlayerName2(playerid)).("vowned6",PlayerInfo[playerid][vowned6]);
dUserSetINT(PlayerName2(playerid)).("vowner6",PlayerInfo[playerid][vowner6]);
dUserSetINT(PlayerName2(playerid)).("vowned7",PlayerInfo[playerid][vowned7]);
dUserSetINT(PlayerName2(playerid)).("vowner7",PlayerInfo[playerid][vowner7]);
dUserSetINT(PlayerName2(playerid)).("vowned8",PlayerInfo[playerid][vowned8]);
dUserSetINT(PlayerName2(playerid)).("vowner8",PlayerInfo[playerid][vowner8]);
dUserSetINT(PlayerName2(playerid)).("vowned9",PlayerInfo[playerid][vowned9]);
dUserSetINT(PlayerName2(playerid)).("vowner9",PlayerInfo[playerid][vowner9]);
dUserSetINT(PlayerName2(playerid)).("vowned10",PlayerInfo[playerid][vowned10]);
dUserSetINT(PlayerName2(playerid)).("vowner10",PlayerInfo[playerid][vowner10]);
dUserSetINT(PlayerName2(playerid)).("vowned11",PlayerInfo[playerid][vowned11]);
dUserSetINT(PlayerName2(playerid)).("vowner11",PlayerInfo[playerid][vowner11]);
dUserSetINT(PlayerName2(playerid)).("vowned12",PlayerInfo[playerid][vowned12]);
dUserSetINT(PlayerName2(playerid)).("vowner12",PlayerInfo[playerid][vowner12]);
dUserSetINT(PlayerName2(playerid)).("vowned13",PlayerInfo[playerid][vowned13]);
dUserSetINT(PlayerName2(playerid)).("vowner13",PlayerInfo[playerid][vowner13]);
dUserSetINT(PlayerName2(playerid)).("vowned14",PlayerInfo[playerid][vowned14]);
dUserSetINT(PlayerName2(playerid)).("vowner14",PlayerInfo[playerid][vowner14]);
dUserSetINT(PlayerName2(playerid)).("vowned15",PlayerInfo[playerid][vowned15]);
dUserSetINT(PlayerName2(playerid)).("vowner15",PlayerInfo[playerid][vowner15]);
}
}
SORRY FOR TRIPLEPOSt LOL
EDIT FOUND THIS BUT I SCARY TO COPY
https://sampforum.blast.hk/showthread.php?tid=161209