Advertisement
Guest User

crash_trackman

a guest
May 13th, 2009
1,502
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.96 KB | None | 0 0
  1. //DO NOT CHANGE!!!
  2. //DEFINES STARTS AT LINE 294!!!
  3.  
  4. #define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  5. /*----------------------------------------------------------------------------*-
  6. Function:
  7. sscanf
  8. Params:
  9. string[] - String to extract parameters from.
  10. format[] - Parameter types to get.
  11. {Float,_}:... - Data return variables.
  12. Return:
  13. 0 - Successful, not 0 - fail.
  14. Notes:
  15. A fail is either insufficient variables to store the data or insufficient
  16. data for the format string - excess data is disgarded.
  17.  
  18. A string in the middle of the input data is extracted as a single word, a
  19. string at the end of the data collects all remaining text.
  20.  
  21. The format codes are:
  22.  
  23. c - A character.
  24. d, i - An integer.
  25. h, x - A hex number (e.g. a colour).
  26. f - A float.
  27. s - A string.
  28. z - An optional string.
  29. pX - An additional delimiter where X is another character.
  30. '' - Encloses a litteral string to locate.
  31. u - User, takes a name, part of a name or an id and returns the id if they're connected.
  32.  
  33. Now has IsNumeric integrated into the code.
  34.  
  35. Added additional delimiters in the form of all whitespace and an
  36. optioanlly specified one in the format string.
  37. -*----------------------------------------------------------------------------*/
  38.  
  39. stock sscanf(string[], format[], {Float,_}:...)
  40. {
  41. #if defined isnull
  42. if (isnull(string))
  43. #else
  44. if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
  45. #endif
  46. {
  47. return format[0];
  48. }
  49. #pragma tabsize 4
  50. new
  51. formatPos = 0,
  52. stringPos = 0,
  53. paramPos = 2,
  54. paramCount = numargs(),
  55. delim = ' ';
  56. while (string[stringPos] && string[stringPos] <= ' ')
  57. {
  58. stringPos++;
  59. }
  60. while (paramPos < paramCount && string[stringPos])
  61. {
  62. switch (format[formatPos++])
  63. {
  64. case '\0':
  65. {
  66. return 0;
  67. }
  68. case 'i', 'd':
  69. {
  70. new
  71. neg = 1,
  72. num = 0,
  73. ch = string[stringPos];
  74. if (ch == '-')
  75. {
  76. neg = -1;
  77. ch = string[++stringPos];
  78. }
  79. do
  80. {
  81. stringPos++;
  82. if ('0' <= ch <= '9')
  83. {
  84. num = (num * 10) + (ch - '0');
  85. }
  86. else
  87. {
  88. return -1;
  89. }
  90. }
  91. while ((ch = string[stringPos]) > ' ' && ch != delim);
  92. setarg(paramPos, 0, num * neg);
  93. }
  94. case 'h', 'x':
  95. {
  96. new
  97. num = 0,
  98. ch = string[stringPos];
  99. do
  100. {
  101. stringPos++;
  102. switch (ch)
  103. {
  104. case 'x', 'X':
  105. {
  106. num = 0;
  107. continue;
  108. }
  109. case '0' .. '9':
  110. {
  111. num = (num << 4) | (ch - '0');
  112. }
  113. case 'a' .. 'f':
  114. {
  115. num = (num << 4) | (ch - ('a' - 10));
  116. }
  117. case 'A' .. 'F':
  118. {
  119. num = (num << 4) | (ch - ('A' - 10));
  120. }
  121. default:
  122. {
  123. return -1;
  124. }
  125. }
  126. }
  127. while ((ch = string[stringPos]) > ' ' && ch != delim);
  128. setarg(paramPos, 0, num);
  129. }
  130. case 'c':
  131. {
  132. setarg(paramPos, 0, string[stringPos++]);
  133. }
  134. case 'f':
  135. {
  136. setarg(paramPos, 0, _:floatstr(string[stringPos]));
  137. }
  138. case 'p':
  139. {
  140. delim = format[formatPos++];
  141. continue;
  142. }
  143. case '\'':
  144. {
  145. new
  146. end = formatPos - 1,
  147. ch;
  148. while ((ch = format[++end]) && ch != '\'') {}
  149. if (!ch)
  150. {
  151. return -1;
  152. }
  153. format[end] = '\0';
  154. if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
  155. {
  156. if (format[end + 1])
  157. {
  158. return -1;
  159. }
  160. return 0;
  161. }
  162. format[end] = '\'';
  163. stringPos = ch + (end - formatPos);
  164. formatPos = end + 1;
  165. }
  166. case 'u':
  167. {
  168. new
  169. end = stringPos - 1,
  170. id = 0,
  171. bool:num = true,
  172. ch;
  173. while ((ch = string[++end]) && ch != delim)
  174. {
  175. if (num)
  176. {
  177. if ('0' <= ch <= '9')
  178. {
  179. id = (id * 10) + (ch - '0');
  180. }
  181. else
  182. {
  183. num = false;
  184. }
  185. }
  186. }
  187. if (num && IsPlayerConnected(id))
  188. {
  189. setarg(paramPos, 0, id);
  190. }
  191. else
  192. {
  193. #if !defined foreach
  194. #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
  195. #define __SSCANF_FOREACH__
  196. #endif
  197. string[end] = '\0';
  198. num = false;
  199. new
  200. name[MAX_PLAYER_NAME];
  201. id = end - stringPos;
  202. foreach (Player, playerid)
  203. {
  204. GetPlayerName(playerid, name, sizeof (name));
  205. if (!strcmp(name, string[stringPos], true, id))
  206. {
  207. setarg(paramPos, 0, playerid);
  208. num = true;
  209. break;
  210. }
  211. }
  212. if (!num)
  213. {
  214. setarg(paramPos, 0, INVALID_PLAYER_ID);
  215. }
  216. string[end] = ch;
  217. #if defined __SSCANF_FOREACH__
  218. #undef foreach
  219. #undef __SSCANF_FOREACH__
  220. #endif
  221. }
  222. stringPos = end;
  223. }
  224. case 's', 'z':
  225. {
  226. new
  227. i = 0,
  228. ch;
  229. if (format[formatPos])
  230. {
  231. while ((ch = string[stringPos++]) && ch != delim)
  232. {
  233. setarg(paramPos, i++, ch);
  234. }
  235. if (!i)
  236. {
  237. return -1;
  238. }
  239. }
  240. else
  241. {
  242. while ((ch = string[stringPos++]))
  243. {
  244. setarg(paramPos, i++, ch);
  245. }
  246. }
  247. stringPos--;
  248. setarg(paramPos, i, '\0');
  249. }
  250. default:
  251. {
  252. continue;
  253. }
  254. }
  255. while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
  256. {
  257. stringPos++;
  258. }
  259. while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
  260. {
  261. stringPos++;
  262. }
  263. paramPos++;
  264. }
  265. do
  266. {
  267. if ((delim = format[formatPos++]) > ' ')
  268. {
  269. if (delim == '\'')
  270. {
  271. while ((delim = format[formatPos++]) && delim != '\'') {}
  272. }
  273. else if (delim != 'z')
  274. {
  275. return delim;
  276. }
  277. }
  278. }
  279. while (delim > ' ');
  280. return 0;
  281. }
  282.  
  283.  
  284. //DO NOT CHANGE!!!
  285. #include <a_samp>
  286. #define RED 0xFF0000AA
  287. #define GREEN 0x33AA33AA
  288.  
  289.  
  290.  
  291.  
  292. //defines
  293. #define MAX_EXPLOSIONS 5 //The explosions of every bomb.
  294. #define time 500 //Time between the explosions. In milliseconds
  295. #define timetoexplode 5000 //Time between planting and explosion of the bomb. In miliseconds
  296.  
  297. //DO NOT CHANGE!!!
  298. new bombing[MAX_PLAYERS];
  299. new bomb[MAX_PLAYERS];
  300. new timer[MAX_PLAYERS];
  301. forward key(playerid);
  302. forward BOOM(playerid);
  303. forward BOOM2(playerid);
  304. new counter[MAX_PLAYERS];
  305.  
  306. //From here, DO NOT CHANGE!!!
  307.  
  308.  
  309. #define FILTERSCRIPT
  310. #if defined FILTERSCRIPT
  311.  
  312. public OnFilterScriptInit()
  313. {
  314. new string[256], string2[256], string3[256];
  315. print("---The firework script v 0.5 by [GXP]trackman!---");
  316. format(string, sizeof(string), "---Max Explosions set to: %d explosions---", MAX_EXPLOSIONS);
  317. print(string);
  318. format(string2, sizeof(string2), "---Time between explosions set to: %d milliseconds---", time);
  319. print(string2);
  320. format(string3, sizeof(string3), "---Time to explode set to: %d milliseconds---", timetoexplode);
  321. print(string3);
  322. return 1;
  323. }
  324.  
  325. public OnFilterScriptExit()
  326. {
  327. return 1;
  328. }
  329.  
  330. #else
  331.  
  332. main()
  333. {
  334. print("\n----------------------------------");
  335. print(" Blank Gamemode by your name here");
  336. print("----------------------------------\n");
  337. }
  338.  
  339. #endif
  340.  
  341. public OnGameModeInit()
  342. {
  343. return 1;
  344. }
  345.  
  346. public OnGameModeExit()
  347. {
  348. return 1;
  349. }
  350.  
  351.  
  352. public BOOM(playerid)
  353. {
  354. counter[playerid] = counter[playerid] +1;
  355. new Float:x, Float:y, Float:z;
  356. GetObjectPos(bomb[playerid], x, y, z);
  357. CreateExplosion(x, y, z, 5, 10);
  358. if(MAX_EXPLOSIONS <= counter[playerid])
  359. {
  360. counter[playerid] = 0;
  361. DestroyObject(bomb[playerid]);
  362. bombing[playerid] = 0;
  363. return true;
  364. }
  365. else
  366. {
  367. timer[playerid] = SetTimer("BOOM", time, false);
  368. return true;
  369. }
  370. }
  371.  
  372.  
  373. public OnPlayerRequestClass(playerid, classid)
  374. {
  375. SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  376. SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  377. SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  378. return 1;
  379. }
  380.  
  381. public OnPlayerRequestSpawn(playerid)
  382. {
  383. return 1;
  384. }
  385.  
  386. public OnPlayerConnect(playerid)
  387. {
  388. counter[playerid] = 0;
  389. bombing[playerid] = 0;
  390. return 1;
  391. }
  392.  
  393. public OnPlayerDisconnect(playerid, reason)
  394. {
  395. bombing[playerid] = 0;
  396. counter[playerid] = 0;
  397. return 1;
  398. }
  399.  
  400. public OnPlayerSpawn(playerid)
  401. {
  402. return 1;
  403. }
  404.  
  405. public OnPlayerDeath(playerid, killerid, reason)
  406. {
  407. return 1;
  408. }
  409.  
  410. public OnVehicleSpawn(vehicleid)
  411. {
  412. return 1;
  413. }
  414.  
  415. public OnVehicleDeath(vehicleid, killerid)
  416. {
  417. return 1;
  418. }
  419.  
  420. public OnPlayerText(playerid, text[])
  421. {
  422. return 1;
  423. }
  424.  
  425. public OnPlayerPrivmsg(playerid, recieverid, text[])
  426. {
  427. return 1;
  428. }
  429.  
  430. public OnPlayerCommandText(playerid, cmdtext[])
  431. {
  432. dcmd(pbomb, 5, cmdtext);
  433. return 0;
  434. }
  435.  
  436. dcmd_pbomb(playerid, params[])
  437. {
  438. if(bombing[playerid] == 1)
  439. {
  440. SendClientMessage(playerid, RED, "You have already planted a bomb!");
  441. return true;
  442. }
  443. else
  444. {
  445. new Float:x, Float:y, Float:z;
  446. GetPlayerPos(playerid, x, y, z);
  447. bomb[playerid] = CreateObject(1252, x+1, y+1, z-0.75, 0, 0, 0);
  448. bombing[playerid] = 1;
  449. SendClientMessage(playerid, GREEN, "You have planted a bomb!");
  450. timer[playerid] = SetTimer("BOOM", timetoexplode, false);
  451. counter[playerid] = 0;
  452. #pragma unused params
  453. return true;
  454. }
  455. }
  456.  
  457.  
  458. public OnPlayerInfoChange(playerid)
  459. {
  460. return 1;
  461. }
  462.  
  463. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  464. {
  465. return 1;
  466. }
  467.  
  468. public OnPlayerExitVehicle(playerid, vehicleid)
  469. {
  470. return 1;
  471. }
  472.  
  473. public OnPlayerStateChange(playerid, newstate, oldstate)
  474. {
  475. return 1;
  476. }
  477.  
  478. public OnPlayerEnterCheckpoint(playerid)
  479. {
  480. return 1;
  481. }
  482.  
  483. public OnPlayerLeaveCheckpoint(playerid)
  484. {
  485. return 1;
  486. }
  487.  
  488. public OnPlayerEnterRaceCheckpoint(playerid)
  489. {
  490. return 1;
  491. }
  492.  
  493. public OnPlayerLeaveRaceCheckpoint(playerid)
  494. {
  495. return 1;
  496. }
  497.  
  498. public OnRconCommand(cmd[])
  499. {
  500. return 1;
  501. }
  502.  
  503. public OnObjectMoved(objectid)
  504. {
  505. return 1;
  506. }
  507.  
  508. public OnPlayerObjectMoved(playerid, objectid)
  509. {
  510. return 1;
  511. }
  512.  
  513. public OnPlayerPickUpPickup(playerid, pickupid)
  514. {
  515. return 1;
  516. }
  517.  
  518. public OnPlayerSelectedMenuRow(playerid, row)
  519. {
  520. return 1;
  521. }
  522.  
  523. public OnPlayerExitedMenu(playerid)
  524. {
  525. return 1;
  526. }
  527.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement