Guest User

Untitled

a guest
Aug 23rd, 2012
692
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.38 KB | None | 0 0
  1.  
  2.  
  3. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  4. //////////////////////////////////////Speedo By Mirgo////////////////////////////////////////
  5. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  6. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  7. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  8.  
  9.  
  10. #include <a_samp>
  11.  
  12.  
  13. #define GasMax 100
  14. #define RunOutTime 30000
  15. #define RefuelWait 5000
  16. #define CAR_AMOUNT 700
  17. #define SpeedoTime 500
  18. #define COLOR_RED 0xFF0000FF
  19. #define COLOR_YELLOW 0xFFFF00AA
  20.  
  21.  
  22. /*forwards*/
  23. forward UpdateSpeedo();
  24. forward CheckGas();
  25. forward Fillup();
  26. forward SpeedoMeter();
  27. forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);
  28.  
  29. /*new´s*/
  30. new Text:SpeedoBox, Text:SpeedoVehText, Text:SpeedoVeh[MAX_PLAYERS], Text:SpeedoKMHText, Text:SpeedoKMH[MAX_PLAYERS],Text:SpeedoTankText, Text:SpeedoTank[MAX_PLAYERS];
  31. new Gas[CAR_AMOUNT],Float:TachoX[MAX_PLAYERS],Float:TachoY[MAX_PLAYERS],Float:TachoZ[MAX_PLAYERS];
  32. new Vozila[][] =
  33. {
  34. "Landstalker", "Bravura", "Buffalo", "Linerunner", "Perrenial", "Sentinel",
  35. "Dumper", "Firetruck", "Trashmaster", "Stretch", "Manana", "Infernus",
  36. "Voodoo", "Pony", "Mule", "Cheetah", "Ambulance", "Leviathan", "Moonbeam",
  37. "Esperanto", "Taxi", "Washington", "Bobcat", "Whoopee", "BF Injection",
  38. "Hunter", "Premier", "Enforcer", "Securicar", "Banshee", "Predator", "Bus",
  39. "Rhino", "Barracks", "Hotknife", "Trailer", "Previon", "Coach", "Cabbie",
  40. "Stallion", "Rumpo", "RC Bandit", "Romero", "Packer", "Monster", "Admiral",
  41. "Squalo", "Seasparrow", "Pizzaboy", "Tram", "Trailer", "Turismo", "Speeder",
  42. "Reefer", "Tropic", "Flatbed", "Yankee", "Caddy", "Solair", "Berkley's RC Van",
  43. "Skimmer", "PCJ-600", "Faggio", "Freeway", "RC Baron", "RC Raider", "Glendale",
  44. "Oceanic","Sanchez", "Sparrow", "Patriot", "Quad", "Coastguard", "Dinghy",
  45. "Hermes", "Sabre", "Rustler", "ZR-350", "Walton", "Regina", "Comet", "BMX",
  46. "Burrito", "Camper", "Marquis", "Baggage", "Dozer", "Maverick", "News Chopper",
  47. "Rancher", "FBI Rancher", "Virgo", "Greenwood", "Jetmax", "Hotring", "Sandking",
  48. "Blista Compact", "Police Maverick", "Boxvillde", "Benson", "Mesa", "RC Goblin",
  49. "Hotring Racer A", "Hotring Racer B", "Bloodring Banger", "Rancher", "Super GT",
  50. "Elegant", "Journey", "Bike", "Mountain Bike", "Beagle", "Cropduster", "Stunt",
  51. "Tanker", "Roadtrain", "Nebula", "Majestic", "Buccaneer", "Shamal", "Hydra",
  52. "FCR-900", "NRG-500", "HPV1000", "Cement Truck", "Tow Truck", "Fortune",
  53. "Cadrona", "FBI Truck", "Willard", "Forklift", "Tractor", "Combine", "Feltzer",
  54. "Remington", "Slamvan", "Blade", "Freight", "Streak", "Vortex", "Vincent",
  55. "Bullet", "Clover", "Sadler", "Firetruck", "Hustler", "Intruder", "Primo",
  56. "Cargobob", "Tampa", "Sunrise", "Merit", "Utility", "Nevada", "Yosemite",
  57. "Windsor", "Monster", "Monster", "Uranus", "Jester", "Sultan", "Stratum",
  58. "Elegy", "Raindance", "RC Tiger", "Flash", "Tahoma", "Savanna", "Bandito",
  59. "Freight Flat", "Streak Carriage", "Kart", "Mower", "Dune", "Sweeper",
  60. "Broadway", "Tornado", "AT-400", "DFT-30", "Huntley", "Stafford", "BF-400",
  61. "News Van", "Tug", "Trailer", "Emperor", "Wayfarer", "Euros", "Hotdog", "Club",
  62. "Freight Box", "Trailer", "Andromada", "Dodo", "RC Cam", "Launch", "Police Car",
  63. "Police Car", "Police Car", "Police Ranger", "Picador", "S.W.A.T", "Alpha",
  64. "Phoenix", "2. Gebrauchtwagen", "1. Gebrauchtwagen", "Luggage", "Luggage", "Stairs", "Boxville",
  65. "Tiller", "Utility Trailer"
  66. };
  67.  
  68.  
  69. public OnFilterScriptInit()
  70. {
  71. /*Textdraws*/
  72. SpeedoBox = TextDrawCreate(623.000000, 324.000000, " .");
  73. TextDrawBackgroundColor(SpeedoBox, 255);
  74. TextDrawFont(SpeedoBox, 1);
  75. TextDrawLetterSize(SpeedoBox, 27.410072, 1.000000);
  76. TextDrawColor(SpeedoBox, -1);
  77. TextDrawSetOutline(SpeedoBox, 0);
  78. TextDrawSetProportional(SpeedoBox, 1);
  79. TextDrawSetShadow(SpeedoBox, 1);
  80. TextDrawUseBox(SpeedoBox, 1);
  81. TextDrawBoxColor(SpeedoBox, 50);
  82. TextDrawTextSize(SpeedoBox, 511.000000, -7.000000);
  83.  
  84. SpeedoVehText = TextDrawCreate(516.000000, 322.000000, "Vozilo:");
  85. TextDrawBackgroundColor(SpeedoVehText, 255);
  86. TextDrawFont(SpeedoVehText, 2);
  87. TextDrawLetterSize(SpeedoVehText, 0.320000, 1.000000);
  88. TextDrawColor(SpeedoVehText, 75366399);
  89. TextDrawSetOutline(SpeedoVehText, 1);
  90. TextDrawSetProportional(SpeedoVehText, 1);
  91.  
  92. SpeedoTankText = TextDrawCreate(516.000000, 376.000000, "Gorivo:");
  93. TextDrawBackgroundColor(SpeedoTankText, 255);
  94. TextDrawFont(SpeedoTankText, 2);
  95. TextDrawLetterSize(SpeedoTankText, 0.320000, 1.000000);
  96. TextDrawColor(SpeedoTankText, 75366399);
  97. TextDrawSetOutline(SpeedoTankText, 1);
  98. TextDrawSetProportional(SpeedoTankText, 1);
  99.  
  100. SpeedoKMHText = TextDrawCreate(516.000000, 349.000000, "KM/H:");
  101. TextDrawBackgroundColor(SpeedoKMHText, 255);
  102. TextDrawFont(SpeedoKMHText, 2);
  103. TextDrawLetterSize(SpeedoKMHText, 0.320000, 1.000000);
  104. TextDrawColor(SpeedoKMHText, 75366399);
  105. TextDrawSetOutline(SpeedoKMHText, 1);
  106. TextDrawSetProportional(SpeedoKMHText, 1);
  107. for(new playerid = 0; playerid < MAX_PLAYERS; playerid++)
  108. {
  109. SpeedoVeh[playerid] = TextDrawCreate(516.000000, 333.000000, " ");
  110. TextDrawBackgroundColor(SpeedoVeh[playerid], 255);
  111. TextDrawFont(SpeedoVeh[playerid], 2);
  112. TextDrawLetterSize(SpeedoVeh[playerid], 0.320000, 1.000000);
  113. TextDrawColor(SpeedoVeh[playerid], -1);
  114. TextDrawSetOutline(SpeedoVeh[playerid], 1);
  115. TextDrawSetProportional(SpeedoVeh[playerid], 1);
  116.  
  117. SpeedoKMH[playerid] = TextDrawCreate(516.000000, 360.000000, " ");
  118. TextDrawBackgroundColor(SpeedoKMH[playerid], 255);
  119. TextDrawFont(SpeedoKMH[playerid], 2);
  120. TextDrawLetterSize(SpeedoKMH[playerid], 0.320000, 1.000000);
  121. TextDrawColor(SpeedoKMH[playerid], -1);
  122. TextDrawSetOutline(SpeedoKMH[playerid], 1);
  123. TextDrawSetProportional(SpeedoKMH[playerid], 1);
  124.  
  125. SpeedoTank[playerid] = TextDrawCreate(516.000000, 387.000000, " ");
  126. TextDrawBackgroundColor(SpeedoTank[playerid], 255);
  127. TextDrawFont(SpeedoTank[playerid], 2);
  128. TextDrawLetterSize(SpeedoTank[playerid], 0.320000, 1.000000);
  129. TextDrawColor(SpeedoTank[playerid], -1);
  130. TextDrawSetOutline(SpeedoTank[playerid], 1);
  131. TextDrawSetProportional(SpeedoTank[playerid], 1);
  132. }
  133. /*Timer*/
  134. SetTimer("UpdateSpeedo",1000,1);
  135. SetTimer("SpeedoMeter",1000,1);
  136. SetTimer("CheckGas",20000,1);
  137. for(new c = 0; c < CAR_AMOUNT; c++)
  138. {
  139. Gas[c] = GasMax;
  140. }
  141. return 1;
  142. }
  143.  
  144. public OnFilterScriptExit()
  145. {
  146. return 1;
  147. }
  148.  
  149. public OnPlayerConnect(playerid)
  150. {
  151. return 1;
  152. }
  153.  
  154. public OnPlayerDisconnect(playerid, reason)
  155. {
  156. return 1;
  157. }
  158.  
  159. public OnPlayerSpawn(playerid)
  160. {
  161. return 1;
  162. }
  163.  
  164. public OnPlayerDeath(playerid, killerid, reason)
  165. {
  166. return 1;
  167. }
  168.  
  169. public OnVehicleSpawn(vehicleid)
  170. {
  171. return 1;
  172. }
  173.  
  174. public OnVehicleDeath(vehicleid, killerid)
  175. {
  176. return 1;
  177. }
  178.  
  179. public OnPlayerText(playerid, text[])
  180. {
  181. return 1;
  182. }
  183.  
  184. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  185. {
  186. return 1;
  187. }
  188.  
  189. public OnPlayerExitVehicle(playerid, vehicleid)
  190. {
  191. return 1;
  192. }
  193.  
  194. public OnPlayerStateChange(playerid, newstate, oldstate)
  195. {
  196. if(newstate == PLAYER_STATE_DRIVER)
  197. {
  198. TextDrawShowForPlayer(playerid,SpeedoBox);
  199. TextDrawShowForPlayer(playerid,SpeedoVehText);
  200. TextDrawShowForPlayer(playerid,SpeedoVeh[playerid]);
  201. TextDrawShowForPlayer(playerid,SpeedoKMHText);
  202. TextDrawShowForPlayer(playerid,SpeedoKMH[playerid]);
  203. TextDrawShowForPlayer(playerid,SpeedoTankText);
  204. TextDrawShowForPlayer(playerid,SpeedoTank[playerid]);
  205. }
  206. if(oldstate == PLAYER_STATE_DRIVER)
  207. {
  208. TextDrawHideForPlayer(playerid,SpeedoBox);
  209. TextDrawHideForPlayer(playerid,SpeedoVehText);
  210. TextDrawHideForPlayer(playerid,SpeedoVeh[playerid]);
  211. TextDrawHideForPlayer(playerid,SpeedoKMHText);
  212. TextDrawHideForPlayer(playerid,SpeedoKMH[playerid]);
  213. TextDrawHideForPlayer(playerid,SpeedoTankText);
  214. TextDrawHideForPlayer(playerid, SpeedoTank[playerid]);
  215. }
  216. return 1;
  217. }
  218.  
  219. public OnPlayerEnterCheckpoint(playerid)
  220. {
  221. return 1;
  222. }
  223.  
  224. public OnPlayerLeaveCheckpoint(playerid)
  225. {
  226. return 1;
  227. }
  228.  
  229. public OnPlayerEnterRaceCheckpoint(playerid)
  230. {
  231. return 1;
  232. }
  233.  
  234. public OnPlayerLeaveRaceCheckpoint(playerid)
  235. {
  236. return 1;
  237. }
  238.  
  239. public OnRconCommand(cmd[])
  240. {
  241. return 1;
  242. }
  243.  
  244. public OnPlayerRequestSpawn(playerid)
  245. {
  246. return 1;
  247. }
  248.  
  249. public OnObjectMoved(objectid)
  250. {
  251. return 1;
  252. }
  253.  
  254. public OnPlayerObjectMoved(playerid, objectid)
  255. {
  256. return 1;
  257. }
  258.  
  259. public OnPlayerPickUpPickup(playerid, pickupid)
  260. {
  261. return 1;
  262. }
  263.  
  264. public OnVehicleMod(playerid, vehicleid, componentid)
  265. {
  266. return 1;
  267. }
  268.  
  269. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  270. {
  271. return 1;
  272. }
  273.  
  274. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  275. {
  276. return 1;
  277. }
  278.  
  279. public OnPlayerSelectedMenuRow(playerid, row)
  280. {
  281. return 1;
  282. }
  283.  
  284. public OnPlayerExitedMenu(playerid)
  285. {
  286. return 1;
  287. }
  288.  
  289. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  290. {
  291. return 1;
  292. }
  293.  
  294. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  295. {
  296. return 1;
  297. }
  298.  
  299. public OnRconLoginAttempt(ip[], password[], success)
  300. {
  301. return 1;
  302. }
  303.  
  304. public OnPlayerUpdate(playerid)
  305. {
  306. return 1;
  307. }
  308.  
  309. public OnPlayerStreamIn(playerid, forplayerid)
  310. {
  311. return 1;
  312. }
  313.  
  314. public OnPlayerStreamOut(playerid, forplayerid)
  315. {
  316. return 1;
  317. }
  318.  
  319. public OnVehicleStreamIn(vehicleid, forplayerid)
  320. {
  321. return 1;
  322. }
  323.  
  324. public OnVehicleStreamOut(vehicleid, forplayerid)
  325. {
  326. return 1;
  327. }
  328.  
  329.  
  330. public UpdateSpeedo()
  331. {
  332. for(new i = 0;i<MAX_PLAYERS;i++)
  333. {
  334. if(IsPlayerConnected(i))
  335. {
  336. if(GetPlayerState(i)==2)
  337. {
  338.  
  339. new speed[128];
  340. new Float:xfloat,Float:yfloat,Float:zfloat;
  341. new Float:distance,value;
  342. GetPlayerPos(i, xfloat, yfloat, zfloat);
  343. distance = floatsqroot(floatpower(floatabs(floatsub(xfloat,TachoX[i])),2)+floatpower(floatabs(floatsub(yfloat,TachoY[i])),2)+floatpower(floatabs(floatsub(zfloat,TachoZ[i])),2));
  344. value = floatround(distance * 11000);
  345. TachoX[i] = xfloat;
  346. TachoY[i] = yfloat;
  347. TachoZ[i] = zfloat;
  348. format(speed,sizeof(speed),"%d",floatround(value/3200));
  349. TextDrawSetString(SpeedoKMH[i],speed);
  350. new namestring[128];
  351. format(namestring,sizeof(namestring),"%s",Vozila[GetVehicleModel(GetPlayerVehicleID(i))-400]);
  352. TextDrawSetString(SpeedoVeh[i],namestring);
  353. }
  354. }
  355. }
  356. return 1;
  357. }
  358.  
  359. public SpeedoMeter()
  360. {
  361. for(new i = 0; i < MAX_PLAYERS; i++)
  362. {
  363. if(IsPlayerConnected(i))
  364. {
  365. if(IsPlayerInAnyVehicle(i) && GetPlayerState(i) == 2)
  366. {
  367. new string[100];
  368. new vehicle = GetPlayerVehicleID(i);
  369. if(Gas[vehicle] <= 10)
  370. {
  371. format(string, sizeof(string), "%d%", Gas[vehicle]);
  372. TextDrawSetString(SpeedoTank[i], string);
  373. }
  374. else
  375. {
  376. format(string, sizeof(string), "%d%", Gas[vehicle]);
  377. TextDrawSetString(SpeedoTank[i], string);
  378. }
  379. }
  380. }
  381. }
  382. return 1;
  383. }
  384.  
  385. public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
  386. {
  387. if(IsPlayerConnected(playerid))
  388. {
  389. new Float:oldposx, Float:oldposy, Float:oldposz;
  390. new Float:tempposx, Float:tempposy, Float:tempposz;
  391. GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  392. tempposx = (oldposx -x);
  393. tempposy = (oldposy -y);
  394. tempposz = (oldposz -z);
  395. //printf("DEBUG: X:%f Y:%f Z:%f",posx,posy,posz);
  396. if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  397. {
  398. return 1;
  399. }
  400. }
  401. return 0;
  402. }
  403.  
  404. public CheckGas()
  405. {
  406. for(new i = 0; i < MAX_PLAYERS; i++)
  407. {
  408. if(IsPlayerConnected(i))
  409. {
  410. if(IsPlayerInAnyVehicle(i) && GetPlayerState(i) == 2)
  411. {
  412. new vehicle = GetPlayerVehicleID(i);
  413. if(Gas[vehicle] >= 1)
  414. {
  415. if(Gas[vehicle] <= 10)
  416. {
  417. PlayerPlaySound(i, 1085, 0.0, 0.0, 0.0);
  418. }
  419. Gas[vehicle]--;
  420. } else {
  421. TogglePlayerControllable(i, 0);
  422. GameTextForPlayer(i,"~n~~n~~n~~n~~n~~n~~n~~n~~r~Tvoj rezervoraj je prazan!~n~~w~/exit da izadete", 5000, 3);
  423. }
  424. }
  425. }
  426. }
  427. return 1;
  428. }
Advertisement
Add Comment
Please, Sign In to add comment