Advertisement
Guest User

transport

a guest
Sep 21st, 2014
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.61 KB | None | 0 0
  1. #include <a_samp>
  2. #include <zcmd>
  3. #include <fixchars>
  4.  
  5. #if !defined IsValidVehicle
  6. native IsValidVehicle(vehicleid);
  7. #endif
  8.  
  9.  
  10. new Object[MAX_VEHICLES][6];
  11. new ObjectMove;
  12. new VehicleJOB;
  13. new RacePoint[MAX_PLAYERS];
  14. new Timer[MAX_PLAYERS];
  15. new TimerCount[MAX_PLAYERS];
  16. new Text:TextWarn;
  17. new TimerWarnVar[MAX_PLAYERS];
  18. new TimerWarn[MAX_PLAYERS];
  19. new Vehicle;
  20. new bool:ItCanContinue[MAX_PLAYERS];
  21.  
  22.  
  23.  
  24.  
  25.  
  26. public OnFilterScriptInit()
  27. {
  28. TextWarn = TextDrawCreate(155.000000, 388.000000, " ");
  29. TextDrawBackgroundColor(TextWarn, 255);
  30. TextDrawFont(TextWarn, 1);
  31. TextDrawLetterSize(TextWarn, 0.500000, 1.700000);
  32. TextDrawColor(TextWarn, -1);
  33. TextDrawSetOutline(TextWarn, 0);
  34. TextDrawSetProportional(TextWarn, 1);
  35. TextDrawSetShadow(TextWarn, 1);
  36.  
  37.  
  38. VehicleJOB = CreateVehicle(578, -2227.0730, 295.5872, 35.7419, 0.0777, 32,17, 30);
  39. Vehicle = CreateVehicle(506, -2227.0730, 295.5871, 35.7421, 0.0777, 32,17, -1);
  40.  
  41.  
  42. Object[VehicleJOB][0] = CreateObject(11474,0,0,-1000,0,0,0,100);
  43. AttachObjectToVehicle(Object[VehicleJOB][0], VehicleJOB, 1.660000,0.834999,0.410000,-0.360000,3.240001,96.659988);
  44.  
  45. Object[VehicleJOB][1] = CreateObject(11474,0,0,-1000,0,0,0,100);
  46. AttachObjectToVehicle(Object[VehicleJOB][1], VehicleJOB, 1.660000,-1.994998,0.410000,-0.360000,3.240001,96.659988);
  47.  
  48. Object[VehicleJOB][2] = CreateObject(11474,0,0,-1000,0,0,0,100);
  49. AttachObjectToVehicle(Object[VehicleJOB][2], VehicleJOB, 1.660000,-4.094998,0.410000,-0.360000,3.240001,96.659988);
  50.  
  51. Object[VehicleJOB][3] = CreateObject(11474,0,0,-1000,0,0,0,100);
  52. AttachObjectToVehicle(Object[VehicleJOB][3], VehicleJOB, -1.310000,-4.094998,0.410000,-0.360000,3.240001,96.659988);
  53.  
  54. Object[VehicleJOB][4] = CreateObject(11474,0,0,-1000,0,0,0,100);
  55. AttachObjectToVehicle(Object[VehicleJOB][4], VehicleJOB, -1.310000,-1.254999,0.410000,-0.360000,3.240001,96.659988);
  56.  
  57. Object[VehicleJOB][5] = CreateObject(11474,0,0,-1000,0,0,0,100);
  58. AttachObjectToVehicle(Object[VehicleJOB][5], VehicleJOB, -1.310000,0.809999,0.410000,-0.360000,3.240001,96.659988);
  59.  
  60. ObjectMove = CreateObject(11474,0,0,-1000,0,0,0,100);
  61. AttachObjectToVehicle(ObjectMove, VehicleJOB, -0.049999,-5.694999,0.385000,-6.839998,4.500001,6.840000);
  62. return 1;
  63. }
  64.  
  65.  
  66.  
  67.  
  68. public OnPlayerConnect(playerid)
  69. {
  70. ItCanContinue[playerid] = false;
  71. RacePoint[playerid] = 0;
  72. return 1;
  73. }
  74.  
  75.  
  76.  
  77. //***** Commands *****//
  78.  
  79. CMD:job(playerid, params[]) // Teleport
  80. {
  81. SetPlayerPos(playerid, -2229.4050, 298.6245, 35.1230);
  82. return 1;
  83. }
  84.  
  85. CMD:abrir(playerid, params[]) // Open to 'ObjectMove'
  86. {
  87. DestroyObject(ObjectMove);
  88. ObjectMove = CreateObject(11474,0,0,-1000,0,0,0,100);
  89. AttachObjectToVehicle(ObjectMove, VehicleJOB, -0.0000, -5.825006, -1.039999, 154.259918,6.300012,-9.000000);
  90. return 1;
  91. }
  92.  
  93. //*******************//
  94.  
  95.  
  96.  
  97.  
  98. public OnPlayerEnterRaceCheckpoint(playerid)
  99. {
  100. switch(RacePoint[playerid])
  101. {
  102. case 1:
  103. {
  104. if(IsPlayerInVehicle(playerid, VehicleJOB))
  105. {
  106. DisablePlayerRaceCheckpoint(playerid);
  107. SetPlayerRaceCheckpoint(playerid, 0, -2201.8064, 319.9278, 35.1719, -2181.4182, 320.1506, 35.7966, 10.0);
  108. RacePoint[playerid] = 2;
  109. ToVerify(playerid);
  110. }
  111. }
  112. case 2:
  113. {
  114. if(IsPlayerInVehicle(playerid, VehicleJOB))
  115. {
  116. DisablePlayerRaceCheckpoint(playerid);
  117. SetPlayerRaceCheckpoint(playerid, 0, -2146.6902, 323.4319, 35.1641, -2146.5986, 330.7473, 35.1719, 10.0);
  118. RacePoint[playerid] = 3;
  119. ToVerify(playerid);
  120. }
  121. }
  122. case 3:
  123. {
  124. if(IsPlayerInVehicle(playerid, VehicleJOB))
  125. {
  126. DisablePlayerRaceCheckpoint(playerid);
  127. SetPlayerRaceCheckpoint(playerid, 0, -2143.7305, 731.0673, 69.4104, -2153.7495, 731.0192, 69.4141, 10.0);
  128. RacePoint[playerid] = 4;
  129. ToVerify(playerid);
  130. }
  131. }
  132. case 4:
  133. {
  134. if(IsPlayerInVehicle(playerid, VehicleJOB))
  135. {
  136. DisablePlayerRaceCheckpoint(playerid);
  137. SetPlayerRaceCheckpoint(playerid, 0, -2261.3171, 730.8754, 49.2969, -2261.3440, 740.1472, 49.2969, 10.0);
  138. RacePoint[playerid] = 5;
  139. ToVerify(playerid);
  140. }
  141. }
  142. case 5:
  143. {
  144. if(IsPlayerInVehicle(playerid, VehicleJOB))
  145. {
  146. DisablePlayerRaceCheckpoint(playerid);
  147. SetPlayerRaceCheckpoint(playerid, 0, -2269.5669, 1237.2422, 45.8456, -2260.3965, 1247.1711, 44.1987, 10.0);
  148. RacePoint[playerid] = 6;
  149. ToVerify(playerid);
  150. }
  151. }
  152. case 6:
  153. {
  154. if(IsPlayerInVehicle(playerid, VehicleJOB))
  155. {
  156. DisablePlayerRaceCheckpoint(playerid);
  157. SetPlayerRaceCheckpoint(playerid, 1, -2072.8286, 1275.1196, 10.1820, -2068.5383, 1276.0862, 9.3181, 10.0);
  158. RacePoint[playerid] = 7;
  159. ToVerify(playerid);
  160. }
  161. }
  162. case 7:
  163. {
  164. if(IsPlayerInVehicle(playerid, VehicleJOB))
  165. {
  166. ToVerify(playerid);
  167. if(ItCanContinue[playerid] == true)
  168. {
  169. DisablePlayerRaceCheckpoint(playerid);
  170. new engine[2], lights[2], alarm[2], doors[2], bonnet[2], boot[2], objective[2];
  171. GivePlayerMoney(playerid, random(1500));
  172. RemovePlayerFromVehicle(playerid);
  173. RacePoint[playerid] = 0;
  174. GameTextForPlayer(playerid, "Befejezett küldetés.", 2000, 0);
  175. GetVehicleParamsEx(VehicleJOB, engine[0], lights[0], alarm[0], doors[0], bonnet[0], boot[0], objective[0]);
  176. SetVehicleParamsEx(VehicleJOB, engine[0], lights[0], alarm[0], true, bonnet[0], boot[0], objective[0]);
  177. GetVehicleParamsEx(Vehicle, engine[1], lights[1], alarm[1], doors[1], bonnet[1], boot[1], objective[1]);
  178. SetVehicleParamsEx(Vehicle, engine[1], lights[1], alarm[1], doors[1], bonnet[1], boot[1], false);
  179. for(new i = 0; i < 6; i++)
  180. {
  181. DestroyObject(Object[VehicleJOB][i]);
  182. }
  183. DestroyObject(ObjectMove);
  184. }
  185. }
  186. }
  187. }
  188. return 1;
  189. }
  190.  
  191.  
  192. public OnPlayerStateChange(playerid, newstate, oldstate)
  193. {
  194. if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
  195. {
  196. if(IsPlayerInVehicle(playerid, VehicleJOB))
  197. {
  198. if(RacePoint[playerid] == 0)
  199. {
  200. ShowPlayerDialog(playerid, 654, DIALOG_STYLE_MSGBOX, "{00FFFF}Fuvar.", \
  201. "{FFFFFF}Szeretné elvállalni a fuvart? {FF0000}És dolgozni?", "Igen", "Nem");
  202. }
  203. else if(RacePoint[playerid] > 0)
  204. {
  205. TimerWarnVar[playerid] = 20;
  206. KillTimer(TimerWarn[playerid]);
  207. TextDrawHideForPlayer(playerid, TextWarn);
  208. }
  209. }
  210. }
  211. if(oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT)
  212. {
  213. if(RacePoint[playerid] >= 1)
  214. {
  215. TimerWarn[playerid] = SetTimerEx("TimerWarnCallback", 1000, true, "d", playerid);
  216. TextDrawShowForPlayer(playerid, TextWarn);
  217. TextDrawSetString(TextWarn, "~r~20 ~w~másodperced van~w~ hogy beülj a járműbe.");
  218. }
  219. }
  220. return 1;
  221. }
  222.  
  223.  
  224. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  225. {
  226. if(dialogid == 654)
  227. {
  228. if(response)
  229. {
  230. Timer[playerid] = SetTimerEx("CountDown", 1000, true, "d", playerid);
  231. TogglePlayerControllable(playerid, false);
  232. SetCameraBehindPlayer(playerid);
  233. TimerCount[playerid] = 0;
  234. TimerWarnVar[playerid] = 20;
  235. new engine, lights, alarm, doors, bonnet, boot, objective;
  236. GetVehicleParamsEx(Vehicle, engine, lights, alarm, doors, bonnet, boot, objective);
  237. SetVehicleParamsEx(Vehicle, engine, lights, alarm, doors, bonnet, boot, true);
  238. PlayAudioStreamForPlayer(playerid, "http://tangible-technology.com/music/beatles/ppm/Track%2008.mp3");
  239. if(!IsValidVehicle(Vehicle))
  240. {
  241. Vehicle = CreateVehicle(506, -2227.0730, 295.5871, 35.7421, 0.0777, 32,17, -1);
  242. }
  243. }
  244. else
  245. {
  246. RemovePlayerFromVehicle(playerid);
  247. }
  248. }
  249. return 1;
  250. }
  251.  
  252. public OnVehicleSpawn(vehicleid)
  253. {
  254. if(vehicleid == VehicleJOB)
  255. {
  256. if(!IsValidVehicle(Vehicle))
  257. {
  258. Vehicle = CreateVehicle(506, -2227.0730, 295.5871, 35.7421, 0.0777, 32,17, -1);
  259. }
  260. for(new i = 0; i < 6; i++)
  261. {
  262. if(!IsValidObject(Object[VehicleJOB][i]))
  263. {
  264. Object[VehicleJOB][0] = CreateObject(11474,0,0,-1000,0,0,0,100);
  265. AttachObjectToVehicle(Object[VehicleJOB][0], VehicleJOB, 1.660000,0.834999,0.410000,-0.360000,3.240001,96.659988);
  266. Object[VehicleJOB][1] = CreateObject(11474,0,0,-1000,0,0,0,100);
  267. AttachObjectToVehicle(Object[VehicleJOB][1], VehicleJOB, 1.660000,-1.994998,0.410000,-0.360000,3.240001,96.659988);
  268. Object[VehicleJOB][2] = CreateObject(11474,0,0,-1000,0,0,0,100);
  269. AttachObjectToVehicle(Object[VehicleJOB][2], VehicleJOB, 1.660000,-4.094998,0.410000,-0.360000,3.240001,96.659988);
  270. Object[VehicleJOB][3] = CreateObject(11474,0,0,-1000,0,0,0,100);
  271. AttachObjectToVehicle(Object[VehicleJOB][3], VehicleJOB, -1.310000,-4.094998,0.410000,-0.360000,3.240001,96.659988);
  272. Object[VehicleJOB][4] = CreateObject(11474,0,0,-1000,0,0,0,100);
  273. AttachObjectToVehicle(Object[VehicleJOB][4], VehicleJOB, -1.310000,-1.254999,0.410000,-0.360000,3.240001,96.659988);
  274. Object[VehicleJOB][5] = CreateObject(11474,0,0,-1000,0,0,0,100);
  275. AttachObjectToVehicle(Object[VehicleJOB][5], VehicleJOB, -1.310000, 0.809999, 0.410000, -0.360000, 3.240001, 96.659988);
  276. }
  277. }
  278.  
  279. if(!IsValidObject(ObjectMove))
  280. {
  281. ObjectMove = CreateObject(11474, 0, 0, -1000, 0, 0, 0, 100);
  282. AttachObjectToVehicle(ObjectMove, VehicleJOB, -0.049999, -5.694999, 0.385000, -6.839998, 4.500001, 6.840000);
  283. }
  284. }
  285. if(vehicleid == Vehicle)
  286. {
  287. if(!IsValidVehicle(Vehicle))
  288. {
  289. if(IsValidVehicle(VehicleJOB))
  290. {
  291. new engine, lights, alarm, doors, bonnet, boot, objective;
  292. GetVehicleParamsEx(Vehicle, engine, lights, alarm, doors, bonnet, boot, objective);
  293. SetVehicleParamsEx(Vehicle, engine, lights, alarm, true, bonnet, boot, true);
  294. }
  295. else return false;
  296. }
  297. else return false;
  298. }
  299. return 1;
  300. }
  301.  
  302.  
  303.  
  304.  
  305. forward CountDown(playerid);
  306. public CountDown(playerid)
  307. {
  308. TimerCount[playerid] ++;
  309. new string[15];
  310. format(string, sizeof(string), "%i.", TimerCount[playerid]);
  311. GameTextForPlayer(playerid, string, 999, 3);
  312.  
  313. if(TimerCount[playerid] == 4)
  314. {
  315. GameTextForPlayer(playerid, "~r~Go~w~.", 999, 3);
  316. KillTimer(Timer[playerid]);
  317. TogglePlayerControllable(playerid, true);
  318. TimerCount[playerid] = 0;
  319. SetPlayerRaceCheckpoint(playerid, 0, -2201.8064, 319.9278, 35.1719, -2181.4182, 320.1506, 35.7966, 10.0);
  320. RacePoint[playerid] = 1;
  321. }
  322. return 1;
  323. }
  324.  
  325.  
  326. forward TimerWarnCallback(playerid);
  327. public TimerWarnCallback(playerid)
  328. {
  329. if(!IsPlayerInVehicle(playerid, VehicleJOB))
  330. {
  331. if(RacePoint[playerid] > 0)
  332. {
  333. TimerWarnVar[playerid] --;
  334. new string[55];
  335. format(string, sizeof(string), "~r~%i másodperced van~w~ hogy beülj a járműbe.", TimerWarnVar[playerid]);
  336. TextDrawSetString(TextWarn, string);
  337. if(TimerWarnVar[playerid] == -1)
  338. {
  339. KillTimer(TimerWarn[playerid]);
  340. TextDrawHideForPlayer(playerid, TextWarn);
  341. RacePoint[playerid] = 0;
  342. TimerWarnVar[playerid] = 20;
  343. TimerCount[playerid] = 0;
  344. for(new i = 0; i < 6; i++)
  345. {
  346. DestroyObject(Object[VehicleJOB][i]);
  347. }
  348. DestroyObject(ObjectMove);
  349. GameTextForPlayer(playerid, "~r~Elrontottad a munkát és így nem tudtad leszállítani az árut!~w~.", 2000, 0);
  350. SetVehicleToRespawn(VehicleJOB);
  351. SetVehicleToRespawn(Vehicle);
  352. DisablePlayerRaceCheckpoint(playerid);
  353. StopAudioStreamForPlayer(playerid);
  354. }
  355. }
  356. }
  357. return 1;
  358. }
  359.  
  360.  
  361. forward ToVerify(playerid);
  362. public ToVerify(playerid)
  363. {
  364. new Float:Pos[3];
  365. GetVehiclePos(Vehicle, Pos[0], Pos[1], Pos[2]);
  366. if(IsPlayerInRangeOfPoint(playerid, 10.0, Pos[0], Pos[1], Pos[2])) return ItCanContinue[playerid] = true;
  367. else
  368. {
  369. ItCanContinue[playerid] = false;
  370. GameTextForPlayer(playerid, "~r~Elrontottad a munkát és így nem tudtad leszállítani az árut~w~.", 2000, 0);
  371. RacePoint[playerid] = 0;
  372. DisablePlayerRaceCheckpoint(playerid);
  373. RemovePlayerFromVehicle(playerid);
  374. RacePoint[playerid] = 0;
  375. StopAudioStreamForPlayer(playerid);
  376. for(new i = 0; i < 6; i++)
  377. {
  378. DestroyObject(Object[VehicleJOB][i]);
  379. }
  380. SendClientMessage(playerid, -1, "{FF0000}[Üzenet] {FFFFFF}Nem kellett volna kiszállni a járműből/vagy át szállni másikba! .");
  381. DestroyObject(ObjectMove);
  382. SetVehicleToRespawn(VehicleJOB);
  383. SetVehicleToRespawn(Vehicle);
  384. }
  385. return 1;
  386. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement