Variable reset
#1

Hello everyone,

I have a question for you guys.
If I have a gamemode with variables for every user. I don't use Pvars because they don't seem to work for me.
So, my script loads and saves the position into a mysql database.
I store the positions when loggin in in this format:
px[playerid] = field[0];
For example.
This system works fine. But when I quit samp, and reload it (without reloading the server) it doesnt seem to work anymore.
Here is my script that loads the position:
pawn Code:
public ContinueLogin(playerid)
{
    format(query, sizeof (query), "SELECT px, py, pz FROM players WHERE username='%s'", playername[playerid]);
    mysql_query(query);
    mysql_store_result();
    while (mysql_fetch_row(data, "|"))
    {
        split(data, field, '|');
    }
    mysql_free_result();
    px[playerid] = strval(field[0]);
    py[playerid] = strval(field[1]);
    pz[playerid] = strval(field[2]);
   
    if (strval(pstatus[playerid]) == 1)
    {
        StartTutorial(playerid);
    }
    else
    {
        ploggedin[playerid] = 1;
        TogglePlayerSpectating(playerid, 0);
        SetPlayerPos(playerid, px[playerid], py[playerid], pz[playerid]);
    }
    return 1;
}
This funtion is called after some other steps like login/register.
So when I reload samp, and I want to login, I jsut get the <<<, >> and Spawn buttons. Should I reset the variables or something? It's really frustrating :S

Thanks so far
Reply
#2

-bump-
i really need this fast
Reply
#3

use SpawnPlayer(playerid); to force the player to spawn and then set his pos
Reply
#4

Thank you, now spawning works everytime, when I have restarted the server.
So:
When I start server, and start samp, I spawn correctly.
When I restart the server, I spawn correctly again
When I only restart samp without restarting the server, I spawn at the default spawn place. So is there a function or something to reset the px[playerid] variable?

Thanks so far
Reply
#5

//bump//
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)