26.01.2015, 18:06
Tб tudo certo com meu sistema de registro e login de MYSQL?
Fiz olhando vбrios tutoriais e juntando partes, pq sempre tem uma nova versгo e tal e com ajuda do fуrum
Tб dando alguns warnings e tal, mas tб funcionando, sу queria saber se ta feito certo ou da melhor forma, qlqr melhoria me digam ai
CODIGO:
OnPlayerConnect
Ao responder o DIALOG login
OnLogin
OnplayerLogin
Avisos que estгo sendo dados:
No meu MYSQL.log
E qnd compila:
Aqui esses warnings como se nгo tive-se usando essas variaveis
Fiz olhando vбrios tutoriais e juntando partes, pq sempre tem uma nova versгo e tal e com ajuda do fуrum
Tб dando alguns warnings e tal, mas tб funcionando, sу queria saber se ta feito certo ou da melhor forma, qlqr melhoria me digam ai
CODIGO:
OnPlayerConnect
pawn Код:
//=============================================================================================================================================================
// login e registro 2
//=============================================================================================================================================================
new query[512], rows, fields;
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
mysql_format(ConnectMYSQL, query, sizeof(query), "SELECT * FROM `accounts` WHERE `Username` = '%s'", Nome(playerid) ); //SELECT * FROM accounts WHERE Name = %s TROQUE PELA QUAL ESTA NO SEU BANCO DE DADOS
mysql_function_query(ConnectMYSQL, query, true, "OnConnection","i",playerid);
// Agora em OnConnection use cache_get_field_content para pegar os dados e por em variaveis
// ou como quiser
//=============================================================================================================================================================
pawn Код:
if(dialogid == DIALOG_LOGIN)
{
if(!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Please enter a valid password!", "Please enter your valid logging in password\nTo continue press log-in\n\nOxiRegister 1.0\n", "Log-in", "Quit");
else
{
mysql_format(ConnectMYSQL, query, sizeof(query), "SELECT * FROM accounts WHERE Senha = '%e' LIMIT 0,1", inputtext);
mysql_pquery(ConnectMYSQL, query, "OnLogin", "d", playerid);
}
}
return 1;
}
pawn Код:
forward OnLogin(playerid);
public OnLogin(playerid)
{
new rows, fields;
cache_get_data(rows, fields);
if(rows)
{
OnPlayerLogin(playerid);
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Incorrect Password!", "Please enter a correct password in order to log-in\nPress log-in to continue", "Log-in", "Quit");
}
return 1;
}
pawn Код:
stock OnPlayerLogin(playerid)
{
new query[512], savestr[50], rows, fields;
mysql_format(ConnectMYSQL, query, sizeof(query), "SELECT * FROM `accounts` WHERE `Username` = '%s'", Nome(playerid) );
mysql_query(ConnectMYSQL,query);
cache_get_data(rows, fields);
if(rows)
{
new int_dest[33];
int_dest[0] = cache_get_field_content_int(0, "UserID"); pInfo[playerid][UserID] = int_dest[0];
int_dest[1] = cache_get_field_content_int(0, "scorelevel"); scorelevel[playerid] = int_dest[1];
int_dest[2] = cache_get_field_content_int(0, "maconha"); maconha[playerid] = int_dest[2];
int_dest[3] = cache_get_field_content_int(0, "sementes"); sementes[playerid] = int_dest[3];
int_dest[4] = cache_get_field_content_int(0, "BPsize"); BPsize[playerid] = int_dest[4];
int_dest[5] = cache_get_field_content_int(0, "wanted"); wanted[playerid] = int_dest[5];
int_dest[6] = cache_get_field_content_int(0, "moneybag"); moneybag[playerid] = int_dest[6];
int_dest[7] = cache_get_field_content_int(0, "COPskills"); COPskills[playerid] = int_dest[7];
int_dest[8] = cache_get_field_content_int(0, "CRIMINALskills"); CRIMINALskills[playerid] = int_dest[8];
int_dest[9] = cache_get_field_content_int(0, "PARAMEDICskills"); PARAMEDICskills[playerid] = int_dest[9];
int_dest[10] = cache_get_field_content_int(0, "admin"); admin[playerid] = int_dest[10];
int_dest[11] = cache_get_field_content_int(0, "money"); money[playerid] = int_dest[11];
int_dest[12] = cache_get_field_content_int(0, "bank"); bank[playerid] = int_dest[12];
int_dest[13] = cache_get_field_content_int(0, "kills"); kills[playerid] = int_dest[13];
int_dest[14] = cache_get_field_content_int(0, "deaths"); deaths[playerid] = int_dest[14];
int_dest[15] = cache_get_field_content_int(0, "DP"); DP[playerid] = int_dest[15];
int_dest[16] = cache_get_field_content_int(0, "VIP"); VIP[playerid] = int_dest[16];
int_dest[17] = cache_get_field_content_int(0, "fmembro"); fmembro[playerid] = int_dest[17];
int_dest[18] = cache_get_field_content_int(0, "fcargo"); fcargo[playerid] = int_dest[18];
int_dest[19] = cache_get_field_content_int(0, "preso"); preso[playerid] = int_dest[19];
int_dest[20] = cache_get_field_content_int(0, "presotime"); presotime[playerid] = int_dest[20];
int_dest[21] = cache_get_field_content_int(0, "startVIPdia"); startVIPdia[playerid] = int_dest[21];
int_dest[22] = cache_get_field_content_int(0, "startVIPmes"); startVIPmes[playerid] = int_dest[22];
int_dest[23] = cache_get_field_content_int(0, "startVIPano"); startVIPano[playerid] = int_dest[23];
int_dest[24] = cache_get_field_content_int(0, "carid"); carid[playerid] = int_dest[24];
int_dest[25] = cache_get_field_content_int(0, "spawnpoint"); spawnpoint[playerid] = int_dest[25];
int_dest[26] = cache_get_field_content_int(0, "housekey"); housekey[playerid] = int_dest[26];
int_dest[27] = cache_get_field_content_int(0, "tutorial"); tutorial[playerid] = int_dest[27];
int_dest[28] = cache_get_field_content_int(0, "idiom"); idiom[playerid] = int_dest[28];
int_dest[29] = cache_get_field_content_int(0, "banned"); banned[playerid] = int_dest[29];
int_dest[30] = cache_get_field_content_int(0, "leftBANdia"); leftBANdia[playerid] = int_dest[30];
int_dest[31] = cache_get_field_content_int(0, "leftBANmes"); leftBANmes[playerid] = int_dest[31];
int_dest[32] = cache_get_field_content_int(0, "leftBANano"); leftBANano[playerid] = int_dest[32];
Avisos que estгo sendo dados:
No meu MYSQL.log
pawn Код:
[16:28:29] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[16:28:29] [ERROR] cache_get_field_content_int - invalid datatype
Aqui esses warnings como se nгo tive-se usando essas variaveis
pawn Код:
(798) : warning 203: symbol is never used: "fields"
(798) : warning 203: symbol is never used: "rows"
pawn Код:
//=============================================================================================================================================================
// login e registro 2
//=============================================================================================================================================================
new query[512], rows, fields;