Guest User

Untitled

a guest
Apr 28th, 2013
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. #if defined _rSave_included
  2. #endinput
  3. #endif
  4. #define _rSave_included
  5. #pragma library rSave
  6. #include <a_samp>
  7. #include <dini>
  8. #define SavedPos "Pos/%s.ini"
  9. enum Pos
  10. {
  11. Float:p_X ,
  12. Float:p_Y ,
  13. Float:p_Z
  14. };
  15. new
  16. p_Pos [ MAX_PLAYERS ] [ Pos ],
  17. p_fSpawn [ MAX_PLAYERS ]
  18. ;
  19. new
  20. s_String [ 240 ]
  21. ;
  22. public OnPlayerConnect(playerid)
  23. {
  24. format ( s_String , 240 , SavedPos , p_Name ( playerid ) );
  25. if(!dini_Exists ( s_String ) )
  26. {
  27. dini_Create ( s_String ) ;
  28. }
  29. p_fSpawn [ playerid ] = 0 ;
  30. return 1;
  31. }
  32. #if defined _ALS_OnPlayerConnect
  33. #undef OnPlayerConnect
  34. #else
  35. #define _ALS_OnPlayerConnect
  36. #endif
  37. #define OnPlayerConnect rSave_OnPlayerConnect
  38. forward rSave_OnPlayerConnect(playerid);
  39. public OnPlayerDisconnect(playerid, reason)
  40. {
  41. format ( s_String , 240 , SavedPos , p_Name ( playerid ) );
  42. GetPlayerPos ( playerid , p_Pos [ playerid ] [ p_X ] , p_Pos [ playerid ] [ p_Y ] , p_Pos [ playerid ] [ p_Z ] );
  43. dini_FloatSet( s_String , "xPosition" , p_Pos [ playerid ] [ p_X ] );
  44. dini_FloatSet( s_String , "yPosition" , p_Pos [ playerid ] [ p_Y ] );
  45. dini_FloatSet( s_String , "zPosition" , p_Pos [ playerid ] [ p_Z ] );
  46. return 1;
  47. }
  48. #if defined _ALS_OnPlayerDisconnect
  49. #undef OnPlayerDisconnect
  50. #else
  51. #define _ALS_OnPlayerDisconnect
  52. #endif
  53. #define OnPlayerDisconnect rSave_OnPlayerDisconnect
  54. forward rSave_OnPlayerDisconnect(playerid, reason);
  55. public OnPlayerSpawn(playerid)
  56. {
  57. if( p_fSpawn [ playerid ] == 0 )
  58. {
  59. p_fSpawn [ playerid ] = 1 ;
  60. format ( s_String , 240 , SavedPos , p_Name ( playerid ) );
  61. p_Pos [ playerid ] [ p_X ] = dini_Float( s_String , "xPosition" );
  62. p_Pos [ playerid ] [ p_Y ] = dini_Float( s_String , "yPosition" );
  63. p_Pos [ playerid ] [ p_Z ] = dini_Float( s_String , "zPosition" );
  64. SetPlayerPos( playerid , p_Pos [ playerid ] [ p_X ] , p_Pos [ playerid ] [ p_Y ] , p_Pos [ playerid ] [ p_Z ] );
  65. }
  66. return 1;
  67. }
  68. #if defined _ALS_OnPlayerSpawn
  69. #undef OnPlayerSpawn
  70. #else
  71. #define _ALS_OnPlayerSpawn
  72. #endif
  73. #define OnPlayerSpawn rSave_OnPlayerSpawn
  74. forward rSave_OnPlayerSpawn(playerid);
  75. stock p_Name( playerid )
  76. {
  77. new
  78. i [ 30 ]
  79. ;
  80. GetPlayerName( playerid , i ,30 ) ;
  81. return ( i ) ;
  82. }
Advertisement
Add Comment
Please, Sign In to add comment