22.10.2015, 18:42
OnPlayerConnect:
-----------------------------------------------------------------------------------------
Код HTML:
mysql_format(MySQLCon, query, sizeof(query), "SELECT * FROM `players` WHERE `user` = '%e' LIMIT 1", GetName(playerid)); mysql_pquery(MySQLCon, query, "OnAccountCheck", "d", playerid);
Код HTML:
forward OnAccountCheck(playerid); public OnAccountCheck(playerid) { new string[228], rows = cache_num_rows(); if(rows) { cache_get_row(0, 2, pInfo[playerid][pPass], MySQLCon, 129); cache_get_field_content(0, "LastLogin", string), strmid(pInfo[playerid][pLastLogin], string, 0, 255, 255); //string..... ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"{EDDC57}Login",string,"Login","Cancel"); } else { //string..... ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_PASSWORD,"{FFFB80}Registration",string,"Register","Cancel"); } return 1; }
Код HTML:
if(dialogid == DIALOG_LOGIN) { if(!response) return Kick(playerid); if(!strcmp(PasswordHash(inputtext), pInfo[playerid][pPass], false)) { mysql_format(MySQLCon, query, sizeof(query), "SELECT * FROM `players` WHERE `user` = '%e' LIMIT 1", GetName(playerid)); mysql_pquery(MySQLCon, query, "OnPlayerLogin", "d", playerid); } }
Код HTML:
forward OnPlayerLogin(playerid); public OnPlayerLogin(playerid) { new rows = cache_num_rows(); if(rows) { pInfo[playerid][pID] = cache_get_field_content_int(0, "ID"); pInfo[playerid][pAdmin] = cache_get_field_content_int(0, "Admin"); pInfo[playerid][pHelper] = cache_get_field_content_int(0, "Helper"); pInfo[playerid][pMoney] = cache_get_field_content_int(0, "Money"); pInfo[playerid][pScore] = cache_get_field_content_int(0, "Score"); pInfo[playerid][pStatus] = cache_get_field_content_int(0, "Status"); pInfo[playerid][pReg] = cache_get_field_content_int(0, "Reg"); pInfo[playerid][pSex] = cache_get_field_content_int(0, "Sex"); pInfo[playerid][pAge] = cache_get_field_content_int(0, "Age"); pInfo[playerid][pMute] = cache_get_field_content_int(0, "Mute"); // ................. and so on } return 1; }