SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 07/02/2014, 04:42 PM   #21
Ramms
Little Clucker
 
Join Date: Nov 2011
Posts: 1
Reputation: 0
Post Re: Save, load and set player position - using y_ini

i have this working but when i restart the server the coords do not load it spawns me at 0,0,0
pawn Code:
public OnPlayerDisconnect(playerid, reason)
{
    if(IsPlayerLoggedIn[playerid] == 1)
    {
        new INI:iFile = INI_Open(PlayerPath(playerid));
        INI_SetTag(iFile,"data");
        GetPlayerPos(playerid, PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ]);
        GetPlayerFacingAngle( playerid, PlayerInfo[playerid][pAngle]);
        INI_SetTag(iFile, "position");
        INI_WriteFloat(iFile,"PositionX",PlayerInfo[playerid][pPosX]);
        INI_WriteFloat(iFile,"PositionY",PlayerInfo[playerid][pPosY]);
        INI_WriteFloat(iFile,"PositionZ",PlayerInfo[playerid][pPosZ]);
        INI_WriteFloat(iFile,"Angle",PlayerInfo[playerid][pAngle]);
        INI_WriteInt(iFile,"Interior",GetPlayerInterior(playerid));
        INI_WriteInt(iFile,"VirtualWorld",GetPlayerVirtualWorld(playerid));
        INI_Close(iFile);
    }
    return 1;
}

public UserDataLoad_data(playerid,name[],value[]) {
    INI_Int("Pass",PlayerInfo[playerid][pPass]);
    #if defined AUTOLOGIN
        INI_String("IP",pIP[playerid],16);
    #endif
    INI_Float("PositionX",PlayerInfo[playerid][pPosX]);
    INI_Float("PositionY",PlayerInfo[playerid][pPosY]);
    INI_Float("PositionZ",PlayerInfo[playerid][pPosZ]);
    INI_Float("Angle",PlayerInfo[playerid][pAngle]);
    INI_Int("Interior",PlayerInfo[playerid][pInterior]);
    INI_Int("VirtualWorld",PlayerInfo[playerid][pVirtualWorld]);
   
    return 1;
}

public SkipSpawn(playerid)
{
    if(PlayerInfo[playerid][pReg] == 1)
    {
        SetSpawnInfo( playerid, 0, 0, PlayerInfo[playerid][pPosX],PlayerInfo[playerid][pPosY],PlayerInfo[playerid][pPosZ],PlayerInfo[playerid][pAngle], 0, 0, 0, 0, 0, 0 );
        SetPlayerInterior( playerid, PlayerInfo[playerid][pInterior]);
        SetPlayerVirtualWorld( playerid, PlayerInfo[playerid][pVirtualWorld]);
        SpawnPlayer(playerid);
        SendClientMessage( playerid, -1, "welcome to your last position" );
    }
    else if(PlayerInfo[playerid][pReg] == 0)
    {
        SetSpawnInfo( playerid, 0, 0, -2764.9766,375.4572,6.3430,271.0806, 0, 0, 0, 0, 0, 0 );
        SpawnPlayer(playerid);
    }
    return 1;
}
Ramms is offline   Reply With Quote
Old 05/04/2014, 12:13 PM   #22
xPirate
Little Clucker
 
xPirate's Avatar
 
Join Date: Aug 2013
Posts: 39
Reputation: 0
Default Re: Save, load and set player position - using y_ini

BUMP Same problem !
__________________
New Extreme-Stunting v3.0 coming soon!
xPirate is offline   Reply With Quote
Old 05/04/2014, 01:18 PM   #23
biker122
Gangsta
 
Join Date: Feb 2014
Posts: 775
Reputation: 59
Default Re: Save, load and set player position - using y_ini

I believe that It won't be saved when it's a server restart. (START/STOP). Try to quit the game and join again.
__________________
k
biker122 is offline   Reply With Quote
Old 05/04/2014, 02:26 PM   #24
xPirate
Little Clucker
 
xPirate's Avatar
 
Join Date: Aug 2013
Posts: 39
Reputation: 0
Default Re: Save, load and set player position - using y_ini

EDIT: Fixed & working with different code !
__________________
New Extreme-Stunting v3.0 coming soon!

Last edited by xPirate; 05/04/2014 at 04:04 PM.
xPirate is offline   Reply With Quote
Old 20/06/2017, 03:39 PM   #25
GrandTA
Little Clucker
 
GrandTA's Avatar
 
Join Date: Mar 2017
Location: IRAN
Posts: 20
Reputation: 0
Default Re: Save, load and set player position - using y_ini

Thanks Man Its Works +rep
GrandTA is offline   Reply With Quote
Old 16/07/2017, 03:46 PM   #26
2xRichard
Little Clucker
 
2xRichard's Avatar
 
Join Date: Jul 2017
Location: IRAN
Posts: 4
Reputation: 0
Question Re: Save, load and set player position - using y_ini

Hey i server restarting , it not work and not load players pos !
Spawn all players to x0 y0 z0 !
can you help ?

Last edited by 2xRichard; 16/07/2017 at 04:48 PM.
2xRichard is offline   Reply With Quote
Old 19/07/2018, 07:57 AM   #27
beastmaster
Little Clucker
 
Join Date: May 2018
Location: India
Posts: 4
Reputation: 0
Default Re: Save, load and set player position - using y_ini

Hi, i am newbie to scripting and i used your script to make a FS and it compiled without any error and loaded too... and when i discconects it saves my location but when i connect it spawns me at the default position. can anyone tell what's the problem?
beastmaster is offline   Reply With Quote
Old 19/07/2018, 08:51 AM   #28
CodeStyle175
Huge Clucker
 
CodeStyle175's Avatar
 
Join Date: Apr 2014
Posts: 470
Reputation: 35
Default Re: Save, load and set player position - using y_ini

when you really want to use this system, just create timer what saves player positsion after every minute.
CodeStyle175 is offline   Reply With Quote
Old 21/07/2018, 04:02 AM   #29
WilliamVN
Little Clucker
 
Join Date: Jul 2018
Posts: 3
Reputation: 0
Default Re: Save, load and set player position - using y_ini

Very Nice
WilliamVN is offline   Reply With Quote
Old 21/07/2018, 04:19 AM   #30
DerickClark
High-roller
 
Join Date: Jul 2012
Posts: 1,763
Reputation: 14
Default Re: Save, load and set player position - using y_ini

Quote:
Originally Posted by CodeStyle175 View Post
when you really want to use this system, just create timer what saves player positsion after every minute.
False. You save it on OnPlayerDisconnect. What if you want to leave the server but won't save?
Something went wrong with your saving?
__________________
Working on a Trucking Server from scratch.
There are cool features, like /workmenu /convoy /pay(When Police Officer asked you for a fine) and more etc.

Last edited by DerickClark; 21/07/2018 at 08:31 AM.
DerickClark is online now   Reply With Quote
Reply

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Include] Player Inventory System 0.2b (Menu + Save / Load) -zriptarusk Filterscripts 37 24/01/2014 07:08 PM
I need help! pls! /s and /r or /l script or fs save position and load position ProdrifterX Scripting Help 2 14/10/2011 04:02 PM
Save & Load position anumaz Help Archive 4 16/07/2011 03:26 AM
save player position ! dorperez Help Archive 2 19/01/2011 03:27 PM
[FilterScript] [FS] Position Saver (dynamic position save system) Nero_3D Filterscripts 13 20/08/2010 06:02 PM


All times are GMT. The time now is 09:34 PM.


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