27.11.2009, 02:39
Код:
dcmd_register(playerid,params[]) { new name[90]; GetPlayerName(playerid,name,sizeof(name)); if (Stats[playerid][aLogged] == 1) return SendClientMessage(playerid,COLOR_RED,"You are logged in!"); if (udb_Exists(name)) return SendClientMessage(playerid,COLOR_RED,"This account already exists, please login."); if (strlen(params) == 0) return SendClientMessage(playerid,COLOR_RED,"USAGE: /register <password>"); if (udb_Create(name,params)) { new file[256],ip[100],tmp[260]; GetPlayerName(playerid,name,sizeof(name)); format(file,sizeof(file),"%s.ini",udb_encode(name)); GetPlayerIp(playerid,ip,100); dini_Set(file,"ip",tmp); dUserSetINT(name).("ALvl",0); dUserSetINT(name).("Money",0); dUserSetINT(name).("Kills",0); dUserSetINT(name).("Deaths",0); Stats[playerid][aLogged] = 1; SendClientMessage(playerid,COLOR_GREEN, "You have been registered and logged in."); PlayerPlaySound(playerid,1057,0.0,0.0,0.0); return 1; } return 1; } dcmd_login(playerid,params[]) { new name[90]; GetPlayerName(playerid,name,sizeof(name)); if (Stats[playerid][aLogged] == 1) return SendClientMessage(playerid,COLOR_RED,"You are already logged in."); if (!udb_Exists(name)) return SendClientMessage(playerid,COLOR_RED,"Account doesn't exist, please use '/register [password]'."); if (strlen(params)==0) return SendClientMessage(playerid,COLOR_RED,"Usage: login <password>"); if (udb_CheckLogin(name,params)) { new file[256], tmp3[100]; format(file,sizeof(file),"%s.ini",udb_encode(name)); GetPlayerIp(playerid,tmp3,100); dini_Set(file,"ip",tmp3); Login(playerid); SendClientMessage(playerid,COLOR_GREEN,"ACCOUNT: Successfully Logged In"); } else { return SendClientMessage(playerid,COLOR_RED,"Login failed! Incorrect Password."); } return 1; }
Код:
stock Save(playerid) { new name[90]; GetPlayerName(playerid,name,sizeof(name)); dUserSetINT(name).("Money",GetPlayerMoney(playerid)); dUserSetINT(name).("Kills",Stats[playerid][Kills]); dUserSetINT(name).("Deaths",Stats[playerid][Deaths]); dUserSetINT(name).("ALvl",Stats[playerid][ALvl]); dUserSetINT(name).("Banned",Stats[playerid][Banned]); dUserSetINT(name).("BankCash",Stats[playerid][BankCash]); dUserSetINT(name).("Arrests",Stats[playerid][Arrests]); dUserSetINT(name).("Robberies",Stats[playerid][Robberies]); dUserSetINT(name).("Drugs",Stats[playerid][Drugs]); new file[256]; format(file,sizeof(file),"%s.dudb.sav",udb_encode(name)); } stock Login(playerid) { new name[90]; GetPlayerName(playerid,name,sizeof(name)); ResetPlayerMoney(playerid); GivePlayerMoney(playerid, dUserINT(name).("Money")); Stats[playerid][Deaths] = dUserINT(name).("Deaths"); Stats[playerid][Kills] = dUserINT(name).("Kills"); Stats[playerid][ALvl] = dUserINT(name).("ALvl"); Stats[playerid][Banned] = dUserINT(name).("Banned"); Stats[playerid][BankCash] = dUserINT(name).("BankCash"); Stats[playerid][Arrests] = dUserINT(name).("Arrests"); Stats[playerid][Robberies] = dUserINT(name).("Robberies"); Stats[playerid][Drugs] = dUserINT(name).("Drugs"); }