Guest User

Seatbelt #No 1

a guest
Jul 17th, 2013
543
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.88 KB | None | 0 0
  1.  
  2. #define FILTERSCRIPT
  3.  
  4. 4.
  5.  
  6.  
  7. 5.
  8. #include <a_samp>
  9.  
  10. 6.
  11. #include <zcmd>
  12.  
  13. 7.
  14.  
  15.  
  16. 8.
  17. #define COLOR_WHITE 0xFFFFFFAA
  18.  
  19. 9.
  20.  
  21.  
  22. 10.
  23.  
  24.  
  25. 11.
  26. new SeatbeltStatus[MAX_PLAYERS];
  27.  
  28. 12.
  29.  
  30.  
  31. 13.
  32. public OnPlayerConnect(playerid) {
  33.  
  34. 14.
  35. SeatbeltStatus[playerid] = 0;
  36.  
  37. 15.
  38. return 1;
  39.  
  40. 16.
  41. }
  42.  
  43. 17.
  44.  
  45.  
  46. 18.
  47. public OnFilterScriptInit()
  48.  
  49. 19.
  50. {
  51.  
  52. 20.
  53. print("\n---------------------------------------------------------");
  54.  
  55. 21.
  56. print(" Seatbelt System for Roleplay. Dafuq's second Fs. ");
  57.  
  58. 22.
  59. print("---------------------------------------------------------\n");
  60.  
  61. 23.
  62. return 1;
  63.  
  64. 24.
  65. }
  66.  
  67. 25.
  68.  
  69.  
  70. 26.
  71. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  72.  
  73. 27.
  74. {
  75.  
  76. 28.
  77. SeatbeltStatus[playerid] = 0;
  78.  
  79. 29.
  80. }
  81.  
  82. 30.
  83.  
  84.  
  85. 31.
  86. public OnPlayerExitVehicle(playerid, vehicleid)
  87.  
  88. 32.
  89. {
  90.  
  91. 33.
  92. new string[50 + MAX_PLAYER_NAME];
  93.  
  94. 34.
  95. if(SeatbeltStatus[playerid] == 1)
  96.  
  97. 35.
  98. {
  99.  
  100. 36.
  101. format(string, sizeof(string), "* %s reaches for their seatbelt, and unbuckles it.", GetPlayerNameEx(playerid));
  102.  
  103. 37.
  104. SCBubble(playerid,string,true,0xFFFF00AA,10,5000);
  105.  
  106. 38.
  107. SendClientMessage(playerid, COLOR_WHITE, "You have taken off your seatbelt.");
  108.  
  109. 39.
  110. }
  111.  
  112. 40.
  113. return 1;
  114.  
  115. 41.
  116. }
  117.  
  118. 42.
  119.  
  120.  
  121. 43.
  122.  
  123.  
  124. 44.
  125. CMD:seatbelt(playerid, params[])
  126.  
  127. 45.
  128. {
  129.  
  130. 46.
  131. if(IsPlayerInAnyVehicle(playerid) == 0)
  132.  
  133. 47.
  134. {
  135.  
  136. 48.
  137. SendClientMessage(playerid, COLOR_WHITE, "You are not in a vehicle!");
  138.  
  139. 49.
  140. return 1;
  141.  
  142. 50.
  143. }
  144.  
  145. 51.
  146. new string[50 + MAX_PLAYER_NAME];
  147.  
  148. 52.
  149. if(IsPlayerInAnyVehicle(playerid) == 1 && SeatbeltStatus[playerid] == 0)
  150.  
  151. 53.
  152. {
  153.  
  154. 54.
  155. SeatbeltStatus[playerid] = 1;
  156.  
  157. 55.
  158. if(IsAMotorBike(GetPlayerVehicleID(playerid)))
  159.  
  160. 56.
  161. {
  162.  
  163. 57.
  164. format(string, sizeof(string), "* %s reaches for their helmet, and puts it on.", GetPlayerNameEx(playerid));
  165.  
  166. 58.
  167. SCBubble(playerid,string,true,0xFFFF00AA,10,5000);
  168.  
  169. 59.
  170. SendClientMessage(playerid, COLOR_WHITE, "You have put on your helmet.");
  171.  
  172. 60.
  173. }
  174.  
  175. 61.
  176. else
  177.  
  178. 62.
  179. {
  180.  
  181. 63.
  182. format(string, sizeof(string), "* %s reaches for their seatbelt, and buckles it up.", GetPlayerNameEx(playerid));
  183.  
  184. 64.
  185. SCBubble(playerid,string,true,0xFFFF00AA,10,5000);
  186.  
  187. 65.
  188. SendClientMessage(playerid, COLOR_WHITE, "You have put on your seatbelt.");
  189.  
  190. 66.
  191. }
  192.  
  193. 67.
  194.  
  195.  
  196. 68.
  197. }
  198.  
  199. 69.
  200. else if(IsPlayerInAnyVehicle(playerid) == 1 && SeatbeltStatus[playerid] == 1)
  201.  
  202. 70.
  203. {
  204.  
  205. 71.
  206. SeatbeltStatus[playerid] = 0;
  207.  
  208. 72.
  209. if(IsAMotorBike(GetPlayerVehicleID(playerid)))
  210.  
  211. 73.
  212. {
  213.  
  214. 74.
  215. format(string, sizeof(string), "* %s reaches for their helmet, and takes it off.", GetPlayerNameEx(playerid));
  216.  
  217. 75.
  218. SCBubble(playerid,string,true,0xFFFF00AA,10,5000);
  219.  
  220. 76.
  221. SendClientMessage(playerid, COLOR_WHITE, "You have taken off your helmet.");
  222.  
  223. 77.
  224. }
  225.  
  226. 78.
  227. else
  228.  
  229. 79.
  230. {
  231.  
  232. 80.
  233. format(string, sizeof(string), "* %s reaches for their seatbelt, and unbuckles it.", GetPlayerNameEx(playerid));
  234.  
  235. 81.
  236. SCBubble(playerid,string,true,0xFFFF00AA,10,5000);
  237.  
  238. 82.
  239. SendClientMessage(playerid, COLOR_WHITE, "You have taken off your seatbelt.");
  240.  
  241. 83.
  242. }
  243.  
  244. 84.
  245. }
  246.  
  247. 85.
  248. return 1;
  249.  
  250. 86.
  251. }
  252.  
  253. 87.
  254.  
  255.  
  256. 88.
  257. CMD:checkseatbelt(playerid, params[])
  258.  
  259. 89.
  260. {
  261.  
  262. 90.
  263. if(SeatbeltStatus[playerid] == 1)
  264.  
  265. 91.
  266. {
  267.  
  268. 92.
  269. format(string, sizeof(string), "* %s check's his seatbelt.", GetPlayerNameEx(playerid));
  270.  
  271. 93.
  272. SendClientMessage(playerid, 0xFFFF00AA, "You have your seatbelt on.");
  273.  
  274. 94.
  275. SendClientMessage(playerid, 0xFFFF00AA, "Have a safety ride.");
  276.  
  277. 95.
  278. }
  279.  
  280. 96.
  281. else
  282.  
  283. 97.
  284. {
  285.  
  286. 98.
  287. format(string, sizeof(string), "* %s check's his seatbelt.", GetPlayerNameEx(playerid));
  288.  
  289. 99.
  290. SendClientMessage(playerid, 0xFFFF00AA, "Seems like you don't have your seatbelt on!");
  291.  
  292. 100.
  293. SendClientMessage(playerid, 0xFFFF00AA, "Better but your seatbelt on before you crash a car.");
  294.  
  295. 101.
  296. }
  297.  
  298. 102.
  299. return 1;
  300.  
  301. 103.
  302. }
  303.  
  304. 104.
  305.  
  306.  
  307. 105.
  308. stock GetPlayerNameEx(playerid) {
  309.  
  310. 106.
  311.  
  312.  
  313. 107.
  314. new
  315.  
  316. 108.
  317. sz_playerName[MAX_PLAYER_NAME],
  318.  
  319. 109.
  320. i_pos;
  321.  
  322. 110.
  323.  
  324.  
  325. 111.
  326. GetPlayerName(playerid, sz_playerName, MAX_PLAYER_NAME);
  327.  
  328. 112.
  329. while ((i_pos = strfind(sz_playerName, "_", false, i_pos)) != -1) sz_playerName[i_pos] = ' ';
  330.  
  331. 113.
  332. return sz_playerName;
  333.  
  334. 114.
  335. }
  336.  
  337. 115.
  338.  
  339.  
  340. 116.
  341.  
  342.  
  343. 117.
  344. stock IsAMotorBike(carid) {
  345.  
  346. 118.
  347. switch(GetVehicleModel(carid)) {
  348.  
  349. 119.
  350. case 509, 510, 462, 448, 581, 522, 461, 521, 523, 463, 586, 468, 471: return 1;
  351.  
  352. 120.
  353. }
  354.  
  355. 121.
  356. return 0;
  357.  
  358. 122.
  359. }
  360.  
  361. 123.
  362.  
  363.  
  364. 124.
  365.  
  366.  
  367. 125.
  368. stock SCBubble(playerid,stringtext[],bool:selftext,color,range,time)
  369.  
  370. 126.
  371. {
  372.  
  373. 127.
  374. SetPlayerChatBubble(playerid,stringtext,color,range,time);
  375.  
  376. 128.
  377. if(selftext)
  378.  
  379. 129.
  380. {
  381.  
  382. 130.
  383. if(strlen(stringtext) > 64)
  384.  
  385. 131.
  386. {
  387.  
  388. 132.
  389. new strings1[65];
  390.  
  391. 133.
  392. strmid(strings1,stringtext,64,128);
  393.  
  394. 134.
  395. strdel(stringtext,64,128);
  396.  
  397. 135.
  398. format(stringtext,66,"%s-",stringtext);
  399.  
  400. 136.
  401. format(strings1,66,"-%s",strings1);
  402.  
  403. 137.
  404. SendClientMessage(playerid,color,stringtext);
  405.  
  406. 138.
  407. SendClientMessage(playerid,color,strings1);
  408.  
  409. 139.
  410. }
  411.  
  412. 140.
  413. else SendClientMessage(playerid,color,stringtext);
  414.  
  415. 141.
  416. }
  417.  
  418. 142.
  419. return 1;
  420.  
  421. 143.
  422. }
  423.  
  424. 144.
  425.  
  426.  
  427. 145.
  428. new Float:CarHealth[MAX_PLAYERS];
  429.  
  430. 146.
  431. public OnPlayerUpdate(playerid)
  432.  
  433. 147.
  434. {
  435.  
  436. 148.
  437. if(IsPlayerInAnyVehicle(playerid) == 1 && SeatbeltStatus[playerid] == 0)
  438.  
  439. 149.
  440. {
  441.  
  442. 150.
  443. new Float:TempCarHealth;
  444.  
  445. 151.
  446. GetVehicleHealth(GetPlayerVehicleID(playerid), TempCarHealth);
  447.  
  448. 152.
  449. new Float:Difference = floatsub(CarHealth[playerid], TempCarHealth);
  450.  
  451. 153.
  452. if((floatcmp(CarHealth[playerid], TempCarHealth) == 1) && (floatcmp(Difference,100.0) == 1))
  453.  
  454. 154.
  455. {
  456.  
  457. 155.
  458. Difference = floatdiv(Difference, 10.0);
  459.  
  460. 156.
  461. new Float:OldHealth;
  462.  
  463. 157.
  464. GetPlayerHealth(playerid, OldHealth);
  465.  
  466. 158.
  467. SetPlayerHealth(playerid, floatsub(OldHealth, Difference));
  468.  
  469. 159.
  470. }
  471.  
  472. 160.
  473. CarHealth[playerid] = TempCarHealth;
  474.  
  475. 161.
  476. }
  477.  
  478. 162.
  479. else
  480.  
  481. 163.
  482. {
  483.  
  484. 164.
  485. CarHealth[playerid] = 0.0;
  486.  
  487. 165.
  488. }
  489.  
  490. 166.
  491. return 1;
  492.  
  493. 167.
  494. }
Advertisement
Add Comment
Please, Sign In to add comment