Advertisement
adri1

Untitled

Nov 18th, 2017
1,350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.12 KB | None | 0 0
  1. /*
  2. Vice City Map 0.1
  3. by adri1
  4. */
  5.  
  6. #include <a_samp>
  7.  
  8. /* Textdraw info */
  9. #define map_td_X 0.0
  10. #define map_td_Y 90.0
  11. #define map_td_SIZE_X 110.0
  12. #define map_td_SIZE_Y 150.0
  13.  
  14. /* Map limits */
  15. #define vc_limit_X_WEST 130.0
  16. #define vc_limit_X_EAST 2970.0
  17. #define vc_limit_Y_NORTH 665.0
  18. #define vc_limit_Y_SOUTH -2735.0
  19.  
  20. /*
  21. Vice city offset
  22. "VC2SA was moved +4000X +2000Y"
  23. */
  24. #define vc_offset_X 4000.0
  25. #define vc_offset_Y 2000.0
  26.  
  27. /* Vice city map object model ID */
  28. #define VC_MAP_MODELID -23000
  29.  
  30. // Timer (player) interval
  31. #define UPDATE_INTERVAL 100
  32.  
  33.  
  34. new
  35. bool:player_vc_map[MAX_PLAYERS],
  36. player_vc_map_pos_timer[MAX_PLAYERS],
  37. Text:td_MAP,
  38. PlayerText:ptd_ME[MAX_PLAYERS],
  39.  
  40. Float:map_width,
  41. Float:prop_X,
  42. Float:mv_X,
  43.  
  44. Float:map_height,
  45. Float:prop_Y,
  46. Float:mv_Y;
  47.  
  48.  
  49. public OnFilterScriptInit()
  50. {
  51. /*
  52. Vice City map object
  53. original object: 19166 (gtasamap3)
  54. */
  55. AddSimpleModel(-1, 19166, VC_MAP_MODELID, "vc_map.dff", "vc_map.txd");
  56.  
  57. //Map textdraw
  58. td_MAP = TextDrawCreate(map_td_X, map_td_Y, "");
  59. TextDrawFont(td_MAP, 5);
  60. TextDrawTextSize(td_MAP, map_td_SIZE_X, map_td_SIZE_Y);
  61. TextDrawBackgroundColor(td_MAP, 0);
  62. TextDrawSetPreviewModel(td_MAP, VC_MAP_MODELID);
  63. TextDrawSetPreviewRot(td_MAP, 90.0, 180.0, 0.0, 0.60);
  64.  
  65. //Calc
  66. map_width = floatsub(vc_limit_X_EAST, vc_limit_X_WEST);
  67. prop_X = floatdiv(map_td_SIZE_X, map_width);
  68. mv_X = floatsub(map_width, vc_limit_X_EAST);
  69.  
  70. map_height = floatsub(vc_limit_Y_SOUTH, vc_limit_Y_NORTH);
  71. prop_Y = floatdiv(map_td_SIZE_Y, map_height);
  72. mv_Y = floatsub(map_height, vc_limit_Y_SOUTH);
  73. return 1;
  74. }
  75.  
  76. public OnFilterScriptExit()
  77. {
  78. TextDrawDestroy(td_MAP);
  79. for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
  80. {
  81. if(IsPlayerConnected(i))
  82. {
  83. if(player_vc_map[i])
  84. {
  85. KillTimer(player_vc_map_pos_timer[i]);
  86. if(ptd_ME[i] != PlayerText:INVALID_TEXT_DRAW)
  87. {
  88. PlayerTextDrawDestroy(i, ptd_ME[i]);
  89. ptd_ME[i] = PlayerText:INVALID_TEXT_DRAW;
  90. }
  91.  
  92. player_vc_map_pos_timer[i] = 0;
  93. player_vc_map[i] = false;
  94. }
  95. }
  96. }
  97. return 1;
  98. }
  99.  
  100. public OnPlayerDisconnect(playerid, reason)
  101. {
  102. return 1;
  103. }
  104.  
  105. public OnPlayerCommandText(playerid, cmdtext[])
  106. {
  107. if(!strcmp(cmdtext, "/map", true))
  108. {
  109. if(player_vc_map[playerid])
  110. {
  111. KillTimer(player_vc_map_pos_timer[playerid]);
  112. if(ptd_ME[playerid] != PlayerText:INVALID_TEXT_DRAW)
  113. {
  114. PlayerTextDrawDestroy(playerid, ptd_ME[playerid]);
  115. ptd_ME[playerid] = PlayerText:INVALID_TEXT_DRAW;
  116. }
  117.  
  118. TextDrawHideForPlayer(playerid, td_MAP);
  119. player_vc_map_pos_timer[playerid] = 0;
  120. player_vc_map[playerid] = false;
  121. }
  122. else
  123. {
  124. player_vc_map[playerid] = true;
  125. player_vc_map_pos_timer[playerid] = SetTimerEx("updatePlayerMapIcon", UPDATE_INTERVAL, true, "i", playerid);
  126. TextDrawShowForPlayer(playerid, td_MAP);
  127. }
  128. return 1;
  129. }
  130. return 0;
  131. }
  132.  
  133. forward updatePlayerMapIcon(playerid);
  134. public updatePlayerMapIcon(playerid)
  135. {
  136. new Float:pos[3];
  137. GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
  138. pos[0] -= vc_offset_X;
  139. pos[1] -= vc_offset_Y;
  140.  
  141. SetPlayerPoint_VC(playerid, "hud:radar_waypoint", 5.0, 5.0, pos[0], pos[1]);
  142. return 1;
  143. }
  144.  
  145. SetPlayerPoint_VC(playerid, icon[], Float:icon_size_X, Float:icon_size_Y, Float:x, Float:y)
  146. {
  147. /* Map limits */
  148. if(x > vc_limit_X_EAST) x = vc_limit_X_EAST;
  149. else if(x < vc_limit_X_WEST) x = vc_limit_X_WEST;
  150.  
  151. if(y > vc_limit_Y_NORTH) y = vc_limit_Y_NORTH;
  152. else if(y < vc_limit_Y_SOUTH) y = vc_limit_Y_SOUTH;
  153.  
  154. /* Conversion */
  155. x += mv_X;
  156. y += mv_Y;
  157.  
  158. new
  159. Float:td_X = map_td_X + floatmul(prop_X, x) - floatdiv(icon_size_X, 2),
  160. Float:td_Y = map_td_Y + floatmul(prop_Y, y) - floatdiv(icon_size_Y, 2);
  161.  
  162. /* Player Textdraw */
  163. if(ptd_ME[playerid] != PlayerText:INVALID_TEXT_DRAW)
  164. {
  165. PlayerTextDrawDestroy(playerid, ptd_ME[playerid]);
  166. ptd_ME[playerid] = PlayerText:INVALID_TEXT_DRAW;
  167. }
  168.  
  169. ptd_ME[playerid] = CreatePlayerTextDraw(playerid, td_X, td_Y, icon);
  170. PlayerTextDrawTextSize(playerid, ptd_ME[playerid], icon_size_X, icon_size_Y);
  171. PlayerTextDrawFont(playerid, ptd_ME[playerid], 4);
  172. PlayerTextDrawShow(playerid, ptd_ME[playerid]);
  173. return 1;
  174. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement