Advertisement
Guest User

Untitled

a guest
Nov 25th, 2012
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.35 KB | None | 0 0
  1. //CREDITS
  2. //funky1234 - RemoveBuilding Include - ( forum.sa-mp.com/showthread.php?p=1551937 )
  3. //tdXkiller - GetObjectCoords Filterscript - ( http://forum.sa-mp.de/index.php?page=User&userID=15493 )
  4.  
  5. #include <a_samp>
  6. #include <ocmd>
  7.  
  8. const MAX_REMOVED_OBJECTS = 500;
  9.  
  10. enum RemovedObjectsENUM
  11. {
  12. _model,
  13. Float:_oX,
  14. Float:_oY,
  15. Float:_oZ,
  16. Float:_orX,
  17. Float:_orY,
  18. Float:_orZ,
  19. Float:_oRadius,
  20. restored
  21. }
  22. new RemovedObjects[MAX_REMOVED_OBJECTS][RemovedObjectsENUM];
  23.  
  24.  
  25. public OnFilterScriptInit()
  26. {
  27. print(" ");
  28. print("( GetObjectCoords by tdXkiller loaded! )");
  29. print(" ");
  30. return 1;
  31. }
  32.  
  33.  
  34. public OnPlayerSpawn(playerid)
  35. {
  36. SendClientMessage(playerid, 0x0096FFFF, "Benutze: /getcoords [MODELID]");
  37. return 1;
  38. }
  39.  
  40.  
  41. ocmd:getcoords(playerid, params[])
  42. {
  43. new modelID, countstring[40];
  44. if(sscanf(params,"u", modelID)) return SendClientMessage(playerid, 0xFF0000FF, "Benutze: /getcoords [MODELID]");
  45. {
  46. for(new i; i < MAX_REMOVED_OBJECTS; i++)
  47. {
  48. RemoveSpecificBuilding(modelID);
  49. format(countstring, sizeof(countstring), "Es wurden %i Objekte gezählt", CountRemovedObjects());
  50. SendClientMessage(playerid, 0x0096FFFF, countstring);
  51. RestoreBuilding(i);
  52. }
  53. }
  54. return 1;
  55. }
  56.  
  57.  
  58. stock RemoveBuilding(modelid, Float:oX, Float:oY, Float:oZ, Float:oRadius = 0.25, Float:orX = 0.0, Float:orY = 0.0, Float:orZ = 0.0)
  59. {
  60. for(new i; i < MAX_REMOVED_OBJECTS; i++)
  61. {
  62. if(RemovedObjects[i][_model] != modelid) continue;
  63. if(RemovedObjects[i][restored] != 0)
  64. {
  65. if((RemovedObjects[i][_oX] == oX) && (RemovedObjects[i][_oY] == oY) && (RemovedObjects[i][_oZ] == oZ))
  66. {
  67. DestroyObject(RemovedObjects[i][restored]);
  68. RemovedObjects[i][restored] = 0;
  69. RemovedObjects[i][_model] = 0;
  70. return i;
  71. }
  72. }
  73. }
  74.  
  75. new slot = GetObjectFreeSlot();
  76. if(slot == -1) return printf("\tCannot remove any more objects.\nIncrease MAX_REMOVED_OBJECTS in your script.\nIt is currently: %i", MAX_REMOVED_OBJECTS);
  77.  
  78. RemovedObjects[slot][_model] = modelid;
  79. RemovedObjects[slot][_oX] = oX;
  80. RemovedObjects[slot][_oY] = oY;
  81. RemovedObjects[slot][_oZ] = oZ;
  82. RemovedObjects[slot][_oRadius] = oRadius;
  83.  
  84. RemovedObjects[slot][_orX] = orX;
  85. RemovedObjects[slot][_orY] = orY;
  86. RemovedObjects[slot][_orZ] = orZ;
  87.  
  88. SaveCoords(modelid, oX, oY, oZ, orX, orY, orZ);
  89.  
  90. for(new i; i < MAX_PLAYERS; i++)
  91. {
  92. if(!IsPlayerConnected(i)) continue;
  93. RemoveBuildingForPlayer(i, modelid, oX, oY, oZ, oRadius);
  94. }
  95. return slot;
  96. }
  97.  
  98.  
  99. stock RestoreBuilding(slot)
  100. {
  101. if(slot < 0 || slot > MAX_REMOVED_OBJECTS) return 0;
  102. if(RemovedObjects[slot][_model] == 0) return 0;
  103. RemovedObjects[slot][restored] = CreateObject(RemovedObjects[slot][_model], RemovedObjects[slot][_oX], RemovedObjects[slot][_oY], RemovedObjects[slot][_oZ], RemovedObjects[slot][_orX], RemovedObjects[slot][_orY], RemovedObjects[slot][_orZ]);
  104. return 1;
  105. }
  106.  
  107.  
  108. stock RemoveSpecificBuilding(modelid)
  109. {
  110. return RemoveBuilding(modelid, 0.0, 0.0, 0.0, 10000.0);
  111. }
  112.  
  113.  
  114. stock GetObjectFreeSlot()
  115. {
  116. for(new i; i < MAX_REMOVED_OBJECTS; i++)
  117. {
  118. if(RemovedObjects[i][_model] == 0) return i;
  119. }
  120. return -1;
  121. }
  122.  
  123.  
  124. stock CountRemovedObjects()
  125. {
  126. new count = 0;
  127. for(new i; i < MAX_REMOVED_OBJECTS; i++)
  128. {
  129. if(RemovedObjects[i][_model] != 0) count++;
  130. }
  131. return count;
  132. }
  133.  
  134. stock SaveCoords(modelid, Float:PosX, Float:PosY, Float:PosZ, Float:PosXA, Float:PosYA, Float:PosZA)
  135. {
  136. new string[80], File:saveFile;
  137. format(string, sizeof(string), "%f, %f, %f, %f, %f, %f //%i \r\n", PosX, PosY, PosZ, PosXA, PosYA, PosZA, modelid);
  138. saveFile = fopen("SaveObjectCoords.ini", io_append);
  139. fwrite(saveFile, string);
  140. fclose(saveFile);
  141. return 1;
  142. }
  143.  
  144.  
  145. stock sscanf(string[], format[], {Float,_}:...)
  146. {
  147. #if defined isnull
  148. if (isnull(string))
  149. #else
  150. if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
  151. #endif
  152. {
  153. return format[0];
  154. }
  155. #pragma tabsize 4
  156. new
  157. formatPos = 0,
  158. stringPos = 0,
  159. paramPos = 2,
  160. paramCount = numargs(),
  161. delim = ' ';
  162. while (string[stringPos] && string[stringPos] <= ' ')
  163. {
  164. stringPos++;
  165. }
  166. while (paramPos < paramCount && string[stringPos])
  167. {
  168. switch (format[formatPos++])
  169. {
  170. case '\0':
  171. {
  172. return 0;
  173. }
  174. case 'i', 'd':
  175. {
  176. new
  177. neg = 1,
  178. num = 0,
  179. ch = string[stringPos];
  180. if (ch == '-')
  181. {
  182. neg = -1;
  183. ch = string[++stringPos];
  184. }
  185. do
  186. {
  187. stringPos++;
  188. if ('0' <= ch <= '9')
  189. {
  190. num = (num * 10) + (ch - '0');
  191. }
  192. else
  193. {
  194. return -1;
  195. }
  196. }
  197. while ((ch = string[stringPos]) > ' ' && ch != delim);
  198. setarg(paramPos, 0, num * neg);
  199. }
  200. case 'h', 'x':
  201. {
  202. new
  203. num = 0,
  204. ch = string[stringPos];
  205. do
  206. {
  207. stringPos++;
  208. switch (ch)
  209. {
  210. case 'x', 'X':
  211. {
  212. num = 0;
  213. continue;
  214. }
  215. case '0' .. '9':
  216. {
  217. num = (num << 4) | (ch - '0');
  218. }
  219. case 'a' .. 'f':
  220. {
  221. num = (num << 4) | (ch - ('a' - 10));
  222. }
  223. case 'A' .. 'F':
  224. {
  225. num = (num << 4) | (ch - ('A' - 10));
  226. }
  227. default:
  228. {
  229. return -1;
  230. }
  231. }
  232. }
  233. while ((ch = string[stringPos]) > ' ' && ch != delim);
  234. setarg(paramPos, 0, num);
  235. }
  236. case 'c':
  237. {
  238. setarg(paramPos, 0, string[stringPos++]);
  239. }
  240. case 'f':
  241. {
  242.  
  243. new changestr[16], changepos = 0, strpos = stringPos;
  244. while(changepos < 16 && string[strpos] && string[strpos] != delim)
  245. {
  246. changestr[changepos++] = string[strpos++];
  247. }
  248. changestr[changepos] = '\0';
  249. setarg(paramPos,0,_:floatstr(changestr));
  250. }
  251. case 'p':
  252. {
  253. delim = format[formatPos++];
  254. continue;
  255. }
  256. case '\'':
  257. {
  258. new
  259. end = formatPos - 1,
  260. ch;
  261. while ((ch = format[++end]) && ch != '\'') {}
  262. if (!ch)
  263. {
  264. return -1;
  265. }
  266. format[end] = '\0';
  267. if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
  268. {
  269. if (format[end + 1])
  270. {
  271. return -1;
  272. }
  273. return 0;
  274. }
  275. format[end] = '\'';
  276. stringPos = ch + (end - formatPos);
  277. formatPos = end + 1;
  278. }
  279. case 'u':
  280. {
  281. new
  282. end = stringPos - 1,
  283. id = 0,
  284. bool:num = true,
  285. ch;
  286. while ((ch = string[++end]) && ch != delim)
  287. {
  288. if (num)
  289. {
  290. if ('0' <= ch <= '9')
  291. {
  292. id = (id * 10) + (ch - '0');
  293. }
  294. else
  295. {
  296. num = false;
  297. }
  298. }
  299. }
  300. if (num && IsPlayerConnected(id))
  301. {
  302. setarg(paramPos, 0, id);
  303. }
  304. else
  305. {
  306. #if !defined foreach
  307. #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
  308. #define __SSCANF_FOREACH__
  309. #endif
  310. string[end] = '\0';
  311. num = false;
  312. new
  313. name[MAX_PLAYER_NAME];
  314. id = end - stringPos;
  315. foreach (Player, playerid)
  316. {
  317. GetPlayerName(playerid, name, sizeof (name));
  318. if (!strcmp(name, string[stringPos], true, id))
  319. {
  320. setarg(paramPos, 0, playerid);
  321. num = true;
  322. break;
  323. }
  324. }
  325. if (!num)
  326. {
  327. setarg(paramPos, 0, INVALID_PLAYER_ID);
  328. }
  329. string[end] = ch;
  330. #if defined __SSCANF_FOREACH__
  331. #undef foreach
  332. #undef __SSCANF_FOREACH__
  333. #endif
  334. }
  335. stringPos = end;
  336. }
  337. case 's', 'z':
  338. {
  339. new
  340. i = 0,
  341. ch;
  342. if (format[formatPos])
  343. {
  344. while ((ch = string[stringPos++]) && ch != delim)
  345. {
  346. setarg(paramPos, i++, ch);
  347. }
  348. if (!i)
  349. {
  350. return -1;
  351. }
  352. }
  353. else
  354. {
  355. while ((ch = string[stringPos++]))
  356. {
  357. setarg(paramPos, i++, ch);
  358. }
  359. }
  360. stringPos--;
  361. setarg(paramPos, i, '\0');
  362. }
  363. default:
  364. {
  365. continue;
  366. }
  367. }
  368. while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
  369. {
  370. stringPos++;
  371. }
  372. while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
  373. {
  374. stringPos++;
  375. }
  376. paramPos++;
  377. }
  378. do
  379. {
  380. if ((delim = format[formatPos++]) > ' ')
  381. {
  382. if (delim == '\'')
  383. {
  384. while ((delim = format[formatPos++]) && delim != '\'') {}
  385. }
  386. else if (delim != 'z')
  387. {
  388. return delim;
  389. }
  390. }
  391. }
  392. while (delim > ' ');
  393. return 0;
  394. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement