The player dies upon registering
#1

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:
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;
}
OnAccountLoad:
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;
}
OnAccountSpawn:
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;
}
MySQL Log:
Код:
[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
Reply
#2

INSERT statements do not return resultsets. You're just setting all values to 0. This includes health, which results in the player's death. I don't even know why you'd need to reload the data that you just inserted. That just seems counter productive.
Reply
#3

Oh.. Wouldn't I still have to load the data though?
Reply
#4

Update: I feel really stupid for the mistake I made. I was attempting to load the data, but I was not submitting any query to load it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)