Advertisement
Guest User

Untitled

a guest
Sep 15th, 2017
409
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.52 KB | None | 0 0
  1. /////////////////////////PERFECT GAMES RPG/////////////////////////////
  2. //--- Izradio rootcause
  3. //--- Editovao Ross Viccy/Salvador
  4. //--- Skripta ima jos mozda kojih gresaka u prevodjenju pa provjerite
  5. ///////////////////////////////////////////////////////////////////////
  6. #define FILTERSCRIPT
  7. #include <a_samp>
  8. #include <streamer>
  9. #include <zcmd>
  10.  
  11. #define EVENT_WORLD 4 // virtualworld id of ship wars event
  12. #define EVENT_AMMO 5000 // how many ammo players will get for their weapons
  13. #define EVENT_ICONID 42 // mapicon id for finish icon (not the markertype) for removeplayermapicon
  14. #define EVENT_LIMIT 100 // max. number of people can join
  15. #define EVENT_DISTANCE 850.0
  16. #define DEFAULT_SPEED 7.0
  17.  
  18. #define WINNER_MONEY 25000 // how much money will winner team get
  19. #define WINNER_SCORE 0 // how much score will winner team get
  20.  
  21. #define SHIP_COLOR_RED 0xE74C3CFF // color of red team
  22. #define SHIP_COLOR_BLUE 0x3498DBFF // color of blue team
  23.  
  24. enum e_swteams
  25. {
  26. SHIP_RED,
  27. SHIP_BLUE
  28. }
  29.  
  30. enum e_teaminfo
  31. {
  32. ShipObject,
  33. Float: ShipSpeed,
  34. TeamPoint
  35. }
  36.  
  37. new
  38. PlayersInGame,
  39. ShipTimer = -1,
  40. bool: GameStarted,
  41. ShipWarsInfo[2][e_teaminfo],
  42. ShipTeam[MAX_PLAYERS] = {-1, ...},
  43. LastFallCheck[MAX_PLAYERS];
  44.  
  45. new
  46. Text: shipText[4],
  47. PlayerText: shipWithTeamColor[MAX_PLAYERS];
  48.  
  49. new
  50. EventWeapons[] = {WEAPON_DEAGLE, WEAPON_SHOTGSPA, WEAPON_M4, WEAPON_RIFLE};
  51. // will give player a deagle, combat shotgun, m4 and country rifle
  52. // https://wiki.sa-mp.com/wiki/Weapons
  53.  
  54. stock GivePoints(team, points)
  55. {
  56. new point_string[6];
  57. ShipWarsInfo[team][TeamPoint] += points;
  58. valstr(point_string, ShipWarsInfo[team][TeamPoint]);
  59. TextDrawSetString(shipText[ (team == _:SHIP_RED) ? 2 : 3 ], point_string);
  60.  
  61. if(ShipWarsInfo[team][TeamPoint] % 5 == 0 && ShipWarsInfo[team][ShipSpeed] < 20.0)
  62. {
  63. ShipWarsInfo[team][ShipSpeed] = floatadd(ShipWarsInfo[team][ShipSpeed], 0.75);
  64. if(ShipWarsInfo[team][ShipSpeed] > 20.0) ShipWarsInfo[team][ShipSpeed] = 20.0;
  65. new string[96];
  66. format(string, sizeof(string), "[%s TEAM] Mi dobijamo brzinu, pokusaj ih jos ubiti!", (team == _:SHIP_RED) ? ("Pirates of the Caribbean") : ("The Pirate Blackbeard"));
  67.  
  68. for(new i; i < GetMaxPlayers(); ++i)
  69. {
  70. if(!IsPlayerConnected(i)) continue;
  71. if(ShipTeam[i] == team) SendClientMessage(i, (team == _:SHIP_RED) ? SHIP_COLOR_RED : SHIP_COLOR_BLUE, string);
  72. }
  73.  
  74. StopDynamicObject(ShipWarsInfo[team][ShipObject]);
  75. MoveDynamicObject(ShipWarsInfo[team][ShipObject], (team == _:SHIP_RED) ? 402.896 : 352.896, floatsub(-2137.920, EVENT_DISTANCE), 17.415, ShipWarsInfo[team][ShipSpeed]);
  76. }
  77.  
  78. return 1;
  79. }
  80.  
  81. stock LeaveGame(playerid, reason = 0)
  82. {
  83. if(reason != 1)
  84. {
  85. RemovePlayerMapIcon(playerid, EVENT_ICONID);
  86. ResetPlayerWeapons(playerid);
  87. SetPlayerTeam(playerid, NO_TEAM);
  88. SetPlayerVirtualWorld(playerid, 0);
  89. SpawnPlayer(playerid);
  90. }
  91.  
  92. ShipTeam[playerid] = -1;
  93. PlayersInGame--;
  94.  
  95. if(PlayersInGame < 2 && reason < 2)
  96. {
  97. if(GameStarted) SendClientMessageToAll(-1, "[SHIP WARS] Event Zavrsen. (nema dovoljno igraca)");
  98. ResetGame();
  99. }
  100.  
  101. for(new i; i < sizeof(shipText); ++i) TextDrawHideForPlayer(playerid, shipText[i]);
  102. PlayerTextDrawHide(playerid, shipWithTeamColor[playerid]);
  103. PlayerTextDrawDestroy(playerid, shipWithTeamColor[playerid]);
  104. return 1;
  105. }
  106.  
  107. stock ResetGame(unload = 0)
  108. {
  109. for(new i; i < GetMaxPlayers(); ++i)
  110. {
  111. if(!IsPlayerConnected(i)) continue;
  112. if(ShipTeam[i] != -1) LeaveGame(i, 2);
  113. }
  114.  
  115. if(!unload)
  116. {
  117. if(ShipTimer != -1)
  118. {
  119. KillTimer(ShipTimer);
  120. ShipTimer = -1;
  121. }
  122.  
  123. GameStarted = false;
  124. PlayersInGame = 0;
  125. StopDynamicObject(ShipWarsInfo[SHIP_RED][ShipObject]);
  126. StopDynamicObject(ShipWarsInfo[SHIP_BLUE][ShipObject]);
  127. SetDynamicObjectPos(ShipWarsInfo[SHIP_RED][ShipObject], 402.896, -2137.920, 17.415);
  128. SetDynamicObjectPos(ShipWarsInfo[SHIP_BLUE][ShipObject], 352.896, -2137.920, 17.415);
  129. ShipWarsInfo[SHIP_RED][ShipSpeed] = DEFAULT_SPEED;
  130. ShipWarsInfo[SHIP_BLUE][ShipSpeed] = DEFAULT_SPEED;
  131. ShipWarsInfo[SHIP_RED][TeamPoint] = 0;
  132. ShipWarsInfo[SHIP_BLUE][TeamPoint] = 0;
  133.  
  134. TextDrawSetString(shipText[2], "0");
  135. TextDrawSetString(shipText[3], "0");
  136. }
  137.  
  138. return 1;
  139. }
  140.  
  141. public OnFilterScriptInit()
  142. {
  143. ShipWarsInfo[SHIP_RED][ShipObject] = CreateDynamicObject(8493, 402.896, -2137.920, 17.415, 0.000, 0.000, 180.000, EVENT_WORLD, 0);
  144. ShipWarsInfo[SHIP_BLUE][ShipObject] = CreateDynamicObject(8493, 352.896, -2137.920, 17.415, 0.000, 0.000, 180.000, EVENT_WORLD, 0);
  145. SetDynamicObjectMaterial(ShipWarsInfo[SHIP_RED][ShipObject], 2, -1, "none", "none", -1618884);
  146. SetDynamicObjectMaterial(ShipWarsInfo[SHIP_RED][ShipObject], 3, -1, "none", "none", -1618884);
  147. SetDynamicObjectMaterial(ShipWarsInfo[SHIP_BLUE][ShipObject], 2, -1, "none", "none", -13330213);
  148. SetDynamicObjectMaterial(ShipWarsInfo[SHIP_BLUE][ShipObject], 3, -1, "none", "none", -13330213);
  149.  
  150. ShipWarsInfo[SHIP_RED][ShipSpeed] = DEFAULT_SPEED;
  151. ShipWarsInfo[SHIP_BLUE][ShipSpeed] = DEFAULT_SPEED;
  152.  
  153. shipText[0] = TextDrawCreate(495.000000, 355.000000, "_");
  154. TextDrawBackgroundColor(shipText[0], 0);
  155. TextDrawFont(shipText[0], 5);
  156. TextDrawLetterSize(shipText[0], 0.500000, 1.000000);
  157. TextDrawColor(shipText[0], -414434049);
  158. TextDrawSetOutline(shipText[0], 0);
  159. TextDrawSetProportional(shipText[0], 1);
  160. TextDrawSetShadow(shipText[0], 1);
  161. TextDrawUseBox(shipText[0], 1);
  162. TextDrawBoxColor(shipText[0], 0);
  163. TextDrawTextSize(shipText[0], 16.000000, 16.000000);
  164. TextDrawSetPreviewModel(shipText[0], 1254);
  165. TextDrawSetPreviewRot(shipText[0], 0.000000, 0.000000, 0.000000, 0.875000);
  166. TextDrawSetSelectable(shipText[0], 0);
  167.  
  168. shipText[1] = TextDrawCreate(495.000000, 375.000000, "_");
  169. TextDrawBackgroundColor(shipText[1], 0);
  170. TextDrawFont(shipText[1], 5);
  171. TextDrawLetterSize(shipText[1], 0.500000, 1.000000);
  172. TextDrawColor(shipText[1], 882433023);
  173. TextDrawSetOutline(shipText[1], 0);
  174. TextDrawSetProportional(shipText[1], 1);
  175. TextDrawSetShadow(shipText[1], 1);
  176. TextDrawUseBox(shipText[1], 1);
  177. TextDrawBoxColor(shipText[1], 0);
  178. TextDrawTextSize(shipText[1], 16.000000, 16.000000);
  179. TextDrawSetPreviewModel(shipText[1], 1254);
  180. TextDrawSetPreviewRot(shipText[1], 0.000000, 0.000000, 0.000000, 0.875000);
  181. TextDrawSetSelectable(shipText[1], 0);
  182.  
  183. shipText[2] = TextDrawCreate(511.000000, 357.000000, "0");
  184. TextDrawBackgroundColor(shipText[2], 255);
  185. TextDrawFont(shipText[2], 1);
  186. TextDrawLetterSize(shipText[2], 0.210000, 1.100000);
  187. TextDrawColor(shipText[2], -414434049);
  188. TextDrawSetOutline(shipText[2], 1);
  189. TextDrawSetProportional(shipText[2], 1);
  190. TextDrawSetSelectable(shipText[2], 0);
  191.  
  192. shipText[3] = TextDrawCreate(511.000000, 377.000000, "0");
  193. TextDrawBackgroundColor(shipText[3], 255);
  194. TextDrawFont(shipText[3], 1);
  195. TextDrawLetterSize(shipText[3], 0.210000, 1.100000);
  196. TextDrawColor(shipText[3], 882433023);
  197. TextDrawSetOutline(shipText[3], 1);
  198. TextDrawSetProportional(shipText[3], 1);
  199. TextDrawSetSelectable(shipText[3], 0);
  200. return 1;
  201. }
  202.  
  203. public OnFilterScriptExit()
  204. {
  205. for(new i; i < sizeof(shipText); ++i)
  206. {
  207. TextDrawHideForAll(shipText[i]);
  208. TextDrawDestroy(shipText[i]);
  209. }
  210.  
  211. ResetGame(1);
  212. return 1;
  213. }
  214.  
  215. public OnPlayerConnect(playerid)
  216. {
  217. ShipTeam[playerid] = -1;
  218. LastFallCheck[playerid] = 0;
  219. return 1;
  220. }
  221.  
  222. public OnPlayerDisconnect(playerid, reason)
  223. {
  224. if(ShipTeam[playerid] != -1) LeaveGame(playerid, 1);
  225. return 1;
  226. }
  227.  
  228. public OnPlayerUpdate(playerid)
  229. {
  230. if(ShipTeam[playerid] != -1 && LastFallCheck[playerid] < tickcount())
  231. {
  232. LastFallCheck[playerid] = tickcount()+500;
  233.  
  234. new Float: temp, Float: z;
  235. GetPlayerPos(playerid, temp, temp, z);
  236. if(z < 3.0)
  237. {
  238. SetPlayerHealth(playerid, -1.0);
  239. GivePoints((ShipTeam[playerid] == _:SHIP_RED) ? SHIP_BLUE : SHIP_RED, 1);
  240. }
  241. }
  242.  
  243. return 1;
  244. }
  245.  
  246. public OnPlayerSpawn(playerid)
  247. {
  248. if(ShipTeam[playerid] != -1)
  249. {
  250. new Float: x, Float: y, Float: z;
  251. GetDynamicObjectPos(ShipWarsInfo[ ShipTeam[playerid] ][ShipObject], x, y, z);
  252. SetPlayerVirtualWorld(playerid, EVENT_WORLD);
  253. SetPlayerPos(playerid, x, y - (-22.22), 9.5);
  254. SetPlayerTeam(playerid, ShipTeam[playerid]);
  255. ResetPlayerWeapons(playerid);
  256. if(GameStarted) for(new i; i < sizeof(EventWeapons); ++i) GivePlayerWeapon(playerid, EventWeapons[i], EVENT_AMMO);
  257. }
  258.  
  259. return 1;
  260. }
  261.  
  262. public OnPlayerDeath(playerid, killerid, reason)
  263. {
  264. if(killerid != INVALID_PLAYER_ID && ShipTeam[playerid] != -1 && ShipTeam[killerid] != -1 && ShipTeam[playerid] != ShipTeam[killerid])
  265. {
  266. new Float: temp, Float: z;
  267. GetPlayerPos(playerid, temp, temp, z);
  268. if(z > 5.0) GivePoints(ShipTeam[killerid], 1);
  269. }
  270.  
  271. return 1;
  272. }
  273.  
  274. public OnDynamicObjectMoved(objectid)
  275. {
  276. new team = -1;
  277. if(objectid == ShipWarsInfo[SHIP_RED][ShipObject]) {
  278. team = SHIP_RED;
  279. }else if(objectid == ShipWarsInfo[SHIP_BLUE][ShipObject]) {
  280. team = SHIP_BLUE;
  281. }else{
  282. team = -1;
  283. }
  284.  
  285. if(team == -1) return 1;
  286. new Float: x, Float: y, Float: z, Float: fin_x = (team == _:SHIP_RED) ? 402.896 : 352.896, Float: fin_y = floatsub(-2137.920, EVENT_DISTANCE);
  287. GetDynamicObjectPos(objectid, x, y, z);
  288. new Float: dist = floatsqroot(floatpower(fin_x-x, 2.0) + floatpower(fin_y-y, 2.0));
  289. if(dist < 10.0)
  290. {
  291. if(ShipWarsInfo[SHIP_RED][ShipSpeed] == ShipWarsInfo[SHIP_BLUE][ShipSpeed])
  292. {
  293. if(ShipWarsInfo[SHIP_RED][TeamPoint] > ShipWarsInfo[SHIP_BLUE][TeamPoint]) {
  294. team = SHIP_RED;
  295. }else if(ShipWarsInfo[SHIP_BLUE][TeamPoint] > ShipWarsInfo[SHIP_RED][TeamPoint]) {
  296. team = SHIP_BLUE;
  297. }else if(ShipWarsInfo[SHIP_RED][TeamPoint] == ShipWarsInfo[SHIP_BLUE][TeamPoint]) {
  298. team = -1;
  299. }
  300. }
  301.  
  302. new string[128];
  303. if(team != -1) {
  304. for(new i; i < GetMaxPlayers(); ++i)
  305. {
  306. if(!IsPlayerConnected(i)) continue;
  307. if(ShipTeam[i] == team)
  308. {
  309. GivePlayerMoney(i, WINNER_MONEY);
  310. SetPlayerScore(i, GetPlayerScore(i) + WINNER_SCORE);
  311. }
  312. }
  313.  
  314. format(string, sizeof(string), "[SHIP WARS] Tim %s je pobjedio u Ship Wars eventu!", (team == _:SHIP_RED) ? ("Pirates of the Caribbean") : ("The Pirate Blackbeard"));
  315. SendClientMessageToAll((team == _:SHIP_RED) ? SHIP_COLOR_RED : SHIP_COLOR_BLUE, string);
  316. }else{
  317. SendClientMessageToAll(-1, "[SHIP WARS] Igra je zavrsila nerjeseno, Cestitke svima na dobroj igri.");
  318. }
  319.  
  320. ResetGame();
  321. }
  322.  
  323. return 1;
  324. }
  325.  
  326. forward StartGame(time, move);
  327. public StartGame(time, move)
  328. {
  329. if(move) {
  330. SendClientMessageToAll(-1, "[SHIP WARS] Event je pokrenut od strane servera. Za ucesce /shipwars!.");
  331. MoveDynamicObject(ShipWarsInfo[SHIP_RED][ShipObject], 402.896, floatsub(-2137.920, EVENT_DISTANCE), 17.415, ShipWarsInfo[SHIP_RED][ShipSpeed]);
  332. MoveDynamicObject(ShipWarsInfo[SHIP_BLUE][ShipObject], 352.896, floatsub(-2137.920, EVENT_DISTANCE), 17.415, ShipWarsInfo[SHIP_BLUE][ShipSpeed]);
  333. }else{
  334. if(time > 1) {
  335. time--;
  336. new string[54];
  337. format(string, sizeof(string), "~n~~w~pokretanje ~r~~h~%d ~n~~g~~h~budi spreman!", time);
  338.  
  339. for(new i; i < GetMaxPlayers(); ++i)
  340. {
  341. if(!IsPlayerConnected(i)) continue;
  342. if(ShipTeam[i] == -1) continue;
  343. PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
  344. GameTextForPlayer(i, string, 1000, 3);
  345. }
  346.  
  347. ShipTimer = SetTimerEx("StartGame", 1000, false, "ii", time, 0);
  348. }else if(time == 1) {
  349. if(PlayersInGame < 2) {
  350. SendClientMessageToAll(-1, "[SHIP WARS] Event je zavrsio (Nema dovoljno igraca)");
  351. ResetGame();
  352. }else{
  353. GameStarted = true;
  354.  
  355. for(new i; i < GetMaxPlayers(); ++i)
  356. {
  357. if(!IsPlayerConnected(i)) continue;
  358. if(ShipTeam[i] == -1) continue;
  359. PlayerPlaySound(i, 1057, 0.0, 0.0, 0.0);
  360. for(new x; x < sizeof(EventWeapons); ++x) GivePlayerWeapon(i, EventWeapons[x], EVENT_AMMO);
  361. }
  362.  
  363. SendClientMessageToAll(-1, "[SHIP WARS] Brodovi ce se poceti kretati za 3sekunde.");
  364. ShipTimer = SetTimerEx("StartGame", 3000, false, "ii", 0, 1);
  365. }
  366. }
  367. }
  368.  
  369.  
  370. return 1;
  371. }
  372.  
  373. CMD:shipwars(playerid, params[])
  374. {
  375. if(GameStarted) return SendClientMessage(playerid, 0xE74C3CFF, "[ERROR] {FFFFFF}Ne mozes sada na Ship Wars event.");
  376. if(ShipTeam[playerid] != -1) return SendClientMessage(playerid, 0xE74C3CFF, "[ERROR] {FFFFFF}Vec si na eventu.");
  377. if(PlayersInGame >= EVENT_LIMIT) return SendClientMessage(playerid, 0xE74C3CFF, "[ERROR] {FFFFFF}Brodovi su popunjeni.");
  378. new team = (PlayersInGame % 2 == 0) ? SHIP_RED : SHIP_BLUE;
  379. ShipTeam[playerid] = team;
  380. SetPlayerVirtualWorld(playerid, EVENT_WORLD);
  381. SetPlayerPos(playerid, (team == _:SHIP_RED) ? 402.896 : 352.896, -2109.0, 9.0);
  382. SetPlayerTeam(playerid, team);
  383. ResetPlayerWeapons(playerid);
  384. PlayersInGame++;
  385. new string[128], name[MAX_PLAYER_NAME];
  386. GetPlayerName(playerid, name, MAX_PLAYER_NAME);
  387.  
  388. if(PlayersInGame == 1) {
  389. ShipTimer = SetTimerEx("StartGame", 1000, false, "ii", 20, 0);
  390. format(string, sizeof(string), "[SHIP WARS] %s(%d) je pokrenuo ship wars, mozes se pridruziti na event narednih 20sec.", name, playerid);
  391. }else{
  392. format(string, sizeof(string), "[SHIP WARS] %s(%d) se pridruzio. (Team %s) [%d/%d]", name, playerid, (team == _:SHIP_RED) ? ("Pirates of the Caribbean") : ("The Pirate Blackbeard"), PlayersInGame, EVENT_LIMIT);
  393. }
  394.  
  395. SendClientMessageToAll(-1, string);
  396. SendClientMessage(playerid, (team == _:SHIP_RED) ? SHIP_COLOR_RED : SHIP_COLOR_BLUE, "NAPOMENA: Ubijaj neprijatelje kako bih ubrzao svoj brod, ko prvi dodje do kraja, pobjednik!");
  397. SendClientMessage(playerid, (team == _:SHIP_RED) ? SHIP_COLOR_RED : SHIP_COLOR_BLUE, "Oruzje ce vam se setovati kada odbrojavanje zavrsi.");
  398. SendClientMessage(playerid, (team == _:SHIP_RED) ? SHIP_COLOR_RED : SHIP_COLOR_BLUE, "Mozete napustiti event komandom /izadjisw.");
  399. SetPlayerMapIcon(playerid, EVENT_ICONID, (team == _:SHIP_RED) ? 402.896 : 352.896, floatsub(-2137.920, EVENT_DISTANCE), 17.415, 53, 0, MAPICON_GLOBAL);
  400.  
  401. shipWithTeamColor[playerid] = CreatePlayerTextDraw(playerid, 493.000000, 310.000000, "_");
  402. PlayerTextDrawBackgroundColor(playerid, shipWithTeamColor[playerid], 0);
  403. PlayerTextDrawFont(playerid, shipWithTeamColor[playerid], 5);
  404. PlayerTextDrawLetterSize(playerid, shipWithTeamColor[playerid], 0.500000, 1.000000);
  405. PlayerTextDrawColor(playerid, shipWithTeamColor[playerid], (team == _:SHIP_RED) ? SHIP_COLOR_RED : SHIP_COLOR_BLUE);
  406. PlayerTextDrawSetOutline(playerid, shipWithTeamColor[playerid], 0);
  407. PlayerTextDrawSetProportional(playerid, shipWithTeamColor[playerid], 1);
  408. PlayerTextDrawSetShadow(playerid, shipWithTeamColor[playerid], 1);
  409. PlayerTextDrawUseBox(playerid, shipWithTeamColor[playerid], 1);
  410. PlayerTextDrawBoxColor(playerid, shipWithTeamColor[playerid], 0);
  411. PlayerTextDrawTextSize(playerid, shipWithTeamColor[playerid], 130.000000, 130.000000);
  412. PlayerTextDrawSetPreviewModel(playerid, shipWithTeamColor[playerid], 8493);
  413. PlayerTextDrawSetPreviewRot(playerid, shipWithTeamColor[playerid], 0.000000, 0.000000, -60.000000, 0.574999);
  414. PlayerTextDrawSetSelectable(playerid, shipWithTeamColor[playerid], 0);
  415.  
  416. for(new i; i < sizeof(shipText); ++i) TextDrawShowForPlayer(playerid, shipText[i]);
  417. PlayerTextDrawShow(playerid, shipWithTeamColor[playerid]);
  418. return 1;
  419. }
  420.  
  421. CMD:izadjisw(playerid, params[])
  422. {
  423. if(ShipTeam[playerid] == -1) return SendClientMessage(playerid, 0xE74C3CFF, "[Greska] {FFFFFF}Nisi bio na eventu.");
  424. if(!GameStarted) return SendClientMessage(playerid, 0xE74C3CFF, "[Greska] {FFFFFF}Ne mozes u ovoj fazi napustiti ratne brodove.");
  425. LeaveGame(playerid);
  426. return 1;
  427. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement