Advertisement
Guest User

Untitled

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