Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #if defined _rSave_included
- #endinput
- #endif
- #define _rSave_included
- #pragma library rSave
- #include <a_samp>
- #include <dini>
- #define SavedPos "Pos/%s.ini"
- enum Pos
- {
- Float:p_X ,
- Float:p_Y ,
- Float:p_Z
- };
- new
- p_Pos [ MAX_PLAYERS ] [ Pos ],
- p_fSpawn [ MAX_PLAYERS ]
- ;
- new
- s_String [ 240 ]
- ;
- public OnPlayerConnect(playerid)
- {
- format ( s_String , 240 , SavedPos , p_Name ( playerid ) );
- if(!dini_Exists ( s_String ) )
- {
- dini_Create ( s_String ) ;
- }
- p_fSpawn [ playerid ] = 0 ;
- return 1;
- }
- #if defined _ALS_OnPlayerConnect
- #undef OnPlayerConnect
- #else
- #define _ALS_OnPlayerConnect
- #endif
- #define OnPlayerConnect rSave_OnPlayerConnect
- forward rSave_OnPlayerConnect(playerid);
- public OnPlayerDisconnect(playerid, reason)
- {
- format ( s_String , 240 , SavedPos , p_Name ( playerid ) );
- GetPlayerPos ( playerid , p_Pos [ playerid ] [ p_X ] , p_Pos [ playerid ] [ p_Y ] , p_Pos [ playerid ] [ p_Z ] );
- dini_FloatSet( s_String , "xPosition" , p_Pos [ playerid ] [ p_X ] );
- dini_FloatSet( s_String , "yPosition" , p_Pos [ playerid ] [ p_Y ] );
- dini_FloatSet( s_String , "zPosition" , p_Pos [ playerid ] [ p_Z ] );
- return 1;
- }
- #if defined _ALS_OnPlayerDisconnect
- #undef OnPlayerDisconnect
- #else
- #define _ALS_OnPlayerDisconnect
- #endif
- #define OnPlayerDisconnect rSave_OnPlayerDisconnect
- forward rSave_OnPlayerDisconnect(playerid, reason);
- public OnPlayerSpawn(playerid)
- {
- if( p_fSpawn [ playerid ] == 0 )
- {
- p_fSpawn [ playerid ] = 1 ;
- format ( s_String , 240 , SavedPos , p_Name ( playerid ) );
- p_Pos [ playerid ] [ p_X ] = dini_Float( s_String , "xPosition" );
- p_Pos [ playerid ] [ p_Y ] = dini_Float( s_String , "yPosition" );
- p_Pos [ playerid ] [ p_Z ] = dini_Float( s_String , "zPosition" );
- SetPlayerPos( playerid , p_Pos [ playerid ] [ p_X ] , p_Pos [ playerid ] [ p_Y ] , p_Pos [ playerid ] [ p_Z ] );
- }
- return 1;
- }
- #if defined _ALS_OnPlayerSpawn
- #undef OnPlayerSpawn
- #else
- #define _ALS_OnPlayerSpawn
- #endif
- #define OnPlayerSpawn rSave_OnPlayerSpawn
- forward rSave_OnPlayerSpawn(playerid);
- stock p_Name( playerid )
- {
- new
- i [ 30 ]
- ;
- GetPlayerName( playerid , i ,30 ) ;
- return ( i ) ;
- }
Advertisement
Add Comment
Please, Sign In to add comment