Advertisement
Guest User

Untitled

a guest
Apr 4th, 2010
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.83 KB | None | 0 0
  1. // This is a comment
  2. // uncomment the line below if you want to write a filterscript
  3. #define FILTERSCRIPT
  4.  
  5. #include <a_samp>
  6. #include <float>
  7. #include <zcmd>
  8.  
  9. #if defined FILTERSCRIPT
  10.  
  11. public OnFilterScriptInit()
  12. {
  13. print("\n--------------------------------------");
  14. print(" Blank Filterscript by your name here");
  15. print("--------------------------------------\n");
  16. return 1;
  17. }
  18.  
  19. public OnFilterScriptExit()
  20. {
  21. return 1;
  22. }
  23.  
  24. #else
  25.  
  26. main()
  27. {
  28. print("\n----------------------------------");
  29. print(" Blank Gamemode by your name here");
  30. print("----------------------------------\n");
  31. }
  32.  
  33. #endif
  34.  
  35. public OnGameModeInit()
  36. {
  37. // Don't use these lines if it's a filterscript
  38. SetGameModeText("Blank Script");
  39. AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  40. return 1;
  41. }
  42.  
  43. public OnGameModeExit()
  44. {
  45. return 1;
  46. }
  47.  
  48. #define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  49.  
  50. public OnPlayerConnect(playerid)
  51. {
  52. return 1;
  53. }
  54.  
  55. public OnPlayerDisconnect(playerid, reason)
  56. {
  57. return 1;
  58. }
  59.  
  60. public OnPlayerSpawn(playerid)
  61. {
  62. return 1;
  63. }
  64.  
  65. public OnPlayerDeath(playerid, killerid, reason)
  66. {
  67. return 1;
  68. }
  69.  
  70. public OnVehicleSpawn(vehicleid)
  71. {
  72. return 1;
  73. }
  74.  
  75. public OnVehicleDeath(vehicleid, killerid)
  76. {
  77. return 1;
  78. }
  79.  
  80. public OnPlayerText(playerid, text[])
  81. {
  82. return 1;
  83. }
  84.  
  85. public OnPlayerCommandText(playerid, cmdtext[])
  86. {
  87. if (strcmp("/xyz", cmdtext, true, 10) == 0)
  88. {
  89. zcmd(xyz,4,cmdtext);
  90. return 1;
  91. }
  92. return 0;
  93. }
  94.  
  95. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  96. {
  97. return 1;
  98. }
  99.  
  100. public OnPlayerExitVehicle(playerid, vehicleid)
  101. {
  102. return 1;
  103. }
  104.  
  105. public OnPlayerStateChange(playerid, newstate, oldstate)
  106. {
  107. return 1;
  108. }
  109.  
  110. public OnPlayerEnterCheckpoint(playerid)
  111. {
  112. return 1;
  113. }
  114.  
  115. public OnPlayerLeaveCheckpoint(playerid)
  116. {
  117. return 1;
  118. }
  119.  
  120. public OnPlayerEnterRaceCheckpoint(playerid)
  121. {
  122. return 1;
  123. }
  124.  
  125. public OnPlayerLeaveRaceCheckpoint(playerid)
  126. {
  127. return 1;
  128. }
  129.  
  130. public OnRconCommand(cmd[])
  131. {
  132. return 1;
  133. }
  134.  
  135. public OnPlayerRequestSpawn(playerid)
  136. {
  137. return 1;
  138. }
  139.  
  140. public OnObjectMoved(objectid)
  141. {
  142. return 1;
  143. }
  144.  
  145. public OnPlayerObjectMoved(playerid, objectid)
  146. {
  147. return 1;
  148. }
  149.  
  150. public OnPlayerPickUpPickup(playerid, pickupid)
  151. {
  152. return 1;
  153. }
  154.  
  155. public OnVehicleMod(playerid, vehicleid, componentid)
  156. {
  157. return 1;
  158. }
  159.  
  160. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  161. {
  162. return 1;
  163. }
  164.  
  165. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  166. {
  167. return 1;
  168. }
  169.  
  170. public OnPlayerSelectedMenuRow(playerid, row)
  171. {
  172. return 1;
  173. }
  174.  
  175. public OnPlayerExitedMenu(playerid)
  176. {
  177. return 1;
  178. }
  179.  
  180. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  181. {
  182. return 1;
  183. }
  184.  
  185. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  186. {
  187. return 1;
  188. }
  189.  
  190. public OnRconLoginAttempt(ip[], password[], success)
  191. {
  192. return 1;
  193. }
  194.  
  195. public OnPlayerUpdate(playerid)
  196. {
  197. return 1;
  198. }
  199.  
  200. public OnPlayerStreamIn(playerid, forplayerid)
  201. {
  202. return 1;
  203. }
  204.  
  205. public OnPlayerStreamOut(playerid, forplayerid)
  206. {
  207. return 1;
  208. }
  209.  
  210. public OnVehicleStreamIn(vehicleid, forplayerid)
  211. {
  212. return 1;
  213. }
  214.  
  215. public OnVehicleStreamOut(vehicleid, forplayerid)
  216. {
  217. return 1;
  218. }
  219.  
  220. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  221. {
  222. return 1;
  223. }
  224.  
  225. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  226. {
  227. return 1;
  228. }
  229. CMD:xyz(playerid,params[]) // zcmd.
  230. {
  231. new
  232. Float:pos1,
  233. Float:pos2,
  234. int;
  235. if(sscanf(params,"fffd",floatstr(params),pos1,pos2,int)) return SendClientMessage(playerid,0x8C8C8C8C,"USAGE: /xyz [x coordination] [y coordination] [z coordination] [interiorid]");
  236. if(IsPlayerInAnyVehicle(playerid))
  237. {
  238. SetVehiclePos(GetPlayerVehicleID(playerid),floatstr(params),pos1,pos2);
  239. LinkVehicleToInterior(GetPlayerVehicleID(playerid),int);
  240. }
  241. else
  242. {
  243. SetPlayerPos(playerid,floatstr(params),pos1,pos2);
  244. SetPlayerInterior(playerid,int);
  245. }
  246. return 1;
  247. }
  248. //------------------[SSCANF]-------------------------------------
  249. stock sscanf(string[], format[], {Float,_}:...)
  250. {
  251. #if defined isnull
  252. if (isnull(string))
  253. #else
  254. if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
  255. #endif
  256. {
  257. return format[0];
  258. }
  259. #pragma tabsize 4
  260. new
  261. formatPos = 0,
  262. stringPos = 0,
  263. paramPos = 2,
  264. paramCount = numargs(),
  265. delim = ' ';
  266. while (string[stringPos] && string[stringPos] <= ' ')
  267. {
  268. stringPos++;
  269. }
  270. while (paramPos < paramCount && string[stringPos])
  271. {
  272. switch (format[formatPos++])
  273. {
  274. case '\0':
  275. {
  276. return 0;
  277. }
  278. case 'i', 'd':
  279. {
  280. new
  281. neg = 1,
  282. num = 0,
  283. ch = string[stringPos];
  284. if (ch == '-')
  285. {
  286. neg = -1;
  287. ch = string[++stringPos];
  288. }
  289. do
  290. {
  291. stringPos++;
  292. if ('0' <= ch <= '9')
  293. {
  294. num = (num * 10) + (ch - '0');
  295. }
  296. else
  297. {
  298. return -1;
  299. }
  300. }
  301. while ((ch = string[stringPos]) > ' ' && ch != delim);
  302. setarg(paramPos, 0, num * neg);
  303. }
  304. case 'h', 'x':
  305. {
  306. new
  307. num = 0,
  308. ch = string[stringPos];
  309. do
  310. {
  311. stringPos++;
  312. switch (ch)
  313. {
  314. case 'x', 'X':
  315. {
  316. num = 0;
  317. continue;
  318. }
  319. case '0' .. '9':
  320. {
  321. num = (num << 4) | (ch - '0');
  322. }
  323. case 'a' .. 'f':
  324. {
  325. num = (num << 4) | (ch - ('a' - 10));
  326. }
  327. case 'A' .. 'F':
  328. {
  329. num = (num << 4) | (ch - ('A' - 10));
  330. }
  331. default:
  332. {
  333. return -1;
  334. }
  335. }
  336. }
  337. while ((ch = string[stringPos]) > ' ' && ch != delim);
  338. setarg(paramPos, 0, num);
  339. }
  340. case 'c':
  341. {
  342. setarg(paramPos, 0, string[stringPos++]);
  343. }
  344. case 'f':
  345. {
  346.  
  347. new changestr[16], changepos = 0, strpos = stringPos;
  348. while(changepos < 16 && string[strpos] && string[strpos] != delim)
  349. {
  350. changestr[changepos++] = string[strpos++];
  351. }
  352. changestr[changepos] = '\0';
  353. setarg(paramPos,0,_:floatstr(changestr));
  354. }
  355. case 'p':
  356. {
  357. delim = format[formatPos++];
  358. continue;
  359. }
  360. case '\'':
  361. {
  362. new
  363. end = formatPos - 1,
  364. ch;
  365. while ((ch = format[++end]) && ch != '\'') {}
  366. if (!ch)
  367. {
  368. return -1;
  369. }
  370. format[end] = '\0';
  371. if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
  372. {
  373. if (format[end + 1])
  374. {
  375. return -1;
  376. }
  377. return 0;
  378. }
  379. format[end] = '\'';
  380. stringPos = ch + (end - formatPos);
  381. formatPos = end + 1;
  382. }
  383. case 'u':
  384. {
  385. new
  386. end = stringPos - 1,
  387. id = 0,
  388. bool:num = true,
  389. ch;
  390. while ((ch = string[++end]) && ch != delim)
  391. {
  392. if (num)
  393. {
  394. if ('0' <= ch <= '9')
  395. {
  396. id = (id * 10) + (ch - '0');
  397. }
  398. else
  399. {
  400. num = false;
  401. }
  402. }
  403. }
  404. if (num && IsPlayerConnected(id))
  405. {
  406. setarg(paramPos, 0, id);
  407. }
  408. else
  409. {
  410. #if !defined foreach
  411. #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
  412. #define __SSCANF_FOREACH__
  413. #endif
  414. string[end] = '\0';
  415. num = false;
  416. new
  417. name[MAX_PLAYER_NAME];
  418. id = end - stringPos;
  419. foreach (Player, playerid)
  420. {
  421. GetPlayerName(playerid, name, sizeof (name));
  422. if (!strcmp(name, string[stringPos], true, id))
  423. {
  424. setarg(paramPos, 0, playerid);
  425. num = true;
  426. break;
  427. }
  428. }
  429. if (!num)
  430. {
  431. setarg(paramPos, 0, INVALID_PLAYER_ID);
  432. }
  433. string[end] = ch;
  434. #if defined __SSCANF_FOREACH__
  435. #undef foreach
  436. #undef __SSCANF_FOREACH__
  437. #endif
  438. }
  439. stringPos = end;
  440. }
  441. case 's', 'z':
  442. {
  443. new
  444. i = 0,
  445. ch;
  446. if (format[formatPos])
  447. {
  448. while ((ch = string[stringPos++]) && ch != delim)
  449. {
  450. setarg(paramPos, i++, ch);
  451. }
  452. if (!i)
  453. {
  454. return -1;
  455. }
  456. }
  457. else
  458. {
  459. while ((ch = string[stringPos++]))
  460. {
  461. setarg(paramPos, i++, ch);
  462. }
  463. }
  464. stringPos--;
  465. setarg(paramPos, i, '\0');
  466. }
  467. default:
  468. {
  469. continue;
  470. }
  471. }
  472. while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
  473. {
  474. stringPos++;
  475. }
  476. while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
  477. {
  478. stringPos++;
  479. }
  480. paramPos++;
  481. }
  482. do
  483. {
  484. if ((delim = format[formatPos++]) > ' ')
  485. {
  486. if (delim == '\'')
  487. {
  488. while ((delim = format[formatPos++]) && delim != '\'') {}
  489. }
  490. else if (delim != 'z')
  491. {
  492. return delim;
  493. }
  494. }
  495. }
  496. while (delim > ' ');
  497. return 0;
  498. }
  499.  
  500. //------------------------------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement