Guest User

Luke hawkrpcom

a guest
Sep 8th, 2009
530
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.78 KB | None | 0 0
  1. #include <a_samp>
  2. #include <core>
  3. #include <float>
  4.  
  5. #pragma tabsize 0
  6.  
  7. #define COLOR_GREY 0xAFAFAFAA
  8. #define COLOR_GREEN 0x33AA33AA
  9. #define COLOR_RED 0xAA3333AA
  10. #define COLOR_YELLOW 0xFFFF00AA
  11. #define COLOR_WHITE 0xFFFFFFAA
  12. #define PocketMoney 5000 //Spawn Money
  13. #define INACTIVE_PLAYER_ID 255
  14. #define GIVECASH_DELAY 5000
  15.  
  16. #define NUMVALUES 4
  17.  
  18. forward MoneyGrubScoreUpdate();
  19. forward Givecashdelaytimer(playerid);
  20. forward SetPlayerRandomSpawn(playerid);
  21. forward SetupPlayerForClassSelection(playerid);
  22. forward GameModeExitFunc();
  23. forward SendPlayerFormattedText(playerid, const str[], define);
  24. forward public SendAllFormattedText(playerid, const str[], define);
  25.  
  26. //------------------------------------------------------------------------------------------------------
  27.  
  28. new CashScoreOld;
  29. new iSpawnSet[MAX_PLAYERS];
  30.  
  31. new Float:gRandomPlayerSpawns[7][3] = {
  32. {2006.1472,-2344.7959,13.5469},
  33. {2001.7155,-2289.6697,13.5469},
  34. {1959.5466,-2245.2151,13.5469},
  35. {1900.1530,-2239.2261,13.5469},
  36. {1882.0526,-2310.1973,13.5469},
  37. {1879.8099,-2348.6899,13.5469},
  38. {1884.3619,-2400.3230,13.5547}
  39. };
  40.  
  41. new Float:gCopPlayerSpawns[1][3] = {
  42. {2297.1064,2452.0115,10.8203}
  43. };
  44.  
  45. new gActivePlayers[MAX_PLAYERS];
  46. new gLastGaveCash[MAX_PLAYERS];
  47.  
  48. //------------------------------------------------------------------------------------------------------
  49.  
  50. main()
  51. {
  52. print(" ");
  53. print(" ");
  54. print(" ==================");
  55. print(" ");
  56. print(" Sky Fight 1.3");
  57. print(" Created By: Luke");
  58. print(" ");
  59. print(" ==================");
  60. print(" ");
  61. print(" ");
  62. }
  63.  
  64. //------------------------------------------------------------------------------------------------------
  65.  
  66. public MoneyGrubScoreUpdate()
  67. {
  68. new CashScore;
  69. new name[MAX_PLAYER_NAME];
  70. for(new i=0; i<MAX_PLAYERS; i++)
  71. {
  72. if (IsPlayerConnected(i))
  73. {
  74. GetPlayerName(i, name, sizeof(name));
  75. CashScore = GetPlayerMoney(i);
  76. SetPlayerScore(i, CashScore);
  77. if (CashScore > CashScoreOld)
  78. {
  79. CashScoreOld = CashScore;
  80. }
  81. }
  82. }
  83. }
  84.  
  85. //------------------------------------------------------------------------------------------------------
  86.  
  87. public OnPlayerConnect(playerid)
  88. {
  89. GameTextForPlayer(playerid,"~n~ ~n~ ~w~Welcome To ~r~Sky Fight ~w~v1.3",16000,5);
  90. SendPlayerFormattedText(playerid, "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=", 0);
  91. SendPlayerFormattedText(playerid, "Welcome to Sky Fight (v1.3)", 0);
  92. SendPlayerFormattedText(playerid, "If you need help type /help", 0);
  93. SendPlayerFormattedText(playerid, "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=", 0);
  94. gActivePlayers[playerid]++;
  95. gLastGaveCash[playerid] = GetTickCount();
  96. return 1;
  97. }
  98.  
  99. //------------------------------------------------------------------------------------------------------
  100.  
  101. public OnPlayerDisconnect(playerid)
  102. {
  103. gActivePlayers[playerid]--;
  104. }
  105.  
  106. //------------------------------------------------------------------------------------------------------
  107.  
  108. public OnPlayerCommandText(playerid, cmdtext[])
  109. {
  110. new string[256];
  111. new playermoney;
  112. new sendername[MAX_PLAYER_NAME];
  113. new giveplayer[MAX_PLAYER_NAME];
  114. new cmd[256];
  115. new giveplayerid, moneys, idx;
  116.  
  117. cmd = strtok(cmdtext, idx);
  118.  
  119. if(strcmp(cmd, "/help", true) == 0) {
  120. SendPlayerFormattedText(playerid,"New to Sky Fight? Well, the objective is simple.",0);
  121. SendPlayerFormattedText(playerid,"Grab a Plane/Helicopter and hit the skies!",0);
  122. SendPlayerFormattedText(playerid,"Kill everyone and anyone else that comes in YOUR sky!",0);
  123. SendPlayerFormattedText(playerid,"",0);
  124. SendPlayerFormattedText(playerid,"Your the king of the skies, so prove it to everyone else by", 0);
  125. SendPlayerFormattedText(playerid,"simply killing everyone else with your Plane/Helicopter!",0);
  126. return 1;
  127. }
  128. if(strcmp(cmd, "/rules", true) == 0) {
  129. SendPlayerFormattedText(playerid,"Although we don't have many rules, the ones we have you NEED to follow.",0);
  130. SendPlayerFormattedText(playerid," 1. No Hacking/Cheating/Bug Abusing or anything of the sort.",0);
  131. SendPlayerFormattedText(playerid," 2. Be a good sport, don't flame or yell at other players.",0);
  132. SendPlayerFormattedText(playerid," 3. Simply have Fun!", 0);
  133. return 1;
  134. }
  135.  
  136. if(strcmp(cmd, "/pay", true) == 0) {
  137. new tmp[256];
  138. tmp = strtok(cmdtext, idx);
  139.  
  140. if(!strlen(tmp)) {
  141. SendClientMessage(playerid, COLOR_WHITE, "USAGE: /pay [PlayerID] [Amount]");
  142. return 1;
  143. }
  144. giveplayerid = strval(tmp);
  145.  
  146. tmp = strtok(cmdtext, idx);
  147. if(!strlen(tmp)) {
  148. SendClientMessage(playerid, COLOR_WHITE, "USAGE: /pay [PlayerID] [Amount]");
  149. return 1;
  150. }
  151. moneys = strval(tmp);
  152.  
  153.  
  154.  
  155. if (IsPlayerConnected(giveplayerid)) {
  156. GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
  157. GetPlayerName(playerid, sendername, sizeof(sendername));
  158. playermoney = GetPlayerMoney(playerid);
  159. if (moneys > 0 && playermoney >= moneys) {
  160. GivePlayerMoney(playerid, (0 - moneys));
  161. GivePlayerMoney(giveplayerid, moneys);
  162. format(string, sizeof(string), " *You have sent %s(player: %d), $%d.", giveplayer,giveplayerid, moneys);
  163. SendClientMessage(playerid, COLOR_YELLOW, string);
  164. format(string, sizeof(string), " *You have recieved $%d from %s(player: %d).", moneys, sendername, playerid);
  165. SendClientMessage(giveplayerid, COLOR_YELLOW, string);
  166. printf(" *%s(playerid:%d) has transfered %d to %s(playerid:%d)",sendername, playerid, moneys, giveplayer, giveplayerid);
  167. }
  168. else {
  169. SendClientMessage(playerid, COLOR_YELLOW, "Invalid transaction amount.");
  170. }
  171. }
  172. else {
  173. format(string, sizeof(string), "%d is not an active player.", giveplayerid);
  174. SendClientMessage(playerid, COLOR_YELLOW, string);
  175. }
  176. return 1;
  177. }
  178.  
  179. return 0;
  180. }
  181.  
  182. //------------------------------------------------------------------------------------------------------
  183.  
  184. public OnPlayerSpawn(playerid)
  185. {
  186. SetPlayerWorldBounds(playerid, 2353.109, 1208.455, -2056.897, -2988.564);
  187. GivePlayerMoney(playerid, PocketMoney);
  188. SetPlayerInterior(playerid,0);
  189. SetPlayerRandomSpawn(playerid);
  190. TogglePlayerClock(playerid,1);
  191. return 1;
  192. }
  193.  
  194. public SetPlayerRandomSpawn(playerid)
  195. {
  196. if (iSpawnSet[playerid] == 1)
  197. {
  198. new rand = random(sizeof(gCopPlayerSpawns));
  199. SetPlayerPos(playerid, gCopPlayerSpawns[rand][0], gCopPlayerSpawns[rand][1], gCopPlayerSpawns[rand][2]); // Warp the player
  200. SetPlayerFacingAngle(playerid, 270.0);
  201. }
  202. else if (iSpawnSet[playerid] == 0)
  203. {
  204. new rand = random(sizeof(gRandomPlayerSpawns));
  205. SetPlayerPos(playerid, gRandomPlayerSpawns[rand][0], gRandomPlayerSpawns[rand][1], gRandomPlayerSpawns[rand][2]); // Warp the player
  206. }
  207. return 1;
  208. }
  209.  
  210. //------------------------------------------------------------------------------------------------------
  211.  
  212. public OnPlayerDeath(playerid, killerid, reason)
  213. {
  214. new name[MAX_PLAYER_NAME];
  215. new string[256];
  216. new deathreason[20];
  217. new playercash;
  218. GetPlayerName(playerid, name, sizeof(name));
  219. GetWeaponName(reason, deathreason, 20);
  220. if (killerid == INVALID_PLAYER_ID) {
  221. switch (reason) {
  222. case WEAPON_DROWN:
  223. {
  224. format(string, sizeof(string), " ** %s drowned.)", name);
  225. }
  226. default:
  227. {
  228. if (strlen(deathreason) > 0) {
  229. format(string, sizeof(string), " ** %s died. (%s)", name, deathreason);
  230. } else {
  231. format(string, sizeof(string), " ** %s died.", name);
  232. }
  233. }
  234. }
  235. }
  236. else {
  237. new killer[MAX_PLAYER_NAME];
  238. GetPlayerName(killerid, killer, sizeof(killer));
  239. if (strlen(deathreason) > 0) {
  240. format(string, sizeof(string), " ** %s killed %s. (%s)", killer, name, deathreason);
  241. } else {
  242. format(string, sizeof(string), " ** %s killed %s.", killer, name);
  243. }
  244. }
  245. SendClientMessageToAll(COLOR_RED, string);
  246. {
  247. playercash = GetPlayerMoney(playerid);
  248. if (playercash > 0)
  249. {
  250. GivePlayerMoney(killerid, playercash);
  251. ResetPlayerMoney(playerid);
  252. }
  253. else
  254. {
  255. }
  256. }
  257. if(killerid == INVALID_PLAYER_ID) {
  258. SendDeathMessage(INVALID_PLAYER_ID,playerid,reason);
  259. ResetPlayerMoney(playerid);
  260. } else {
  261. SendDeathMessage(killerid,playerid,reason);
  262. SetPlayerScore(killerid,GetPlayerScore(killerid)+1);
  263. playercash = GetPlayerMoney(playerid);
  264. if (playercash > 0) {
  265. GivePlayerMoney(killerid, playercash);
  266. ResetPlayerMoney(playerid);
  267. }
  268. else
  269. {
  270. }
  271. }
  272. return 1;
  273. }
  274.  
  275. //------------------------------------------------------------------------------------------------------
  276.  
  277. public OnPlayerRequestClass(playerid, classid)
  278. {
  279. iSpawnSet[playerid] = 0;
  280. SetupPlayerForClassSelection(playerid);
  281. return 1;
  282. }
  283.  
  284. public SetupPlayerForClassSelection(playerid)
  285. {
  286. SetPlayerInterior(playerid,0);
  287. SetPlayerPos(playerid,1629.8392,-2288.5488,94.1328);
  288. SetPlayerFacingAngle(playerid, 45.9620);
  289. SetPlayerCameraPos(playerid,1628.1469,-2287.2246,95.2250);
  290. SetPlayerCameraLookAt(playerid,1629.8392,-2288.5488,94.1328);
  291. }
  292.  
  293. public GameModeExitFunc()
  294. {
  295. GameModeExit();
  296. }
  297.  
  298. public OnGameModeInit()
  299. {
  300. SetGameModeText("Sky Fight");
  301.  
  302. ShowPlayerMarkers(1);
  303. ShowNameTags(1);
  304.  
  305.  
  306. // Player Class's
  307.  
  308. AddPlayerClass(285,1958.3783,1343.1572,15.3746,270.1425,46,1,0,0,-1,-1);
  309. AddPlayerClass(287,1958.3783,1343.1572,15.3746,270.1425,46,1,0,0,-1,-1);
  310. AddPlayerClass(270,1958.3783,1343.1572,15.3746,270.1425,46,1,0,0,-1,-1);
  311. AddPlayerClass(271,1958.3783,1343.1572,15.3746,270.1425,46,1,0,0,-1,-1);
  312. AddPlayerClass(269,1958.3783,1343.1572,15.3746,270.1425,46,1,0,0,-1,-1);
  313. AddPlayerClass(276,1958.3783,1343.1572,15.3746,270.1425,46,1,0,0,-1,-1);
  314. AddPlayerClass(275,1958.3783,1343.1572,15.3746,270.1425,46,1,0,0,-1,-1);
  315. AddPlayerClass(248,1958.3783,1343.1572,15.3746,270.1425,46,1,0,0,-1,-1);
  316. AddPlayerClass(100,1958.3783,1343.1572,15.3746,270.1425,46,1,0,0,-1,-1);
  317. AddPlayerClass(247,1958.3783,1343.1572,15.3746,270.1425,46,1,0,0,-1,-1);
  318. AddPlayerClass(204,1958.3783,1343.1572,15.3746,270.1425,46,1,0,0,-1,-1);
  319. AddPlayerClass(203,1958.3783,1343.1572,15.3746,270.1425,46,1,0,0,-1,-1);
  320. AddPlayerClass(173,1958.3783,1343.1572,15.3746,270.1425,46,1,0,0,-1,-1);
  321. AddPlayerClass(175,1958.3783,1343.1572,15.3746,270.1425,46,1,0,0,-1,-1);
  322. AddPlayerClass(174,1958.3783,1343.1572,15.3746,270.1425,46,1,0,0,-1,-1);
  323. AddPlayerClass(102,1958.3783,1343.1572,15.3746,270.1425,46,1,0,0,-1,-1);
  324. AddPlayerClass(104,1958.3783,1343.1572,15.3746,270.1425,46,1,0,0,-1,-1);
  325. AddPlayerClass(103,1958.3783,1343.1572,15.3746,270.1425,46,1,0,0,-1,-1);
  326. AddPlayerClass(109,1958.3783,1343.1572,15.3746,270.1425,46,1,0,0,-1,-1);
  327. AddPlayerClass(108,1958.3783,1343.1572,15.3746,270.1425,46,1,0,0,-1,-1);
  328. AddPlayerClass(110,1958.3783,1343.1572,15.3746,270.1425,46,1,0,0,-1,-1);
  329. AddPlayerClass(116,1958.3783,1343.1572,15.3746,270.1425,46,1,0,0,-1,-1);
  330. AddPlayerClass(114,1958.3783,1343.1572,15.3746,270.1425,46,1,0,0,-1,-1);
  331. AddPlayerClass(115,1958.3783,1343.1572,15.3746,270.1425,46,1,0,0,-1,-1);
  332. AddPlayerClass(122,1958.3783,1343.1572,15.3746,270.1425,46,1,0,0,-1,-1);
  333. AddPlayerClass(123,1958.3783,1343.1572,15.3746,270.1425,46,1,0,0,-1,-1);
  334. AddPlayerClass(120,1958.3783,1343.1572,15.3746,270.1425,46,1,0,0,-1,-1);
  335. AddPlayerClass(299,1958.3783,1343.1572,15.3746,270.1425,46,1,0,0,-1,-1);
  336. AddPlayerClass(297,1958.3783,1343.1572,15.3746,270.1425,46,1,0,0,-1,-1);
  337. AddPlayerClass(268,1958.3783,1343.1572,15.3746,270.1425,46,1,0,0,-1,-1);
  338. AddPlayerClass(292,1958.3783,1343.1572,15.3746,270.1425,46,1,0,0,-1,-1);
  339. AddPlayerClass(169,1958.3783,1343.1572,15.3746,270.1425,46,1,0,0,-1,-1);
  340. AddPlayerClass(56,1958.3783,1343.1572,15.3746,270.1425,46,1,0,0,-1,-1);
  341.  
  342.  
  343.  
  344. // Car Spawns
  345.  
  346. AddStaticVehicle(476,1901.6326,-2281.7292,14.2519,207.4987,7,6); // RUSTLER Plane 1
  347. AddStaticVehicle(476,1915.5544,-2274.7009,14.2515,194.9342,1,6); // RUSTLER Plane 2
  348. AddStaticVehicle(476,1930.6199,-2268.5801,14.2507,183.4229,89,91); // RUSTLER Plane 3
  349. AddStaticVehicle(476,1946.9194,-2266.3423,14.2524,175.6082,119,117); // RUSTLER Plane 4
  350. AddStaticVehicle(476,1963.5221,-2267.8687,14.2506,164.4326,103,102); // RUSTLER Plane 5
  351. AddStaticVehicle(476,1978.1501,-2272.1570,14.2482,156.1803,77,87); // RUSTLER Plane 6
  352. AddStaticVehicle(425,1878.8654,-2365.2329,14.4373,231.1387,43,0); // HUNTER Helicopter 1
  353. AddStaticVehicle(425,1862.1017,-2378.8735,14.1304,237.1812,43,0); // HUNTER Helicopter 2
  354. AddStaticVehicle(520,1869.7185,-2444.6877,14.2844,262.3140,0,0); // HYDRA 1
  355. AddStaticVehicle(520,1865.8258,-2432.7229,14.2776,256.8309,0,0); // HYDRA 2
  356. AddStaticVehicle(476,1995.9371,-2380.2893,14.2363,89.7214,6,7); // RUSTLER 7
  357. AddStaticVehicle(476,1994.6183,-2398.4636,14.2433,89.2167,71,77); // RUSTLER 8
  358. AddStaticVehicle(476,1996.4241,-2321.9807,14.2489,90.1316,7,6); // RUSTLER 9
  359. AddStaticVehicle(476,1992.9398,-2304.1401,14.2528,105.1293,1,6); // RUSTLER 10
  360.  
  361.  
  362.  
  363. // Pickups
  364.  
  365. AddStaticPickup(356, 15, 1853.9034,-2328.6262,13.5469); //HIDDEN GUN M4
  366. AddStaticPickup(361, 15, 1385.2852,-2586.4070,13.5469); //HIDDEN GUN FLAMETHROWER
  367. AddStaticPickup(359, 15, 1524.0764,-2392.8154,13.5547); //HIDDEN GUN RPG
  368.  
  369. SetTimer("MoneyUpdate", 1000, 1);
  370.  
  371. return 1;
  372. }
  373.  
  374. public SendPlayerFormattedText(playerid, const str[], define)
  375. {
  376. new tmpbuf[256];
  377. format(tmpbuf, sizeof(tmpbuf), str, define);
  378. SendClientMessage(playerid, 0xFF004040, tmpbuf);
  379. }
  380.  
  381. public SendAllFormattedText(playerid, const str[], define)
  382. {
  383. new tmpbuf[256];
  384. format(tmpbuf, sizeof(tmpbuf), str, define);
  385. SendClientMessageToAll(0xFFFF00AA, tmpbuf);
  386. }
  387.  
  388. strtok(const string[], &index)
  389. {
  390. new length = strlen(string);
  391. while ((index < length) && (string[index] <= ' '))
  392. {
  393. index++;
  394. }
  395.  
  396. new offset = index;
  397. new result[20];
  398. while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  399. {
  400. result[index - offset] = string[index];
  401. index++;
  402. }
  403. result[index - offset] = EOS;
  404. return result;
  405. }
Advertisement
Add Comment
Please, Sign In to add comment