11.04.2014, 22:50
(
Последний раз редактировалось JacobEdwards; 12.04.2014 в 04:23.
)
Hello,
I am having a bit of trouble with my login system currently. Once the user registers they spawn and die. I was wondering if it could be how the server loads the account info, but if they logout and in they spawn perfectly. All the info gets inserted into the database perfectly as far as I can see.
OnAccountRegister:
OnAccountLoad:
OnAccountSpawn:
MySQL Log:
I am having a bit of trouble with my login system currently. Once the user registers they spawn and die. I was wondering if it could be how the server loads the account info, but if they logout and in they spawn perfectly. All the info gets inserted into the database perfectly as far as I can see.
OnAccountRegister:
pawn Код:
forward OnAccountRegister(playerid, password[]);
public OnAccountRegister(playerid, password[]) {
new query[1024]; // TODO: Fix to exact amount.
mysql_format(MySQLHandle, query, sizeof(query), "INSERT INTO `PlayerVariables` (`DBID`, `Username`, `Key`, `IP`, `Admin`, `Helper`, `VIP`, `Cash`, `Bank`, `Score`, `Model`, `Interior`, `VW`, `Health`, `Armour`, `PosX`, `PosY`, `PosZ`, `PosA`) VALUES ('0', '%e', '%e', '%e', '0', '0', '0', '250', '1500', '1', '299', '0', '0', '100', '0', '2065.18', '2556.71', '6.78895', '65.1539');", GetPlayerNameEx(playerid, "normal"), password, GetPlayerIpEx(playerid));
mysql_tquery(MySQLHandle, query, "", "");
SetTimerEx("OnAccountLoad", 2000, 0, "d", playerid);
printf("[Debug] OnAccountRegister called: [Username]: %s", PlayerData[playerid][pUsername]);
return 1;
}
pawn Код:
forward OnAccountLoad(playerid);
public OnAccountLoad(playerid) {
PlayerData[playerid][pLoggedIn] = 1;
PlayerData[playerid][pAdmin] = cache_get_row_int(0, 4);
PlayerData[playerid][pHelper] = cache_get_row_int(0, 5);
PlayerData[playerid][pVIP] = cache_get_row_int(0, 6);
PlayerData[playerid][pCash] = cache_get_row_int(0, 7);
PlayerData[playerid][pBank] = cache_get_row_int(0, 8);
PlayerData[playerid][pScore] = cache_get_row_int(0, 9);
PlayerData[playerid][pModel] = cache_get_row_int(0, 10);
PlayerData[playerid][pInterior] = cache_get_row_int(0, 11);
PlayerData[playerid][pVW] = cache_get_row_int(0, 12);
PlayerData[playerid][pHealth] = cache_get_row_float(0, 13);
PlayerData[playerid][pArmour] = cache_get_row_float(0, 14);
PlayerData[playerid][pPosX] = cache_get_row_float(0, 15);
PlayerData[playerid][pPosY] = cache_get_row_float(0, 16);
PlayerData[playerid][pPosZ] = cache_get_row_float(0, 17);
PlayerData[playerid][pPosA] = cache_get_row_float(0, 18);
SetTimerEx("OnAccountSpawn", 2000, 0, "d", playerid);
return 1;
}
pawn Код:
forward OnAccountSpawn(playerid);
public OnAccountSpawn(playerid) {
if(!PlayerData[playerid][pLoggedIn]) return Kick(playerid);
SetSpawnInfo(playerid, -1, PlayerData[playerid][pModel], PlayerData[playerid][pPosX], PlayerData[playerid][pPosY], PlayerData[playerid][pPosZ], PlayerData[playerid][pPosA], -1, -1, -1, -1, -1, -1);
SetPlayerInterior(playerid, PlayerData[playerid][pInterior]);
SetPlayerVirtualWorld(playerid, PlayerData[playerid][pVW]);
SetPlayerHealth(playerid, Float:PlayerData[playerid][pHealth]); // TODO: Update the gamemode with a anticheat health hack system.
SetPlayerArmour(playerid, Float:PlayerData[playerid][pArmour]);
SetPlayerScore(playerid, PlayerData[playerid][pScore]);
GivePlayerMoney(playerid, PlayerData[playerid][pCash]); // TODO: Update the gamemode with a anticheat money system.
SpawnPlayer(playerid);
return 1;
}
Код:
[18:52:25] [DEBUG] CMySQLQuery::Execute[OnAccountRetrieve] - starting query execution [18:52:25] [DEBUG] CMySQLQuery::Execute[OnAccountRetrieve] - query was successfully executed within 0.403 milliseconds [18:52:25] [DEBUG] CMySQLResult::CMySQLResult() - constructor called [18:52:25] [DEBUG] Calling callback "OnAccountRetrieve".. [18:52:25] [DEBUG] cache_get_row_count - connection: 1 [18:52:25] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called [18:52:29] [DEBUG] mysql_format - connection: 1, len: 1024, format: "INSERT INTO `PlayerVariables` (`DBID`, `Username`, `Key`, `IP`, `Admin`, `Helper`, `VIP`, `Cash`, `Bank`, `Score`, `Model`, `Int..." [18:52:29] [DEBUG] mysql_tquery - connection: 1, query: "INSERT INTO `PlayerVariables` (`DBID`, `Username`, `Key`, `IP`, ", callback: "(null)", format: "(null)" [18:52:29] [DEBUG] CMySQLQuery::Execute[] - starting query execution [18:52:29] [DEBUG] CMySQLQuery::Execute[] - query was successfully executed within 30.222 milliseconds [18:52:29] [DEBUG] CMySQLQuery::Execute[] - no callback specified, skipping result saving