Advertisement
Guest User

Rafelder

a guest
Apr 12th, 2008
696
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.08 KB | None | 0 0
  1. //////////////////////////////////////
  2. /// Icon Control ///
  3. /// ///
  4. /// ///
  5. /// ///
  6. /// Copyright by Rafelder ///
  7. //////////////////////////////////////
  8.  
  9. #define MAX_ICONS 1000
  10. #define MAX_SHOWED_MAPICONS 32 //Don't write more than 32!
  11.  
  12. new Float:XM[MAX_ICONS];
  13. new Float:YM[MAX_ICONS];
  14. new Float:ZM[MAX_ICONS];
  15.  
  16. new MarkerM[MAX_ICONS];
  17. new ColorM[MAX_ICONS];
  18.  
  19. new IsValid[MAX_ICONS];
  20. new Show[MAX_PLAYERS][MAX_ICONS];
  21.  
  22. new IconidM=-1;
  23. new Set_Timer=0;
  24. new Count=0;
  25. new ShowedForPlayer[MAX_PLAYERS];
  26. forward StreamTimer();
  27.  
  28.  
  29. /*
  30. native CreateMapIcon(markerid, color, Float:X, Float:Y, Float:Z);
  31. native DestroyMapIcon(iconid);
  32. native ResetMapIconVariables(playerid);
  33.  
  34. native IsValidMapIcon(iconid);
  35. native IsIconActivatedForPlayer(playerid, iconid);
  36. native IsIconActivatedForAll(iconid);
  37.  
  38. native SetMapIconPos(iconid, Float:X, Float:Y, Float:Z);
  39. native SetMapIconIcon(iconid, markerid, color);
  40. native SetMapIconColor(iconid, color);
  41.  
  42. native GetMapIconPos(iconid, &Float:X, &Float:Y, &Float:Z);
  43. native GetMapIconIcon(iconid);
  44. native GetMapIconColor(iconid);
  45.  
  46. native ShowMapIconForPlayer(playerid, iconid);
  47. native ShowMapIconForAll(iconid);
  48. native ShowAllMapIconForPlayer(playerid);
  49. native ShowAllMapIconForAll();
  50. native DisableMapIconForPlayer(playerid, iconid);
  51. native DisableMapIconForAll(iconid);
  52. native DisableAllMapIconForPlayer(playerid);
  53. native DisableAllMapIconForAll();
  54. */
  55.  
  56. /***************************CREATE***************************/
  57. stock CreateMapIcon(markerid, color, Float:X, Float:Y, Float:Z)
  58. {
  59. if (Set_Timer == 0) {
  60. SetTimer("StreamTimer", 200, 1);
  61. Set_Timer=1;
  62. }
  63.  
  64. if (IconidM >= MAX_ICONS) return 0;
  65. IconidM++;
  66. IsValid[IconidM]=1;
  67. XM[IconidM]=X;
  68. YM[IconidM]=Y;
  69. ZM[IconidM]=Z;
  70. MarkerM[IconidM]=markerid;
  71. ColorM[IconidM]=color;
  72. for(new i=0; i<MAX_PLAYERS; i++) {
  73. Show[i][IconidM]=1;
  74. }
  75. return IconidM;
  76. }
  77.  
  78. stock DestroyMapIcon(iconid)
  79. {
  80. IsValid[iconid]=0;
  81. XM[iconid]=0.0;
  82. YM[iconid]=0.0;
  83. ZM[iconid]=0.0;
  84. MarkerM[iconid]=0;
  85. ColorM[iconid]=0;
  86. for(new i=0; i<MAX_PLAYERS; i++)
  87. Show[i][iconid]=0;
  88. return 1;
  89. }
  90.  
  91. stock ResetMapIconVariables(playerid)
  92. {
  93. for(new i=0; i<MAX_ICONS; i++) {
  94. Show[playerid][i]=1;
  95. }
  96. return 1;
  97. }
  98. /*****************************IS*****************************/
  99. stock IsValidMapIcon(iconid)
  100. {
  101. if (IsValid[iconid] == 1) return 1;
  102. return 0;
  103. }
  104.  
  105.  
  106. stock IsIconActivatedForPlayer(playerid, iconid)
  107. {
  108. if (!IsValidMapIcon(icondid)) return 0;
  109. if (Show[playerid][iconid] == 1) return 1;
  110. return 0;
  111. }
  112.  
  113. stock IsIconActivatedForAll(iconid)
  114. {
  115. if (!IsValidMapIcon(icondid)) return 0;
  116. for(new i=0; i<MAX_PLAYERS; i++) {
  117. if (Show[i][iconid] == 1) return 1;
  118. return 0;
  119. }
  120. }
  121.  
  122. /*****************************DO*****************************/
  123. stock SetMapIconPos(iconid, Float:X, Float:Y, Float:Z)
  124. {
  125. if (!IsValidMapIcon(icondid)) return 0;
  126. XM[iconid]=X;
  127. YM[iconid]=Y;
  128. ZM[iconid]=Z;
  129. return 1;
  130. }
  131.  
  132. stock SetMapIconIcon(iconid, markerid, color)
  133. {
  134. if (!IsValidMapIcon(icondid)) return 0;
  135. MarkerM[iconid]=markerid;
  136. ColorM[iconid]=color;
  137. return 1;
  138. }
  139.  
  140. stock SetMapIconColor(iconid, color)
  141. {
  142. if (!IsValidMapIcon(icondid)) return 0;
  143. ColorM[iconid]=color;
  144. return 1;
  145. }
  146.  
  147. stock ShowMapIconForPlayer(playerid, iconid)
  148. {
  149. if (!IsValidMapIcon(iconid)) return 0;
  150. Show[playerid][iconid]=1;
  151. return 1;
  152. }
  153.  
  154. stock ShowMapIconForAll(iconid)
  155. {
  156. if (!IsValidMapIcon(icondid)) return 0;
  157. for(new i=0; i<MAX_PLAYERS; i++)
  158. if (IsPlayerConnected(i))
  159. Show[i][iconid]=1;
  160. return 1;
  161. }
  162.  
  163. stock ShowAllMapIconForPlayer(playerid)
  164. {
  165. for(new m=0; m<MAX_ICONS; m++) {
  166. if (IsValidMapIcon(m))
  167. Show[playerid][m]=1;
  168. }
  169. return 1;
  170. }
  171.  
  172. stock ShowAllMapIconForAll()
  173. {
  174. for(new i=0; i<MAX_PLAYERS; i++) {
  175. if (IsPlayerConnected(i)) {
  176. for(new m=0; m<MAX_ICONS; m++) {
  177. if (IsValidMapIcon(m))
  178. Show[i][m]=1;
  179. }
  180. }
  181. }
  182. return 1;
  183. }
  184.  
  185. stock DisableMapIconForPlayer(playerid, iconid)
  186. {
  187. if (!IsValidMapIcon(icondid)) return 0;
  188. Show[playerid][iconid]=0;
  189. return 1;
  190. }
  191.  
  192. stock DisableMapIconForAll(iconid)
  193. {
  194. if (!IsValidMapIcon(icondid)) return 0;
  195. for(new i=0; i<MAX_PLAYERS; i++)
  196. Show[i][iconid]=0;
  197. return 1;
  198. }
  199.  
  200. stock DisableAllMapIconForPlayer(playerid)
  201. {
  202. for(new m=0; m<MAX_ICONS; m++) {
  203. if (IsValidMapIcon(m))
  204. Show[playerid][m]=0;
  205. }
  206. return 1;
  207. }
  208.  
  209. stock DisableAllMapIconForAll()
  210. {
  211. for(new i=0; i<MAX_PLAYERS; i++) {
  212. if (IsPlayerConnected(i)) {
  213. for(new m=0; m<MAX_ICONS; m++) {
  214. if (IsValidMapIcon(m))
  215. Show[i][m]=0;
  216. }
  217. }
  218. }
  219. return 1;
  220. }
  221. /****************************GET*****************************/
  222. stock GetMapIconPos(iconid, &Float:X, &Float:Y, &Float:Z)
  223. {
  224. if (!IsValidMapIcon(iconid)) return 0;
  225. X=XM[iconid];
  226. Y=YM[iconid];
  227. Z=ZM[iconid];
  228. return 1;
  229. }
  230.  
  231. stock GetMapIconIcon(iconid)
  232. {
  233. if (!IsValidMapIcon(icondid)) return 0;
  234. return MarkerM[iconid];
  235. }
  236.  
  237. stock GetMapIconColor(iconid)
  238. {
  239. if (!IsValidMapIcon(icondid)) return 0;
  240. return ColorM[inconid];
  241. }
  242. /***************************TIMER*****************************/
  243. public StreamTimer()
  244. {
  245. for(new i=0; i<MAX_PLAYERS; i++) {
  246. if (IsPlayerConnected(i)) {
  247. ShowedForPlayer[i]=0;
  248. for(new oldm=0; oldm<32; oldm++) {RemovePlayerMapIcon(i, oldm);}
  249. Count=0;
  250. for(new m=0; m<MAX_ICONS; m++) {
  251. if (IsValidMapIcon(m)) {
  252. if (ShowedForPlayer[i] < MAX_SHOWED_MAPICONS) {
  253. if (Show[i][m] == 1) {
  254. if (GetDistanceToMapIcon(i, m) <= 400) {
  255. SetPlayerMapIcon(i, Count, XM[m], YM[m], ZM[m], MarkerM[m], ColorM[m]);
  256. ShowedForPlayer[i]++;
  257. Count++;
  258. }
  259.  
  260. }
  261. }
  262. }
  263. }
  264. }
  265. }
  266. return 1;
  267. }
  268. /**************************DISTANCE***************************/
  269. stock GetDistanceToMapIcon(playerid, iconid)
  270. {
  271. new Float:x1,Float:y1,Float:z1;
  272. new Float:x2,Float:y2,Float:z2;
  273. new Float:output;
  274. GetPlayerPos(playerid, x1, y1, z1);
  275. GetMapIconPos(iconid, x2, y2, z2);
  276. output = floatsqroot(floatpower(floatabs(floatsub(x2, x1)), 2)+floatpower(floatabs(floatsub(y2, y1)), 2));
  277. return floatround(output);
  278. }
  279.  
  280.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement