Guest User

pos saver and loader

a guest
Jan 14th, 2012
468
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. #define FILTERSCRIPT
  2.  
  3. #include <a_samp>
  4. #include <Dini>
  5. #include <dudb>
  6.  
  7. new Float:positionx;
  8. new Float:positiony;
  9. new Float:positionz;
  10. new skin;
  11.  
  12. #if defined FILTERSCRIPT
  13.  
  14. public OnFilterScriptInit()
  15. {
  16. print("\n--------------------------------------");
  17. print(" Position saver by Jueix");
  18. print("--------------------------------------\n");
  19. return 1;
  20. }
  21.  
  22. public OnPlayerConnect(playerid)
  23. {
  24. LoadStats(playerid);
  25. return 1;
  26. }
  27.  
  28. public OnPlayerDisconnect(playerid, reason)
  29. {
  30. new Float:x;
  31. new Float:y;
  32. new Float:z;
  33.  
  34. GetPlayerPos(playerid,x,y,z);
  35. skin = GetPlayerSkin(playerid);
  36. positionx = x;
  37. positiony = y;
  38. positionz = z;
  39. if (!dini_Exists(Pos(playerid)))
  40. {
  41. dini_Create(Pos(playerid));
  42. }
  43.  
  44. SaveStats(playerid);
  45. return 1;
  46. }
  47.  
  48. public OnPlayerSpawn(playerid)
  49. {
  50. if (!dini_Exists(Pos(playerid))) {
  51. SetPlayerPos(playerid, 1676.8462, 1447.7908, 10.7833);
  52. }
  53. else
  54. {
  55. SetPlayerPos(playerid, positionx,positiony,positionz);
  56. SetPlayerSkin(playerid,skin);
  57. }
  58. return 1;
  59. }
  60.  
  61. Player(playerid)
  62. {
  63. new player[MAX_PLAYER_NAME];
  64. GetPlayerName(playerid, player, sizeof(player));
  65. return player;
  66. }
  67.  
  68. Pos(playerid)
  69. {
  70. new a[256]; format(a, sizeof(a), "%s.ini",udb_encode(Player(playerid)));
  71. return a;
  72. }
  73.  
  74. SaveStats(playerid)
  75. {
  76. dini_IntSet(Pos(playerid), "PositionX", floatround(positionx));
  77. dini_IntSet(Pos(playerid), "PositionY", floatround(positiony));
  78. dini_IntSet(Pos(playerid), "PositionZ", floatround(positionz));
  79. dini_IntSet(Pos(playerid), "skin", (skin));
  80. }
  81.  
  82. LoadStats(playerid)
  83. {
  84. positionx = dini_Int(Pos(playerid), "PositionX");
  85. positiony = dini_Int(Pos(playerid), "PositionY");
  86. positionz = dini_Int(Pos(playerid), "PositionZ");
  87. skin = dini_Int(Pos(playerid), "skin");
  88. }
  89.  
  90. public OnFilterScriptExit()
  91. {
  92. return 1;
  93. }
  94.  
  95. #else
  96.  
  97. main()
  98. {
  99. print("\n----------------------------------");
  100. print(" Blank Gamemode by Jueix");
  101. print("----------------------------------\n");
  102. }
  103.  
  104. #endif
Advertisement
Add Comment
Please, Sign In to add comment