02.02.2011, 10:31
Код:
LoginPlayer(playerid, password[]) { GetPlayerName(playerid, Name, sizeof(Name)); if(!AccountExists[playerid]) return SendClientMessage(playerid, COLOR_RED, "You're not registered!"); if(PlayerLogged[playerid]) return SendClientMessage(playerid, COLOR_RED, "You're already logged in!"); if(strlen(password) < 3 || strlen(password) >= 32) return SendClientMessage(playerid, COLOR_RED, "Your password is too short or too long!"); CheckMySQL(); new string[128]; format(string, sizeof(string), "SELECT * FROM Users WHERE Name = '%s' AND Password = '%s'", Name, password); mysql_query(string); mysql_store_result(); if(!mysql_num_rows()) return SendClientMessage(playerid, COLOR_RED, "Incorrect password."); new query[512]; GetPlayerName(playerid, Name, sizeof(Name)); format(query, sizeof(query), "SELECT * FROM stats WHERE Name='%s'", Name); mysql_query(query); mysql_store_result(); new row[128]; new field[13][32]; mysql_fetch_row_format(row, "|"); explode(row, field, "|"); mysql_free_result(); Money[playerid] = strval(field[1]); skin[playerid] = strval(field[2]); X[playerid] = strval(field[3]); Y[playerid] = strval(field[4]); Z[playerid] = strval(field[5]); Ang[playerid] = strval(field[6]); dlic[playerid] = strval(field[7]); pin[playerid] = strval(field[8]); cc[playerid] = strval(field[9]); admin[playerid] = strval(field[10]); GivePlayerMoney(playerid, Money[playerid]); format(query, sizeof(query), "SELECT * FROM orgs WHERE NAME='%s'",Name); mysql_query(query); mysql_store_result(); mysql_fetch_row_format(row, "|"); explode(row, field, "|"); mysql_free_result(); IsLaw[playerid] = strval(field[8]); format(string, sizeof(string), "{A9C4E4}Thank you, you have logged in and your stats have been restored.", Name); SendClientMessage(playerid, 0x6666FFFF, string); PlayerLogged[playerid] = 1; LoadVeh(playerid); return 1; }