Cannot spawn player
#1

Anyone know this problem ?

When player after insert password at Login screen.

It cannot spawn the player.
But when from stock firstPlayerSpawn from Register screen.
It can spawn . . .

This my script. . .

pawn Код:
public OnQueryFinish(query[], resultid, extraid, connectionHandle) {
    new result[256];
    switch(resultid) {
        case THREAD_CHECK_CREDENTIALS: {
            mysql_store_result();
            if(mysql_num_rows() == 0) { // INCORRECT PASSWORD!1
                SetPVarInt(extraid, "WP", GetPVarInt(extraid, "WP") + 1);
                if(GetPVarInt(extraid, "WP") > 3) {
                    SendClientMessage(extraid, COLOR_GREY, "Auto Kick. Reason: Wrong insert password");
                    KickWithMessage(extraid);
                }
                else {
                    ShowPlayerDialog(extraid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "SERVER: Login", "Wrong password.\n\nYour account has been registered, Please enter your password!", "Login", "Cancel");
                }
            }
            else {
                DeletePVar(extraid, "WP");

                mysql_retrieve_row();

                mysql_get_field("playerID", result);
                PlayerInfo[extraid][pID] = strval(result);

                mysql_get_field("playerLevel", result);
                PlayerInfo[extraid][pLevel] = strval(result);

                mysql_get_field("playerMoney", result);
                PlayerInfo[extraid][pCash] = strval(result);

                mysql_get_field("playerHealth", result);
                PlayerInfo[extraid][pHealth] = floatstr(result);

                mysql_get_field("playerArmor", result);
                PlayerInfo[extraid][pArmor] = floatstr(result);

                mysql_get_field("playerPosX", result);
                PlayerInfo[extraid][pPos][0] = floatstr(result);

                mysql_get_field("playerPosY", result);
                PlayerInfo[extraid][pPos][1] = floatstr(result);

                mysql_get_field("playerPosZ", result);
                PlayerInfo[extraid][pPos][2] = floatstr(result);

                mysql_get_field("playerPosAngle", result);
                PlayerInfo[extraid][pPos][3] = floatstr(result);

                PlayerInfo[extraid][pLogin] = 1;

                if(PlayerInfo[extraid][pRegister] == 0)
                {
                    SetPlayerPos(extraid,1716.1129,-1880.0715,-10.0);
                    SetPlayerCameraPos(extraid,1755.0413,-1824.8710,20.2100);
                    SetPlayerCameraLookAt(extraid,1716.1129,-1880.0715,22.0264);
                    ShowPlayerDialog(extraid, TUT, DIALOG_STYLE_LIST, "Gender Your char ?", "Male\nFemale", "Choose", "Exit");
                    return 1;
                }
                SetSpawnInfo(extraid, 0, PlayerInfo[extraid][pSkin], PlayerInfo[extraid][pPos][0], PlayerInfo[extraid][pPos][1], PlayerInfo[extraid][pPos][2], PlayerInfo[extraid][pPos][3], 0, 0, 0, 0, 0, 0);
                SpawnPlayer(extraid);
                SetPlayerScore(extraid, PlayerInfo[extraid][pLevel]);
                GivePlayerMoney(extraid, PlayerInfo[extraid][pCash]);
                SetPlayerWeapons(extraid);
                SetPlayerHealth(extraid, PlayerInfo[extraid][pHealth]);
                SetPlayerArmour(extraid, PlayerInfo[extraid][pArmor]);
            }
        }
    }
    return 1;
}
This Login screen script. . .

pawn Код:
if(dialogid == DIALOG_LOGIN) {
        if(!response) return Kick(playerid);
        if(response) {
            new escapedPassword[129], szPlayerName[MAX_PLAYER_NAME], querySz[300];
            GetPlayerName(playerid, szPlayerName, MAX_PLAYER_NAME);
            WP_Hash(escapedPassword, sizeof(escapedPassword), inputtext);
            format(querySz, sizeof(querySz), "SELECT * FROM `playerdata` WHERE `playerName` = '%s' AND `playerPassword` = '%s'", szPlayerName, escapedPassword);
            mysql_query(querySz, THREAD_CHECK_CREDENTIALS, playerid);
            mysql_free_result();
        }
    }
I'm using MYSQL database. . .
Anyone can help this problem ? ? ?
Reply
#2

you could try forcing the player to spawn with SpawnPlayer(playerid);
Reply
#3

In case PlayerInfo[extraid][pRegister] is 0, it will return a value and the rest of the code (which spawns the players) won't be executed.
pawn Код:
if(PlayerInfo[extraid][pRegister] == 0)
{
    SetPlayerPos(extraid,1716.1129,-1880.0715,-10.0);
    SetPlayerCameraPos(extraid,1755.0413,-1824.8710,20.2100);
    SetPlayerCameraLookAt(extraid,1716.1129,-1880.0715,22.0264);
    ShowPlayerDialog(extraid, TUT, DIALOG_STYLE_LIST, "Gender Your char ?", "Male\nFemale", "Choose", "Exit");
    return 1;
}
In fact, you don't even need that if statement because if the player gets the dialog to login, that means that he's already registered.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)