23.04.2012, 21:11
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { if(dialogid == 14600) { if(response) { if(!strlen(inputtext) && strlen(inputtext) >= 4) { ShowPlayerDialog(playerid, 14600, DIALOG_STYLE_INPUT , "Register", "This account is not registered, please register!", "OK", "Cancel"); return SendClientMessage(playerid, 0xF60000AA, "Please enter a password with a minimun size of 4 characters."); } mysql_real_escape_string(inputtext, escpass); WP_Hash(largestring, sizeof(largestring), escpass); GetPlayerIp(playerid, PIP, 50); format(Query, sizeof(Query), "INSERT INTO `playerinfo` (`user`, `password`, `kills`, `deaths`, `score`, `money`, `IP`, `adminlvl`) VALUES ('%s', '%s', 0, 0, 0, 0, '%s', 0)", escpname(playerid), largestring, PIP); mysql_query(Query); GameTextForPlayer(playerid, "~g~Registered", 2000, 3); SendClientMessage(playerid, 0x0000D9AA, "Registered and Logged into your account!"); SetPVarInt(playerid, "Logged", 1); } } if(dialogid == 15000) { if(response) { WP_Hash(largestring, sizeof(largestring), inputtext); format(Query, sizeof(Query), "SELECT * FROM `playerinfo` WHERE `user` = '%s' AND `password` = '%s' LIMIT 1", escpname(playerid), largestring); mysql_query(Query); mysql_store_result(); new rows = mysql_num_rows(); if(!rows) { SendClientMessage(playerid, 0xF60000AA, "Invalid password!"); SetPVarInt(playerid, "WrongPass", GetPVarInt(playerid, "WrongPass") + 1); ShowPlayerDialog(playerid, 15000, DIALOG_STYLE_INPUT , "Login", "This account is registered, please login", "OK", "Cancel"); if(GetPVarInt(playerid, "WrongPass") == 3) { SendClientMessage(playerid, 0xF60000AA, "Max password tries exceeded!!"); Kick(playerid); } mysql_free_result(); } else if(rows > 0) { if(mysql_fetch_row(line)) { new data[3][55]; new data2[5]; sscanf(line, "p<|>s[50]s[300]dddds[50]ds[100]", data[0], largestring, data2[0], data2[1], data2[2], data2[3], data[2], data2[4], estring); stringempty(estring); stringempty(largestring); SetPVarInt(playerid, "Kills", data2[0]); SetPVarInt(playerid, "Logged", 1); SetPVarInt(playerid, "Deaths", data2[1]); SetPlayerScore(playerid, data2[2]); GivePlayerMoney(playerid, data2[3]); SetPVarInt(playerid, "AdminLevel", data2[4]); SendClientMessage(playerid, 0x0000D9AA, "Logged in!"); mysql_free_result(); GetPlayerIp(playerid, PIP, 18); format(Query, sizeof(Query), "UPDATE `playerinfo` SET IP = '%s' WHERE user='%s'", PIP, escpname(playerid)); mysql_query(Query); } } } } return 1; }