forward LoadAccount(playerid);
public LoadAccount(playerid)
{
cache_get_row(0, 2, PlayerInfo[playerid][Password]);
cache_get_row(0, 3, PlayerInfo[playerid][pIp]);
PlayerInfo[playerid][pAge] = cache_get_row_int(0, 4);
cache_get_row(0, 5, PlayerInfo[playerid][pSex]);
cache_get_row(0, 6, PlayerInfo[playerid][pRace]);
PlayerInfo[playerid][pSkin] = cache_get_row_int(0, 7);
PlayerInfo[playerid][posx] = cache_get_row_float(0, 8);
PlayerInfo[playerid][posy] = cache_get_row_float(0, 9);
PlayerInfo[playerid][posz] = cache_get_row_float(0, 10);
return 1;
}
forward LoginPlayer(playerid);
public LoginPlayer(playerid)
{
new rows, fields;
cache_get_data(rows, fields);
if(rows)
{
//SCM(playerid, COLOR_RED, "Ran - Loginplayer");
TextDrawHideForPlayer(playerid, LoginRegister1);
TextDrawHideForPlayer(playerid, LoginRegister2);
TextDrawHideForPlayer(playerid, LoginRegister3);
TextDrawHideForPlayer(playerid, LoginRegister4);
TextDrawHideForPlayer(playerid, LoginRegister5);
TextDrawHideForPlayer(playerid, LoginRegister6);
TextDrawHideForPlayer(playerid, LoginRegister7);
TextDrawHideForPlayer(playerid, LoginRegister8);
format(msg, sizeof(msg), "~w~Welcome ~n~~y~ %s", GetNameEx(playerid));
GameTextForPlayer(playerid, msg, 5000, 1);
LoadAccount(playerid);
SpawnPlayer(playerid);
}
else
{
ShowDialog(playerid, Show:<Login>,DIALOG_STYLE_INPUT,"{08088A}Eastside Gaming Roleplay", "{FFFFFF}Welcome to {08088A}Eastside Gaming Roleplay. {FFFFFF}We {04B404}did {FFFFFF}find youe account in our database.\nPlease enter the password you have associated with this account.\nThat password was not the correct one.", "Login", "Quit");
}
return 1;
}
Dialog:Login(playerid, response, listitem, inputtext[])
{
if (response)
{
if(isnull(inputtext))
{
ShowDialog(playerid, Show:<Login>,DIALOG_STYLE_INPUT,"{08088A}Eastside Gaming Roleplay", "{FFFFFF}Welcome to {08088A}Eastside Gaming Roleplay. {FFFFFF}We {04B404}did {FFFFFF}find youe account in our database.\nPlease enter the password you have associated with this account.\nThat password was not the correct one.", "Login", "Quit");
}
new escapedPlayerName[MAX_PLAYER_NAME], escapepass[100];
mysql_real_escape_string(inputtext, escapepass);
mysql_real_escape_string(PlayerInfo[playerid][pName], escapedPlayerName);
format(query, sizeof(query), "SELECT * FROM `accounts` WHERE `name` = '%s' AND `password` = '%s' LIMIT 0,1", escapedPlayerName, escapepass);
mysql_function_query(handle, query, true, "LoginPlayer", "i", playerid);
}
else
{
Kick(playerid);
}
return 1;
}
[21:06:05] [ERROR] cache_get_row_int - invalid datatype
[21:06:05] [WARNING] CMySQLResult::GetRowData - invalid row ('0') or field index ('10')
[21:06:05] [ERROR] cache_get_row_float - invalid datatype
forward LoadAccount(playerid);
public LoadAccount(playerid)
{
cache_get_row(0, 1, PlayerInfo[playerid][Password]);
cache_get_row(0, 2, PlayerInfo[playerid][pIp]);
PlayerInfo[playerid][pAge] = cache_get_row_int(0, 3);
cache_get_row(0, 4, PlayerInfo[playerid][pSex]);
cache_get_row(0, 5, PlayerInfo[playerid][pRace]);
PlayerInfo[playerid][pSkin] = cache_get_row_int(0, 6);
PlayerInfo[playerid][posx] = cache_get_row_float(0, 7);
PlayerInfo[playerid][posy] = cache_get_row_float(0, 8);
PlayerInfo[playerid][posz] = cache_get_row_float(0, 9);
return 1;
}
The indexes in phpMyAdmin start from 1 but in PAWN start from 0. So you'll need to decrease it by 1 each one:
pawn Код:
|
That worked THANKS! But now the only thing loading is the ints, the strings aren't loading.
|
You have to provide the size (max_len) by yourself if you use an enum-array as destination. |
cache_get_row(0, 1, PlayerInfo[playerid][Password], .max_len = 256); cache_get_row(0, 2, PlayerInfo[playerid][pIp], .max_len = 32); //...
https://sampwiki.blast.hk/wiki/MySQL/R33#cache_get_row
That means you have to use Код:
cache_get_row(0, 1, PlayerInfo[playerid][Password], .max_len = 256); cache_get_row(0, 2, PlayerInfo[playerid][pIp], .max_len = 32); //... |
https://sampwiki.blast.hk/wiki/MySQL/R33#cache_get_row
That means you have to use Код:
cache_get_row(0, 1, PlayerInfo[playerid][Password], .max_len = 256); cache_get_row(0, 2, PlayerInfo[playerid][pIp], .max_len = 32); //... |
forward LoadAccount(playerid);
public LoadAccount(playerid)
{
cache_get_row(0, 1, PlayerInfo[playerid][Password], 128);
cache_get_row(0, 2, PlayerInfo[playerid][pIp], 44);
PlayerInfo[playerid][pAge] = cache_get_row_int(0, 3);
cache_get_row(0, 4, PlayerInfo[playerid][pSex], 7);
cache_get_row(0, 5, PlayerInfo[playerid][pRace], 22);
PlayerInfo[playerid][pSkin] = cache_get_row_int(0, 6);
PlayerInfo[playerid][posx] = cache_get_row_float(0, 7);
PlayerInfo[playerid][posy] = cache_get_row_float(0, 8);
PlayerInfo[playerid][posz] = cache_get_row_float(0, 9);
return 1;
}