[Tutorial] Save, load and set player position - using y_ini
#33

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)
Reply


Messages In This Thread
Save, load and set player position - using y_ini - by SmiT - 27.11.2011, 12:18
Re: Save, load and set player position - using y_ini - by SantarioLeone - 27.11.2011, 18:10
Re: Save, load and set player position - using y_ini - by wups - 27.11.2011, 19:13
Re: Save, load and set player position - using y_ini - by RepzThat - 27.11.2011, 20:05
Re: Save, load and set player position - using y_ini - by SmiT - 28.11.2011, 12:52
Re: Save, load and set player position - using y_ini - by SantarioLeone - 29.11.2011, 17:20
Re: Save, load and set player position - using y_ini - by dmng825 - 31.12.2011, 16:08
Re: Save, load and set player position - using y_ini - by Zom3ie - 31.12.2011, 20:41
Re: Save, load and set player position - using y_ini - by dmng825 - 02.01.2012, 12:16
Re: Save, load and set player position - using y_ini - by maxmax1 - 17.02.2012, 15:22
Re: Save, load and set player position - using y_ini - by Joe Vagos - 15.07.2012, 16:54
Re: Save, load and set player position - using y_ini - by Michael_Cuellar - 02.08.2012, 19:13
Re: Save, load and set player position - using y_ini - by rokasma - 07.11.2012, 14:15
Re: Save, load and set player position - using y_ini - by x96664 - 14.11.2012, 19:04
Re: Save, load and set player position - using y_ini - by Jesseding - 14.11.2012, 20:59
Re: Save, load and set player position - using y_ini - by jstowe96 - 24.11.2012, 01:16
Re: Save, load and set player position - using y_ini - by Crypt - 24.11.2012, 06:04
Re: Save, load and set player position - using y_ini - by jstowe96 - 24.11.2012, 11:38
Re: Save, load and set player position - using y_ini - by Blademaster680 - 15.07.2013, 21:45
Re : Save, load and set player position - using y_ini - by mirou123 - 23.08.2013, 19:29
Re: Save, load and set player position - using y_ini - by Ramms - 07.02.2014, 16:42
Re: Save, load and set player position - using y_ini - by xPirate - 05.04.2014, 12:13
Re: Save, load and set player position - using y_ini - by biker122 - 05.04.2014, 13:18
Re: Save, load and set player position - using y_ini - by xPirate - 05.04.2014, 14:26
Re: Save, load and set player position - using y_ini - by GrandTA - 20.06.2017, 15:39
Re: Save, load and set player position - using y_ini - by 2xRichard - 16.07.2017, 15:46
Re: Save, load and set player position - using y_ini - by beastmaster - 19.07.2018, 07:57
Re: Save, load and set player position - using y_ini - by CodeStyle175 - 19.07.2018, 08:51
Re: Save, load and set player position - using y_ini - by WilliamVN - 21.07.2018, 04:02
Re: Save, load and set player position - using y_ini - by DerickClark - 21.07.2018, 04:19
Re: Save, load and set player position - using y_ini - by beastmaster - 25.07.2018, 08:59
Re: Save, load and set player position - using y_ini - by DerickClark - 26.07.2018, 06:56
Re: Save, load and set player position - using y_ini - by beastmaster - 26.07.2018, 11:38

Forum Jump:


Users browsing this thread: 1 Guest(s)