Guest User

tsha

a guest
Oct 14th, 2008
125
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <a_samp>
  2. new TopModels[15] = 0;
  3. new TopModelsID[15] = 0;
  4. #define MAX_MODEL_ID 20000
  5. new countmodel[MAX_MODEL_ID];
  6. enum object_info
  7. {
  8. modelidd,
  9. Float:ox,
  10. Float:oy,
  11. Float:oz,
  12. Float:orx,
  13. Float:ory,
  14. Float:orz,
  15. Float:viewdist
  16. }
  17. //--------------objecthere---------------------------------------
  18. new Objects[][object_info] = {
  19. //--------------------objects put here---------------------------------------------------------
  20. //{modelid, Float:x, Float:y, Float:z,Float:rotx, Float:roty, Float:rotz, Float:viewdist},
  21. //last object without the ','
  22. {11111, 123.456, 123.456,123.456, 0.0, 0.0, 0.0, 500.0}, //examples
  23. {11111, 123.456, 123.456,123.456, 0.0, 0.0, 0.0, 500.0}, //examples
  24. {11111, 123.456, 123.456,123.456, 0.0, 0.0, 0.0, 500.0}, //examples
  25. {11111, 123.456, 123.456,123.456, 0.0, 0.0, 0.0, 500.0} //examples
  26. };
  27. //----------------end-objects-----------------------------------
  28. enum player_info
  29. {
  30. objid[sizeof(Objects)],
  31. bool:view[sizeof(Objects)]
  32. }
  33. new PlayerO[MAX_PLAYERS][player_info];
  34. public OnFilterScriptInit()
  35. {
  36. GetCount();
  37. GetTopModels();
  38. GetObjectsInfo();
  39. CreateTopObject();
  40. return 1;
  41. }
  42. public OnPlayerSpawn(playerid)
  43. {
  44. SetTimerEx("PlayerObjectUpdate", 100, 1, "d", playerid);
  45. SetPlayerPos(playerid,0.0, 0.0, 120002.0);
  46. SetTimerEx("loadspawnpos", 1000, false, "d", playerid);
  47. return 1;
  48. }
  49. GetObjectsInfo()
  50. {
  51. new modelss;
  52. new ggf[256];
  53. for(new i = 0;i< MAX_MODEL_ID; i++)
  54. {
  55. if(countmodel[i] != 0)
  56. {
  57. modelss++;
  58. }
  59. }
  60. format(ggf,sizeof(ggf),"%d Objects and %d Models Loaded By Dominator Object Streamer",sizeof(Objects),modelss);
  61. printf(ggf);
  62. }
  63. GetTopModels()
  64. {
  65. new FinalPosition;
  66. for(new i = 0;i< sizeof(Objects); i++)
  67. {
  68. if(Objects[i][modelidd] == TopModelsID[0] || Objects[i][modelidd] == TopModelsID[1] || Objects[i][modelidd] == TopModelsID[2] || Objects[i][modelidd] == TopModelsID[3] || Objects[i][modelidd] == TopModelsID[4] || Objects[i][modelidd] == TopModelsID[5] || Objects[i][modelidd] == TopModelsID[6] || Objects[i][modelidd] == TopModelsID[7] || Objects[i][modelidd] == TopModelsID[8] || Objects[i][modelidd] == TopModelsID[9])
  69. {
  70. FinalPosition = -1;
  71. } else if(countmodel[Objects[i][modelidd]] > TopModels[0]) FinalPosition = 1;
  72. else if(countmodel[Objects[i][modelidd]] > TopModels[1] && countmodel[Objects[i][modelidd]] <= TopModels[0]) FinalPosition = 2;
  73. else if(countmodel[Objects[i][modelidd]] > TopModels[2] && countmodel[Objects[i][modelidd]] <= TopModels[1]) FinalPosition = 3;
  74. else if(countmodel[Objects[i][modelidd]] > TopModels[3] && countmodel[Objects[i][modelidd]] <= TopModels[2]) FinalPosition = 4;
  75. else if(countmodel[Objects[i][modelidd]] > TopModels[4] && countmodel[Objects[i][modelidd]] <= TopModels[3]) FinalPosition = 5;
  76. else if(countmodel[Objects[i][modelidd]] > TopModels[5] && countmodel[Objects[i][modelidd]] <= TopModels[4]) FinalPosition = 6;
  77. else if(countmodel[Objects[i][modelidd]] > TopModels[6] && countmodel[Objects[i][modelidd]] <= TopModels[5]) FinalPosition = 7;
  78. else if(countmodel[Objects[i][modelidd]] > TopModels[7] && countmodel[Objects[i][modelidd]] <= TopModels[6]) FinalPosition = 8;
  79. else if(countmodel[Objects[i][modelidd]] > TopModels[8] && countmodel[Objects[i][modelidd]] <= TopModels[7]) FinalPosition = 9;
  80. else if(countmodel[Objects[i][modelidd]] > TopModels[9] && countmodel[Objects[i][modelidd]] <= TopModels[8]) FinalPosition = 10;
  81. else if(countmodel[Objects[i][modelidd]] > TopModels[10] && countmodel[Objects[i][modelidd]] <= TopModels[9]) FinalPosition = 11;
  82. else if(countmodel[Objects[i][modelidd]] > TopModels[11] && countmodel[Objects[i][modelidd]] <= TopModels[10]) FinalPosition = 12;
  83. else if(countmodel[Objects[i][modelidd]] > TopModels[12] && countmodel[Objects[i][modelidd]] <= TopModels[11]) FinalPosition = 13;
  84. else if(countmodel[Objects[i][modelidd]] > TopModels[13] && countmodel[Objects[i][modelidd]] <= TopModels[12]) FinalPosition = 14;
  85. else if(countmodel[Objects[i][modelidd]] > TopModels[14] && countmodel[Objects[i][modelidd]] <= TopModels[13]) FinalPosition = 15;
  86. else if(countmodel[Objects[i][modelidd]] <= TopModels[14]) FinalPosition = -1;
  87. if(FinalPosition == 1)
  88. {
  89. TopModels[14] = TopModels[13];
  90. TopModels[13] = TopModels[12];
  91. TopModels[12] = TopModels[11];
  92. TopModels[11] = TopModels[10];
  93. TopModels[10] = TopModels[9];
  94. TopModels[9] = TopModels[8];
  95. TopModels[8] = TopModels[7];
  96. TopModels[7] = TopModels[6];
  97. TopModels[6] = TopModels[5];
  98. TopModels[5] = TopModels[4];
  99. TopModels[4] = TopModels[3];
  100. TopModels[3] = TopModels[2];
  101. TopModels[2] = TopModels[1];
  102. TopModels[1] = TopModels[0];
  103. TopModelsID[14] = TopModelsID[13];
  104. TopModelsID[13] = TopModelsID[12];
  105. TopModelsID[12] = TopModelsID[11];
  106. TopModelsID[11] = TopModelsID[10];
  107. TopModelsID[10] = TopModelsID[9];
  108. TopModelsID[9] = TopModelsID[8];
  109. TopModelsID[8] = TopModelsID[7];
  110. TopModelsID[7] = TopModelsID[6];
  111. TopModelsID[6] = TopModelsID[5];
  112. TopModelsID[5] = TopModelsID[4];
  113. TopModelsID[4] = TopModelsID[3];
  114. TopModelsID[3] = TopModelsID[2];
  115. TopModelsID[2] = TopModelsID[1];
  116. TopModelsID[1] = TopModelsID[0];
  117. TopModels[0] = countmodel[Objects[i][modelidd]];
  118. TopModelsID[0] = Objects[i][modelidd];
  119. }
  120. else if(FinalPosition == 2)
  121. {
  122. TopModels[14] = TopModels[13];
  123. TopModels[13] = TopModels[12];
  124. TopModels[12] = TopModels[11];
  125. TopModels[11] = TopModels[10];
  126. TopModels[10] = TopModels[9];
  127. TopModels[9] = TopModels[8];
  128. TopModels[8] = TopModels[7];
  129. TopModels[7] = TopModels[6];
  130. TopModels[6] = TopModels[5];
  131. TopModels[5] = TopModels[4];
  132. TopModels[4] = TopModels[3];
  133. TopModels[3] = TopModels[2];
  134. TopModels[2] = TopModels[1];
  135. TopModelsID[14] = TopModelsID[13];
  136. TopModelsID[13] = TopModelsID[12];
  137. TopModelsID[12] = TopModelsID[11];
  138. TopModelsID[11] = TopModelsID[10];
  139. TopModelsID[10] = TopModelsID[9];
  140. TopModelsID[9] = TopModelsID[8];
  141. TopModelsID[8] = TopModelsID[7];
  142. TopModelsID[7] = TopModelsID[6];
  143. TopModelsID[6] = TopModelsID[5];
  144. TopModelsID[5] = TopModelsID[4];
  145. TopModelsID[4] = TopModelsID[3];
  146. TopModelsID[3] = TopModelsID[2];
  147. TopModelsID[2] = TopModelsID[1];
  148. TopModels[1] = countmodel[Objects[i][modelidd]];
  149. TopModelsID[1] = Objects[i][modelidd];
  150. }
  151. else if(FinalPosition == 3)
  152. {
  153. TopModels[14] = TopModels[13];
  154. TopModels[13] = TopModels[12];
  155. TopModels[12] = TopModels[11];
  156. TopModels[11] = TopModels[10];
  157. TopModels[10] = TopModels[9];
  158. TopModels[9] = TopModels[8];
  159. TopModels[8] = TopModels[7];
  160. TopModels[7] = TopModels[6];
  161. TopModels[6] = TopModels[5];
  162. TopModels[5] = TopModels[4];
  163. TopModels[4] = TopModels[3];
  164. TopModels[3] = TopModels[2];
  165. TopModelsID[14] = TopModelsID[13];
  166. TopModelsID[13] = TopModelsID[12];
  167. TopModelsID[12] = TopModelsID[11];
  168. TopModelsID[11] = TopModelsID[10];
  169. TopModelsID[10] = TopModelsID[9];
  170. TopModelsID[9] = TopModelsID[8];
  171. TopModelsID[8] = TopModelsID[7];
  172. TopModelsID[7] = TopModelsID[6];
  173. TopModelsID[6] = TopModelsID[5];
  174. TopModelsID[5] = TopModelsID[4];
  175. TopModelsID[4] = TopModelsID[3];
  176. TopModelsID[3] = TopModelsID[2];
  177. TopModels[2] = countmodel[Objects[i][modelidd]];
  178. TopModelsID[2] = Objects[i][modelidd];
  179. }
  180. else if(FinalPosition == 4)
  181. {
  182. TopModels[14] = TopModels[13];
  183. TopModels[13] = TopModels[12];
  184. TopModels[12] = TopModels[11];
  185. TopModels[11] = TopModels[10];
  186. TopModels[10] = TopModels[9];
  187. TopModels[9] = TopModels[8];
  188. TopModels[8] = TopModels[7];
  189. TopModels[7] = TopModels[6];
  190. TopModels[6] = TopModels[5];
  191. TopModels[5] = TopModels[4];
  192. TopModels[4] = TopModels[3];
  193. TopModelsID[14] = TopModelsID[13];
  194. TopModelsID[13] = TopModelsID[12];
  195. TopModelsID[12] = TopModelsID[11];
  196. TopModelsID[11] = TopModelsID[10];
  197. TopModelsID[10] = TopModelsID[9];
  198. TopModelsID[9] = TopModelsID[8];
  199. TopModelsID[8] = TopModelsID[7];
  200. TopModelsID[7] = TopModelsID[6];
  201. TopModelsID[6] = TopModelsID[5];
  202. TopModelsID[5] = TopModelsID[4];
  203. TopModelsID[4] = TopModelsID[3];
  204. TopModels[3] = countmodel[Objects[i][modelidd]];
  205. TopModelsID[3] = Objects[i][modelidd];
  206. }
  207. else if(FinalPosition == 5)
  208. {
  209. TopModels[14] = TopModels[13];
  210. TopModels[13] = TopModels[12];
  211. TopModels[12] = TopModels[11];
  212. TopModels[11] = TopModels[10];
  213. TopModels[10] = TopModels[9];
  214. TopModels[9] = TopModels[8];
  215. TopModels[8] = TopModels[7];
  216. TopModels[7] = TopModels[6];
  217. TopModels[6] = TopModels[5];
  218. TopModels[5] = TopModels[4];
  219. TopModelsID[14] = TopModelsID[13];
  220. TopModelsID[13] = TopModelsID[12];
  221. TopModelsID[12] = TopModelsID[11];
  222. TopModelsID[11] = TopModelsID[10];
  223. TopModelsID[10] = TopModelsID[9];
  224. TopModelsID[9] = TopModelsID[8];
  225. TopModelsID[8] = TopModelsID[7];
  226. TopModelsID[7] = TopModelsID[6];
  227. TopModelsID[6] = TopModelsID[5];
  228. TopModelsID[5] = TopModelsID[4];
  229. TopModels[4] = countmodel[Objects[i][modelidd]];
  230. TopModelsID[4] = Objects[i][modelidd];
  231. }
  232. else if(FinalPosition == 6)
  233. {
  234. TopModels[14] = TopModels[13];
  235. TopModels[13] = TopModels[12];
  236. TopModels[12] = TopModels[11];
  237. TopModels[11] = TopModels[10];
  238. TopModels[10] = TopModels[9];
  239. TopModels[9] = TopModels[8];
  240. TopModels[8] = TopModels[7];
  241. TopModels[7] = TopModels[6];
  242. TopModels[6] = TopModels[5];
  243. TopModelsID[14] = TopModelsID[13];
  244. TopModelsID[13] = TopModelsID[12];
  245. TopModelsID[12] = TopModelsID[11];
  246. TopModelsID[11] = TopModelsID[10];
  247. TopModelsID[10] = TopModelsID[9];
  248. TopModelsID[9] = TopModelsID[8];
  249. TopModelsID[8] = TopModelsID[7];
  250. TopModelsID[7] = TopModelsID[6];
  251. TopModelsID[6] = TopModelsID[5];
  252. TopModels[5] = countmodel[Objects[i][modelidd]];
  253. TopModelsID[5] = Objects[i][modelidd];
  254. }
  255. else if(FinalPosition == 7)
  256. {
  257. TopModels[14] = TopModels[13];
  258. TopModels[13] = TopModels[12];
  259. TopModels[12] = TopModels[11];
  260. TopModels[11] = TopModels[10];
  261. TopModels[10] = TopModels[9];
  262. TopModels[9] = TopModels[8];
  263. TopModels[8] = TopModels[7];
  264. TopModels[7] = TopModels[6];
  265. TopModelsID[14] = TopModelsID[13];
  266. TopModelsID[13] = TopModelsID[12];
  267. TopModelsID[12] = TopModelsID[11];
  268. TopModelsID[11] = TopModelsID[10];
  269. TopModelsID[10] = TopModelsID[9];
  270. TopModelsID[9] = TopModelsID[8];
  271. TopModelsID[8] = TopModelsID[7];
  272. TopModelsID[7] = TopModelsID[6];
  273. TopModels[6] = countmodel[Objects[i][modelidd]];
  274. TopModelsID[6] = Objects[i][modelidd];
  275. }
  276. else if(FinalPosition == 8)
  277. {
  278. TopModels[14] = TopModels[13];
  279. TopModels[13] = TopModels[12];
  280. TopModels[12] = TopModels[11];
  281. TopModels[11] = TopModels[10];
  282. TopModels[10] = TopModels[9];
  283. TopModels[9] = TopModels[8];
  284. TopModels[8] = TopModels[7];
  285. TopModelsID[14] = TopModelsID[13];
  286. TopModelsID[13] = TopModelsID[12];
  287. TopModelsID[12] = TopModelsID[11];
  288. TopModelsID[11] = TopModelsID[10];
  289. TopModelsID[10] = TopModelsID[9];
  290. TopModelsID[9] = TopModelsID[8];
  291. TopModelsID[8] = TopModelsID[7];
  292. TopModels[7] = countmodel[Objects[i][modelidd]];
  293. TopModelsID[7] = Objects[i][modelidd];
  294. }
  295. else if(FinalPosition == 9)
  296. {
  297. TopModels[14] = TopModels[13];
  298. TopModels[13] = TopModels[12];
  299. TopModels[12] = TopModels[11];
  300. TopModels[11] = TopModels[10];
  301. TopModels[10] = TopModels[9];
  302. TopModels[9] = TopModels[8];
  303. TopModelsID[14] = TopModelsID[13];
  304. TopModelsID[13] = TopModelsID[12];
  305. TopModelsID[12] = TopModelsID[11];
  306. TopModelsID[11] = TopModelsID[10];
  307. TopModelsID[10] = TopModelsID[9];
  308. TopModelsID[9] = TopModelsID[8];
  309. TopModels[8] = countmodel[Objects[i][modelidd]];
  310. TopModelsID[8] = Objects[i][modelidd];
  311. }
  312. else if(FinalPosition == 10)
  313. {
  314. TopModels[14] = TopModels[13];
  315. TopModels[13] = TopModels[12];
  316. TopModels[12] = TopModels[11];
  317. TopModels[11] = TopModels[10];
  318. TopModels[10] = TopModels[9];
  319. TopModelsID[14] = TopModelsID[13];
  320. TopModelsID[13] = TopModelsID[12];
  321. TopModelsID[12] = TopModelsID[11];
  322. TopModelsID[11] = TopModelsID[10];
  323. TopModelsID[10] = TopModelsID[9];
  324. TopModels[9] = countmodel[Objects[i][modelidd]];
  325. TopModelsID[9] = Objects[i][modelidd];
  326. }
  327. else if(FinalPosition == 11)
  328. {
  329. TopModels[14] = TopModels[13];
  330. TopModels[13] = TopModels[12];
  331. TopModels[12] = TopModels[11];
  332. TopModels[11] = TopModels[10];
  333. TopModelsID[14] = TopModelsID[13];
  334. TopModelsID[13] = TopModelsID[12];
  335. TopModelsID[12] = TopModelsID[11];
  336. TopModelsID[11] = TopModelsID[10];
  337. TopModels[10] = countmodel[Objects[i][modelidd]];
  338. TopModelsID[10] = Objects[i][modelidd];
  339. }
  340. else if(FinalPosition == 12)
  341. {
  342. TopModels[14] = TopModels[13];
  343. TopModels[13] = TopModels[12];
  344. TopModels[12] = TopModels[11];
  345. TopModelsID[14] = TopModelsID[13];
  346. TopModelsID[13] = TopModelsID[12];
  347. TopModelsID[12] = TopModelsID[11];
  348. TopModels[11] = countmodel[Objects[i][modelidd]];
  349. TopModelsID[11] = Objects[i][modelidd];
  350. }
  351. else if(FinalPosition == 13)
  352. {
  353. TopModels[14] = TopModels[13];
  354. TopModels[13] = TopModels[12];
  355. TopModelsID[14] = TopModelsID[13];
  356. TopModelsID[13] = TopModelsID[12];
  357. TopModels[12] = countmodel[Objects[i][modelidd]];
  358. TopModelsID[12] = Objects[i][modelidd];
  359. }
  360. else if(FinalPosition == 14)
  361. {
  362. TopModels[14] = TopModels[13];
  363. TopModelsID[14] = TopModelsID[13];
  364. TopModels[13] = countmodel[Objects[i][modelidd]];
  365. TopModelsID[13] = Objects[i][modelidd];
  366. }
  367. else if(FinalPosition == 15)
  368. {
  369. TopModels[14] = countmodel[Objects[i][modelidd]];
  370. TopModelsID[14] = Objects[i][modelidd];
  371. }
  372. }
  373. }
  374. GetCount()
  375. {
  376. for(new i = 0; i < sizeof(Objects); i++)
  377. {
  378. countmodel[Objects[i][modelidd]]++;
  379. }
  380. }
  381. bool:IsInReach(Float:x,Float:y,Float:z,Float:x2,Float:y2,Float:z2,Float:dist)
  382. {
  383. x = (x > x2) ? x - x2 : x2 - x;
  384. if(x > dist) return false;
  385. y = (y > y2) ? y - y2 : y2 - y;
  386. if(y > dist) return false;
  387. z = (z > z2) ? z - z2 : z2 - z;
  388. if(z > dist) return false;
  389. return true;
  390. }
  391. forward PlayerObjectUpdate(playerid);
  392. public PlayerObjectUpdate(playerid)
  393. {
  394. if(IsPlayerConnected(playerid))
  395. {
  396. new Float:pos[3];
  397. GetPlayerPos(playerid,pos[0],pos[1],pos[2]);
  398. for(new i = 0; i < sizeof(Objects); i++)
  399. {
  400. if(!PlayerO[playerid][view][i])
  401. {
  402. if(IsInReach(pos[0],pos[1],pos[2],Objects[i][ox],Objects[i][oy],Objects[i][oz],Objects[i][viewdist]))
  403. {
  404. PlayerO[playerid][view][i] = true;
  405. PlayerO[playerid][objid][i] = CreatePlayerObject(playerid,Objects[i][modelidd],Objects[i][ox],Objects[i][oy],Objects[i][oz],Objects[i][orx],Objects[i][ory],Objects[i][orz]);
  406. }
  407. } else if(!IsInReach(pos[0],pos[1],pos[2],Objects[i][ox],Objects[i][oy],Objects[i][oz],Objects[i][viewdist]))
  408. {
  409. PlayerO[playerid][view][i] = false;
  410. DestroyPlayerObject(playerid,PlayerO[playerid][objid][i]);
  411. }
  412. }
  413. }
  414. }
  415. CreateTopObject()
  416. {
  417. for(new i = 0;i<sizeof(TopModels);i++)
  418. {
  419. if(TopModels[i] != 0) CreateObject(TopModelsID[i],0.0,0.0,120000.0,0.0,0.0,0.0);
  420. }
  421. }
RAW Paste Data