17.05.2013, 08:38
here is the register and login thing...
Код:
stock RegisterPlayer(playerid, password[]) { new query[500],name[50],Float:x,Float:y,Float:z,rand,hashpass[200]; WP_Hash(hashpass,sizeof(hashpass),password); GetPlayerName(playerid,name,sizeof(name)); rand = randomEx(1000,9999); GetPlayerPos(playerid,x,y,z); format(query,sizeof(query),"INSERT INTO `USERS`(`Name`,`Password`,`LoggedIn`,`Level`,`Admin`,`VIP`,`Money`,`Score`,`Death`,`Number`) VALUES('%s','%s','1','0','0','0','30000','0','0','%d')",DB_Escape(name),DB_Escape(hashpass),rand); db_query(users,query); pinfo[playerid][level] = 0; pinfo[playerid][admin] = 0; pinfo[playerid][vip] = 0; pinfo[playerid][money] = 30000; pinfo[playerid][score] = 0; pinfo[playerid][death] = 0; pinfo[playerid][number] = rand; SendClientMessage(playerid,-1,"Succesfully Registered! ENJOY!!"); SetTimerEx("Refresh", 5000, true, "i", playerid); return 1; } stock LoginPlayer(playerid, password[]) { new query[500],name[50],hashpass[200],DBResult:res,str1[3],str2[3],str3[3],str4[3],str5[3],str6[3],str7[3]; WP_Hash(hashpass,sizeof(hashpass),password); GetPlayerName(playerid,name,sizeof(name)); format(query,sizeof(query),"UPDATE `USERS` SET `LoggedIn` = '1' WHERE `Name` = '%s'",DB_Escape(name),DB_Escape(hashpass)); db_query(users,query); format(query,sizeof(query),"SELECT * FROM `USERS` WHERE `Name` = '%s' AND `Password` = '%s'",DB_Escape(name),DB_Escape(hashpass)); res = db_query(users,query); if(db_num_rows(res)) { db_get_field_assoc(res,"Level",str1,3); db_get_field_assoc(res,"Admin",str2,3); db_get_field_assoc(res,"VIP",str3,3); db_get_field_assoc(res,"Money",str4,9); db_get_field_assoc(res,"Score",str5,3); db_get_field_assoc(res,"Death",str6,3); db_get_field_assoc(res,"Number",str7,3); pinfo[playerid][level] = strval(str1); pinfo[playerid][admin] = strval(str2); pinfo[playerid][vip] = strval(str3); pinfo[playerid][money] = strval(str4); pinfo[playerid][score] = strval(str5); pinfo[playerid][death] = strval(str6); pinfo[playerid][number] = strval(str7); printf("///////////LOGIN//////////"); printf("%d",pinfo[playerid][admin]); printf("%d",pinfo[playerid][vip]); printf("%d",pinfo[playerid][money]); printf("%d",pinfo[playerid][score]); SetPlayerMoney(playerid,pinfo[playerid][money]); SetPlayerScore(playerid,pinfo[playerid][score]); SendClientFormattedMessage(playerid,-1,"Successfully logged in!"); } else { SendClientMessage(playerid,-1,"Incorrect password! Please retry!!"); ShowPlayerDialog(playerid,LOGINDIALOG, DIALOG_STYLE_PASSWORD, "Login", "Enter your password below:", "Login!", "Kick!"); } db_free_result(res); SetTimerEx("Refresh", 5000, true, "i", playerid); return 1; }