SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 23/07/2010, 10:04 PM   #1
baske007
Big Clucker
 
Join Date: Apr 2010
Location: Netherlands
Posts: 78
Reputation: 0
Default Variable reset

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
baske007 is offline  
Old 24/07/2010, 09:23 AM   #2
baske007
Big Clucker
 
Join Date: Apr 2010
Location: Netherlands
Posts: 78
Reputation: 0
Default Re: Variable reset

-bump-
i really need this fast
baske007 is offline  
Old 24/07/2010, 09:37 AM   #3
dice7
High-roller
 
Join Date: Apr 2009
Location: Slovenia
Posts: 2,200
Reputation: 22
Default Re: Variable reset

use SpawnPlayer(playerid); to force the player to spawn and then set his pos
dice7 is offline  
Old 24/07/2010, 11:40 AM   #4
baske007
Big Clucker
 
Join Date: Apr 2010
Location: Netherlands
Posts: 78
Reputation: 0
Default Re: Variable reset

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
baske007 is offline  
Old 24/07/2010, 12:18 PM   #5
baske007
Big Clucker
 
Join Date: Apr 2010
Location: Netherlands
Posts: 78
Reputation: 0
Default Re: Variable reset

//bump//
baske007 is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 05:18 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.