SA-MP Forums Archive
Variable reset - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Variable reset (/showthread.php?tid=162539)



Variable reset - baske007 - 23.07.2010

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


Re: Variable reset - baske007 - 24.07.2010

-bump-
i really need this fast


Re: Variable reset - dice7 - 24.07.2010

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


Re: Variable reset - baske007 - 24.07.2010

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


Re: Variable reset - baske007 - 24.07.2010

//bump//