SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 25/07/2018, 09:59 AM   #31
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 Derick,
Can you help me? Actually the FS is working fine and when I left the server it saves the coords in the file but when I log in it spawns me at my default location

I will be thankful if u can help me
beastmaster is offline   Reply With Quote
Old 26/07/2018, 07:56 AM   #32
DerickClark
High-roller
 
Join Date: Jul 2012
Posts: 1,762
Reputation: 14
Default Re: Save, load and set player position - using y_ini

Quote:
Originally Posted by beastmaster View Post
Hi Derick,
Can you help me? Actually the FS is working fine and when I left the server it saves the coords in the file but when I log in it spawns me at my default location

I will be thankful if u can help me
What does it print out?
__________________
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.
DerickClark is offline   Reply With Quote
Old 26/07/2018, 12:38 PM   #33
beastmaster
Little Clucker
 
Join Date: May 2018
Location: India
Posts: 4
Reputation: 0
Default Re: Save, load and set player position - using y_ini

Quote:
what does it print out?
this is how FS looks

Quote:
#include <a_samp>
#include <YSI\y_ini>

new
Float: PosX[ MAX_PLAYERS ],
Float: PosY[ MAX_PLAYERS ],
Float: PosZ[ MAX_PLAYERS ],
Float: Angle[ MAX_PLAYERS ],
Interior[ MAX_PLAYERS ],
VirtualWorld[ MAX_PLAYERS ]
;

stock user_ini_file(playerid)
{
new
string[ 128 ],
user_name[ MAX_PLAYER_NAME ]
;

GetPlayerName( playerid, user_name, MAX_PLAYER_NAME );
format( string, sizeof ( string ), "%s.ini", user_name );
/* scriptfiles directory */
return
string;
}

forward @load_user_position( playerid, name[], value[] );

@load_user_position( playerid, name[], value[] )
{
INI_Float( "PositionX", PosX[ playerid ] );
INI_Float( "PositionY", PosY[ playerid ] );
INI_Float( "PositionZ", PosZ[ playerid ] );
INI_Float( "Angle", Angle[ playerid ] );
INI_Int( "Interior", Interior[ playerid ] );
INI_Int( "VirtualWorld", VirtualWorld[ playerid ] );
return ( 1 );
}

public OnPlayerDisconnect( playerid, reason )
{
GetPlayerPos( playerid, PosX[ playerid ], PosY[ playerid ], PosZ[ playerid ] );
GetPlayerFacingAngle( playerid, Angle[ playerid ] );

new INI:File = INI_Open( user_ini_file( playerid ) );
INI_SetTag( File, "position" );
INI_WriteFloat( File, "PositionX", PosX[ playerid ] );
INI_WriteFloat( File, "PositionY", PosY[ playerid ] );
INI_WriteFloat( File, "PositionZ", PosZ[ playerid ] );
INI_WriteFloat( File, "Angle", Angle[ playerid ] );
INI_WriteInt( File, "Interior", GetPlayerInterior( playerid ) );
INI_WriteInt( File, "VirtualWorld", GetPlayerVirtualWorld( playerid ) );
INI_Close( File );
return ( 1 );
}

public OnPlayerConnect( playerid )
{
PosX[ playerid ] = 0;
PosY[ playerid ] = 0;
PosZ[ playerid ] = 0;
Angle[ playerid ] = 0;
Interior[ playerid ] = 0;
VirtualWorld[ playerid ] = 0;

INI_ParseFile( user_ini_file( playerid ), "load_user_%s", .bExtra = true, .extra = playerid );
return ( 1 );
}


public OnPlayerSpawn( playerid )
{
if ( PosX[ playerid ] != 0 && PosY[ playerid ] != 0 && PosZ[ playerid ] != 0 )
{
SetPlayerPos( playerid, PosX[ playerid ], PosY[ playerid ], PosZ[ playerid ] );
SetPlayerFacingAngle( playerid, Angle[ playerid ] );
SetPlayerInterior( playerid, Interior[ playerid ] );
SetPlayerVirtualWorld( playerid, VirtualWorld[ playerid ] );
SendClientMessage( playerid, -1, "welcome to your last position" );
}
return ( 1 );
}
and when i leave the server it saves my last cords but when i join again it spawns me at the default loaction( which is in gamemode)
beastmaster is offline   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 08: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 05:02 PM
Save & Load position anumaz Help Archive 4 16/07/2011 04:26 AM
save player position ! dorperez Help Archive 2 19/01/2011 04:27 PM


All times are GMT. The time now is 11:25 PM.


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