Advertisement
OG_LOC

test

May 24th, 2014
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.01 KB | None | 0 0
  1. //Includes
  2. #include <a_samp>
  3. #include <YSI\y_ini>
  4. #include <sscanf>
  5. #include <zcmd>
  6.  
  7. //Other Defines
  8. #define FILTERSCRIPT
  9.  
  10. //Colors
  11. #define COLOR_YELLOW 0xFFEE00AA
  12. #define COLOR_ORANGE 0xFFBB00AA
  13. #define COLOR_RED 0xFF0000FF
  14.  
  15. //Enum
  16. enum PositionInfo
  17. {
  18. Float: PosX,
  19. Float: PosY,
  20. Float: PosZ,
  21. Float: Angle,
  22. Interior,
  23. VirtualWorld,
  24. }
  25.  
  26. new YPosInfo[MAX_PLAYERS][PositionInfo];
  27.  
  28. #define YPos_Path "YPOS/%s.ini"
  29. stock user_ini_file(playerid)
  30. {
  31. new str[128],user_name[MAX_PLAYER_NAME];
  32. GetPlayerName(playerid,user_name,sizeof(user_name));
  33.  
  34. for(new d,len = strlen(user_name); d != len; d++)
  35. user_name[d] = tolower(user_name[d]);
  36.  
  37. format(str,sizeof(str),YPos_Path,user_name);
  38. return str;
  39. }
  40.  
  41. forward load_user_position(playerid, name[], value[]);
  42.  
  43. public load_user_position(playerid, name[], value[])
  44. {
  45. INI_Float("PositionX", YPosInfo[playerid][PosX]);
  46. INI_Float("PositionY", YPosInfo[playerid][PosY]);
  47. INI_Float("PositionZ", YPosInfo[playerid][PosZ]);
  48. INI_Float("Angle", YPosInfo[playerid][Angle]);
  49. INI_Int("Interior", YPosInfo[playerid][Interior]);
  50. INI_Int("VirtualWorld", YPosInfo[playerid][VirtualWorld]);
  51. return 1;
  52. }
  53.  
  54. public OnFilterScriptInit()
  55. {
  56. print("\n--------------------------------------");
  57. print(" Youssef's Saving/Loading Position Filterscript Loaded");
  58. print("--------------------------------------\n");
  59. return 1;
  60. }
  61.  
  62. public OnFilterScriptExit()
  63. {
  64. print("\n--------------------------------------");
  65. print(" Youssef's Saving/Loading Position Filterscript Unloaded");
  66. print("--------------------------------------\n");
  67. for(new i = 0; i < MAX_PLAYERS; i++)
  68. {
  69. YPosInfo[i][PosX] = 0;
  70. YPosInfo[i][PosY] = 0;
  71. YPosInfo[i][PosZ] = 0;
  72. YPosInfo[i][Angle] = 0;
  73. YPosInfo[i][Interior] = 0;
  74. YPosInfo[i][VirtualWorld] = 0;
  75. }
  76. return 1;
  77. }
  78.  
  79.  
  80. public OnPlayerConnect(playerid)
  81. {
  82. SendClientMessage(playerid,COLOR_YELLOW,"This Server Uses YPOS (Youssef's Saving/Loading Position) Filterscript.");
  83. if(fexist(user_ini_file(playerid)))
  84. {
  85. INI_ParseFile(user_ini_file(playerid), "load_%s", .bExtra = true, .extra = playerid);
  86. }
  87. else
  88. {
  89. new INI:File = INI_Open(user_ini_file(playerid));
  90. INI_SetTag(File, "YPositions");
  91. INI_WriteFloat(File, "PositionX", 0);
  92. INI_WriteFloat(File, "PositionY", 0);
  93. INI_WriteFloat(File, "PositionZ", 0);
  94. INI_WriteFloat(File, "Angle", 0);
  95. INI_WriteInt(File, "Interior", 0);
  96. INI_WriteInt(File, "VirtualWorld", 0);
  97. }
  98. return 1;
  99. }
  100.  
  101. public OnPlayerDisconnect(playerid, reason)
  102. {
  103. if(fexist(user_ini_file(playerid)))
  104. {
  105. new INI:File = INI_Open(user_ini_file(playerid));
  106. INI_SetTag(File, "YPositions");
  107. INI_WriteFloat(File, "PositionX", YPosInfo[playerid][PosX]);
  108. INI_WriteFloat(File, "PositionY", YPosInfo[playerid][PosY]);
  109. INI_WriteFloat(File, "PositionZ", YPosInfo[playerid][PosZ]);
  110. INI_WriteFloat(File, "Angle", YPosInfo[playerid][Angle]);
  111. INI_WriteInt(File, "Interior", YPosInfo[playerid][Interior]);
  112. INI_WriteInt(File, "VirtualWorld", YPosInfo[playerid][VirtualWorld]);
  113. INI_Close(File);
  114. }
  115. return 1;
  116. }
  117.  
  118. public OnPlayerSpawn(playerid)
  119. {
  120. return 1;
  121. }
  122.  
  123. COMMAND:saveplace1(playerid, params[])
  124. {
  125. new string[64];
  126. GetPlayerPos(playerid, YPosInfo[playerid][PosX], YPosInfo[playerid][PosY], YPosInfo[playerid][PosZ]);
  127. GetPlayerFacingAngle(playerid, YPosInfo[playerid][Angle]);
  128. format(string,sizeof string, "Successfully Saved The PositionX: %f", YPosInfo[playerid][PosX]);
  129. SendClientMessage(playerid, COLOR_ORANGE, string);
  130. format(string,sizeof string, "Successfully Saved The PositionY: %f", YPosInfo[playerid][PosY]);
  131. SendClientMessage(playerid, COLOR_ORANGE, string);
  132. format(string,sizeof string, "Successfully Saved The PositionZ: %f", YPosInfo[playerid][PosZ]);
  133. SendClientMessage(playerid, COLOR_ORANGE, string);
  134. format(string,sizeof string, "Angle: %f , Interior: %d , Virtual World: %d ", YPosInfo[playerid][Angle],GetPlayerInterior(playerid),GetPlayerVirtualWorld(playerid));
  135. YPosInfo[playerid][Interior] = GetPlayerInterior(playerid);
  136. YPosInfo[playerid][VirtualWorld] = GetPlayerVirtualWorld(playerid);
  137. SendClientMessage(playerid, COLOR_ORANGE, string);
  138. return 1;
  139. }
  140.  
  141. COMMAND:gotoplace1(playerid, params[])
  142. {
  143. if(!fexist(user_ini_file(playerid)))
  144. {
  145. SendClientMessage(playerid, COLOR_RED, "You Have Not Saved Your Place Number 1, Yet! Use /saveplace1 To Save Your Current Place To Number 1");
  146. }
  147. else if(fexist(user_ini_file(playerid)))
  148. {
  149. SetPlayerPos(playerid, YPosInfo[playerid][PosX], YPosInfo[playerid][PosY], YPosInfo[playerid][PosZ]);
  150. SetPlayerFacingAngle(playerid, YPosInfo[playerid][Angle]);
  151. SetPlayerVirtualWorld(playerid, YPosInfo[playerid][VirtualWorld]);
  152. SetPlayerInterior(playerid, YPosInfo[playerid][Interior]);
  153. SendClientMessage(playerid, COLOR_ORANGE, "Successfully Teleported To Your Place Number 1.");
  154. }
  155. return 1;
  156. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement