Guest User

Pirates Team Deathmatch

a guest
Oct 22nd, 2013
530
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.87 KB | None | 0 0
  1. //Pirates TDM by TonyII
  2. //==========================[INCLUDES]=======================
  3. #include <a_samp>
  4. #include <YSI\y_ini>
  5. #include <zcmd>
  6. #include <sscanf2>
  7. //==========================[COLORS]=========================
  8. #define COLOR_ORANGE 0xFF8000FF
  9. #define COLOR_WHITE 0xFFFFFFAA
  10. #define COLOR_GREY 0xAFAFAFFF
  11. #define COLOR_RED 0xFF0606FF
  12. #define COLOR_BLUE 0x2641FEFF
  13. //==========================[PATHS]==========================
  14. #define PATH "/users/%s.ini"
  15. //==========================[DIALOGS]========================
  16. #define DIALOG_REGISTER 1
  17. #define DIALOG_LOGIN 2
  18. //==========================[TEAMS]==========================
  19. #define TEAM_RED 1
  20. #define TEAM_BLUE 2
  21. //==========================[VARIABLES]======================
  22. new Team[MAX_PLAYERS];
  23. new Canon[MAX_PLAYERS];
  24. new Float:OldHP[MAX_PLAYERS];
  25. new ControllingRedShip[MAX_PLAYERS];
  26. new ControllingBlueShip[MAX_PLAYERS];
  27. new ShipRed;
  28. new SailRed;
  29. new FenceRed;
  30. new ObjectRed;
  31. new ShipBlue;
  32. new SailBlue;
  33. new FenceBlue;
  34. new ObjectBlue;
  35. new bCamera;
  36. new rCamera;
  37. //==========================[ENUMS]==========================
  38. enum pInfo
  39. {
  40. pCoins,
  41. pAdmin,
  42. pPass,
  43. pLevel,
  44. };
  45. new PlayerInfo[MAX_PLAYERS][pInfo];
  46. //==========================[MAIN]============================
  47. main()
  48. {
  49. print("\n----------------------------------");
  50. print("Pirate TDM by TonyII");
  51. print("----------------------------------\n");
  52. }
  53. //==========================[STOCKS]==========================
  54. stock GPN(playerid)
  55. {
  56. new name[MAX_PLAYER_NAME];
  57. GetPlayerName(playerid,name,sizeof(name));
  58. return name;
  59. }
  60.  
  61. stock UserPath(playerid)
  62. {
  63. new string[128],playername[MAX_PLAYER_NAME];
  64. GetPlayerName(playerid,playername,sizeof(playername));
  65. format(string,sizeof(string),PATH,playername);
  66. return string;
  67. }
  68.  
  69. stock udb_hash(buf[])
  70. {
  71. new length=strlen(buf);
  72. new s1 = 1;
  73. new s2 = 0;
  74. new n;
  75. for (n=0; n<length; n++)
  76. {
  77. s1 = (s1 + buf[n]) % 65521;
  78. s2 = (s2 + s1) % 65521;
  79. }
  80. return (s2 << 16) + s1;
  81. }
  82. //==========================[PUBLICS]=========================
  83. forward LoadUser_Data(playerid,name[],value[]);
  84. public LoadUser_Data(playerid,name[],value[])
  85. {
  86. INI_Int("Coins",PlayerInfo[playerid][pCoins]);
  87. INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
  88. INI_Int("Level",PlayerInfo[playerid][pLevel]);
  89. INI_Int("Password",PlayerInfo[playerid][pPass]);
  90. return 1;
  91. }
  92.  
  93. forward Kicked(playerid);
  94. public Kicked(playerid)
  95. {
  96. Kick(playerid);
  97. return 1;
  98. }
  99.  
  100. forward Banned(playerid);
  101. public Banned(playerid)
  102. {
  103. Ban(playerid);
  104. return 1;
  105. }
  106.  
  107. public OnGameModeInit()
  108. {
  109. SetGameModeText("Pirates TDM v1.0");
  110. SendRconCommand("hostname [ENG]** Pirates TDM **");
  111. SendRconCommand("weburl www.sa-mp.com");
  112. SendRconCommand("mapname Ocean");
  113. AddPlayerClass(19,2431.3733,-1679.4271,13.7673,0,24,100,0,0,0,0); //RED
  114. AddPlayerClass(21,2167.8926,-1670.0753,15.0805,0,24,100,0,0,0,0); //BLUE
  115. DisableInteriorEnterExits();
  116. ObjectRed = CreateObject(8493,0,0,-100,0,0,0);
  117. FenceRed = CreateObject(9159,0,0,-100,0,0,0);
  118. SailRed = CreateObject(8981,0,0,-100,0,0,0);
  119. ShipRed = AddStaticVehicleEx(454, 105.6520, -3990.7867, -0.0164, 180.0000, -1, -1, -1);
  120. ObjectBlue = CreateObject(8493,0,0,-100,0,0,0);
  121. FenceBlue = CreateObject(9159,0,0,-100,0,0,0);
  122. SailBlue = CreateObject(8981,0,0,-100,0,0,0);
  123. ShipBlue = AddStaticVehicleEx(454, 133.6520, -3990.7867, -0.0164, 180.0000, -1, -1, -1);
  124. AttachObjectToVehicle(ObjectRed, ShipRed, 0.809999, 1.439998, 16.650209, 0.000000, 0.000000, 0.000000);
  125. AttachObjectToVehicle(SailRed, ShipRed, 0.294999, -4.665059, 16.250276, 0.000000, 0.000000, 0.000000);
  126. AttachObjectToVehicle(FenceRed, ShipRed, 0.784999, 1.439998, 16.655208, 0.000000, 0.000000, 0.000000);
  127. AttachObjectToVehicle(ObjectBlue, ShipBlue, 0.809999, 1.439998, 16.650209, 0.000000, 0.000000, 0.000000);
  128. AttachObjectToVehicle(SailBlue, ShipBlue, 0.294999, -4.665059, 16.250276, 0.000000, 0.000000, 0.000000);
  129. AttachObjectToVehicle(FenceBlue, ShipBlue, 0.784999, 1.439998, 16.655208, 0.000000, 0.000000, 0.000000);
  130. LinkVehicleToInterior(ShipRed,1);
  131. LinkVehicleToInterior(ShipBlue,1);
  132. SetVehicleHealth(ShipRed,999999);
  133. SetVehicleHealth(ShipBlue,999999);
  134. return 1;
  135. }
  136.  
  137. public OnGameModeExit()
  138. {
  139. return 1;
  140. }
  141.  
  142. public OnPlayerCommandPerformed(playerid, cmdtext[], success)
  143. {
  144. if(!success)
  145. SendClientMessage(playerid,COLOR_BLUE, "[P:TDM]{AFAFAF} Unknown command.");
  146. return 1;
  147. }
  148.  
  149. public OnPlayerRequestClass(playerid, classid)
  150. {
  151. switch(classid)
  152. {
  153. case 0:
  154. {
  155. GameTextForPlayer(playerid,"~r~TEAM RED",300,3);
  156. SetPlayerColor(playerid,COLOR_RED);
  157. Team[playerid] = TEAM_RED;
  158. }
  159. case 1:
  160. {
  161. GameTextForPlayer(playerid,"~b~TEAM BLUE",300,3);
  162. SetPlayerColor(playerid,COLOR_BLUE);
  163. Team[playerid] = TEAM_BLUE;
  164. }
  165. }
  166. SetPlayerPos(playerid, 546.3170,-1905.5155,1.4745);
  167. SetPlayerFacingAngle(playerid,4);
  168. SetPlayerCameraPos(playerid, 546.3170,-1905.5155,1.4745);
  169. SetPlayerCameraLookAt(playerid, 546.3170,-1905.5155,1.4745);
  170. return 1;
  171. }
  172.  
  173. public OnPlayerConnect(playerid)
  174. {
  175. if(fexist(UserPath(playerid)))
  176. {
  177. INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  178. TogglePlayerSpectating(playerid,1);
  179. ShowPlayerDialog(playerid,DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "{FFFFFF}Login","{FFFFFF}Welcome to {FF8000}Pirates Team Deathmatch\n{FFFFFF}Type your {00FF00}password {FFFFFF}below to login.", "Login", "Quit");
  180. }
  181. else
  182. {
  183. TogglePlayerSpectating(playerid,1);
  184. ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_PASSWORD,"{FFFFFF}Register.","{FFFFFF}Welcome to {FF8000}Pirates Team Deathmatch\n{FFFFFF}Type your {00FF00}password {FFFFFF}below to register a new account.","Register","Quit");
  185. }
  186. SetPlayerSkillLevel(playerid, WEAPONSKILL_SAWNOFF_SHOTGUN, 1);
  187. new plname[MAX_PLAYER_NAME], string[128];
  188. GetPlayerName(playerid, plname, sizeof(plname));
  189. PlayerInfo[playerid][pAdmin] = 0;
  190. PlayerInfo[playerid][pLevel] = 0;
  191. PlayerInfo[playerid][pCoins] = 0;
  192. format(string, sizeof(string), "/users/%s.ini", plname);
  193. return 1;
  194. }
  195.  
  196. public OnPlayerDisconnect(playerid, reason)
  197. {
  198. ControllingRedShip[playerid] = 0;
  199. ControllingBlueShip[playerid] = 0;
  200. new INI:File = INI_Open(UserPath(playerid));
  201. INI_SetTag(File,"Data");
  202. INI_WriteInt(File,"Coins",PlayerInfo[playerid][pCoins]);
  203. INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
  204. INI_WriteInt(File,"Level",PlayerInfo[playerid][pLevel]);
  205. INI_Close(File);
  206. return 1;
  207. }
  208.  
  209. public OnPlayerSpawn(playerid)
  210. {
  211. if(Team[playerid] == TEAM_RED)
  212. {
  213. SetPlayerSkin(playerid,19);
  214. }
  215. else
  216. {
  217. SetPlayerSkin(playerid,21);
  218. }
  219. return 1;
  220. }
  221.  
  222. public OnPlayerDeath(playerid, killerid, reason)
  223. {
  224. if(Team[playerid] == Team[killerid])
  225. {
  226. SendClientMessage(playerid,COLOR_ORANGE,"You've lost 75 coins and 2 levels for killing your teammate!");
  227. PlayerInfo[killerid][pLevel] -= 2;
  228. SetPlayerScore(killerid,PlayerInfo[killerid][pLevel]);
  229. PlayerInfo[killerid][pCoins] -= 75;
  230. GivePlayerMoney(killerid,-75);
  231. }
  232. else
  233. {
  234. PlayerInfo[killerid][pLevel] ++;
  235. SetPlayerScore(killerid,PlayerInfo[killerid][pLevel]);
  236. PlayerInfo[killerid][pCoins] += 50;
  237. GivePlayerMoney(killerid,50);
  238. }
  239. new Float:X,Float:Y,Float:Z;
  240. if(Team[playerid] == TEAM_RED)
  241. {
  242. GetVehiclePos(ShipRed,X,Y,Z);
  243. SetSpawnInfo(playerid,19,0,X,Y+2,Z+6,0,26,50,33,100,8,1);
  244. SpawnPlayer(playerid);
  245. }
  246. else
  247. {
  248. GetVehiclePos(ShipBlue,X,Y,Z);
  249. SetSpawnInfo(playerid,21,0,X,Y+2,Z+6,0,26,50,33,100,8,1);
  250. SpawnPlayer(playerid);
  251. }
  252. SendDeathMessage(killerid, playerid, reason);
  253. return 1;
  254. }
  255.  
  256. public OnVehicleSpawn(vehicleid)
  257. {
  258. return 1;
  259. }
  260.  
  261. public OnVehicleDeath(vehicleid, killerid)
  262. {
  263. return 1;
  264. }
  265.  
  266. public OnPlayerText(playerid, text[])
  267. {
  268. return 1;
  269. }
  270.  
  271. public OnPlayerCommandText(playerid, cmdtext[])
  272. {
  273. if (strcmp("/mycommand", cmdtext, true, 10) == 0)
  274. {
  275. // Do something here
  276. return 1;
  277. }
  278. return 0;
  279. }
  280.  
  281. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  282. {
  283. return 1;
  284. }
  285.  
  286. public OnPlayerExitVehicle(playerid, vehicleid)
  287. {
  288. return 1;
  289. }
  290.  
  291. public OnPlayerStateChange(playerid, newstate, oldstate)
  292. {
  293. return 1;
  294. }
  295.  
  296. public OnPlayerEnterCheckpoint(playerid)
  297. {
  298. return 1;
  299. }
  300.  
  301. public OnPlayerLeaveCheckpoint(playerid)
  302. {
  303. return 1;
  304. }
  305.  
  306. public OnPlayerEnterRaceCheckpoint(playerid)
  307. {
  308. return 1;
  309. }
  310.  
  311. public OnPlayerLeaveRaceCheckpoint(playerid)
  312. {
  313. return 1;
  314. }
  315.  
  316. public OnRconCommand(cmd[])
  317. {
  318. return 1;
  319. }
  320.  
  321. public OnPlayerRequestSpawn(playerid)
  322. {
  323. new Float:X,Float:Y,Float:Z;
  324. if(Team[playerid] == TEAM_RED)
  325. {
  326. GetVehiclePos(ShipRed,X,Y,Z);
  327. SetSpawnInfo(playerid,19,0,X,Y+2,Z+6,0,26,50,33,100,8,1);
  328. SpawnPlayer(playerid);
  329. }
  330. else
  331. {
  332. GetVehiclePos(ShipBlue,X,Y,Z);
  333. SetSpawnInfo(playerid,21,0,X,Y+2,Z+6,0,26,50,33,100,8,1);
  334. SpawnPlayer(playerid);
  335. }
  336. return 1;
  337. }
  338.  
  339. public OnObjectMoved(objectid)
  340. {
  341. return 1;
  342. }
  343.  
  344. public OnPlayerObjectMoved(playerid, objectid)
  345. {
  346. return 1;
  347. }
  348.  
  349. public OnPlayerPickUpPickup(playerid, pickupid)
  350. {
  351. return 1;
  352. }
  353.  
  354. public OnVehicleMod(playerid, vehicleid, componentid)
  355. {
  356. return 1;
  357. }
  358.  
  359. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  360. {
  361. return 1;
  362. }
  363.  
  364. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  365. {
  366. return 1;
  367. }
  368.  
  369. public OnPlayerSelectedMenuRow(playerid, row)
  370. {
  371. return 1;
  372. }
  373.  
  374. public OnPlayerExitedMenu(playerid)
  375. {
  376. return 1;
  377. }
  378.  
  379. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  380. {
  381. return 1;
  382. }
  383.  
  384. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  385. {
  386. new Float:X,Float:Y,Float:Z;
  387. if (newkeys & KEY_SECONDARY_ATTACK)
  388. {
  389. if(Team[playerid] == TEAM_BLUE || ControllingBlueShip[playerid] == 1)
  390. {
  391. ControllingBlueShip[playerid] = 0;
  392. RemovePlayerFromVehicle(playerid);
  393. GetPlayerPos(playerid, X,Y,Z);
  394. SetPlayerPos(playerid, X,Y+2,Z+6);
  395. SetCameraBehindPlayer(playerid);
  396. DestroyObject(bCamera);
  397. SetPlayerHealth(playerid,OldHP[playerid]);
  398. }
  399. else if(Team[playerid] == TEAM_RED || ControllingRedShip[playerid] == 1)
  400. {
  401. ControllingRedShip[playerid] = 0;
  402. RemovePlayerFromVehicle(playerid);
  403. GetPlayerPos(playerid, X,Y,Z);
  404. SetPlayerPos(playerid, X,Y+2,Z+6);
  405. SetCameraBehindPlayer(playerid);
  406. DestroyObject(rCamera);
  407. SetPlayerHealth(playerid,OldHP[playerid]);
  408. }
  409. }
  410. return 1;
  411. }
  412.  
  413. public OnRconLoginAttempt(ip[], password[], success)
  414. {
  415. return 1;
  416. }
  417.  
  418. public OnPlayerUpdate(playerid)
  419. {
  420. return 1;
  421. }
  422.  
  423. public OnPlayerStreamIn(playerid, forplayerid)
  424. {
  425. return 1;
  426. }
  427.  
  428. public OnPlayerStreamOut(playerid, forplayerid)
  429. {
  430. return 1;
  431. }
  432.  
  433. public OnVehicleStreamIn(vehicleid, forplayerid)
  434. {
  435. return 1;
  436. }
  437.  
  438. public OnVehicleStreamOut(vehicleid, forplayerid)
  439. {
  440. return 1;
  441. }
  442.  
  443. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  444. {
  445. if(dialogid == DIALOG_REGISTER)
  446. {
  447. if(!response) return Kick(playerid);
  448. if(response)
  449. {
  450. if(!strlen(inputtext)) return ShowPlayerDialog(playerid,DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register.","{FF8000}Pirates Team Deathmatch\n{FF0000}You have entered an invalid password.\n{FFFFFF}Type your password below to register a new account.","Register","Quit");
  451. new INI:File = INI_Open(UserPath(playerid));
  452. INI_SetTag(File,"Data");
  453. INI_WriteInt(File,"Password",udb_hash(inputtext));
  454. INI_WriteInt(File,"Coins",0);
  455. INI_WriteInt(File,"Admin",0);
  456. INI_WriteInt(File,"Level",0);
  457. INI_Close(File);
  458. TogglePlayerSpectating(playerid,0);
  459. TogglePlayerControllable(playerid,1);
  460. ForceClassSelection(playerid);
  461. }
  462. }
  463. if(dialogid == DIALOG_LOGIN)
  464. {
  465. if(!response) return Kick (playerid);
  466. if(response)
  467. {
  468. if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
  469. {
  470. INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  471. SetPlayerScore(playerid, PlayerInfo[playerid][pLevel]);
  472. GivePlayerMoney(playerid, PlayerInfo[playerid][pCoins]);
  473. TogglePlayerSpectating(playerid,0);
  474. TogglePlayerControllable(playerid,1);
  475. ForceClassSelection(playerid);
  476. }
  477. else
  478. {
  479. ShowPlayerDialog(playerid,DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"{FFFFFF}Login","{FF8000}Pirates Team Deathmatch\n{FF0000}Incorrect password.\n{FFFFFF}Type your {00FF00}password {FFFFFF}below to login.","Login","Quit");
  480. TogglePlayerSpectating(playerid,1);
  481. }
  482. return 1;
  483. }
  484. }
  485. return 1;
  486. }
  487.  
  488. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  489. {
  490. return 1;
  491. }
  492.  
  493. CMD:help(playerid,params[])
  494. {
  495. SendClientMessage(playerid,COLOR_WHITE,"Available commands.");
  496. SendClientMessage(playerid,COLOR_WHITE,"/swapteams - /suicide - /report - /buymolotovcocktails - /buycanonball - /firecanon - /commandship");
  497. return 1;
  498. }
  499.  
  500. CMD:suicide(playerid, params[])
  501. {
  502. if(ControllingRedShip[playerid] == 1 || ControllingBlueShip[playerid] == 1) return SendClientMessage(playerid,COLOR_BLUE,"[P:TDM]{AFAFAF} You can't do this right now.");
  503. SetPlayerHealth(playerid,0);
  504. return 1;
  505. }
  506.  
  507. CMD:buycanonball(playerid,params[])
  508. {
  509. if(Canon[playerid] == 1) return SendClientMessage(playerid,COLOR_BLUE,"[P:TDM]{AFAFAF} You already have a canon.");
  510. if(GetPlayerMoney(playerid) <= 500) return SendClientMessage(playerid,COLOR_BLUE,"[P:TDM]{AFAFAF} Insufficient funds. [500 coins]");
  511. Canon[playerid] = 1;
  512. PlayerInfo[playerid][pCoins] -= 500;
  513. GivePlayerMoney(playerid, -500);
  514. SendClientMessage(playerid,COLOR_ORANGE,"You've successfully purchased a canon, /firecanon.");
  515. return 1;
  516. }
  517.  
  518. CMD:buymolotovcocktails(playerid,params[])
  519. {
  520. if(GetPlayerMoney(playerid) <= 1000) return SendClientMessage(playerid,COLOR_BLUE,"[P:TDM]{AFAFAF} Insufficient funds. [1000 coins]");
  521. PlayerInfo[playerid][pCoins] -= 1000;
  522. GivePlayerMoney(playerid, -1000);
  523. GivePlayerWeapon(playerid,18,5);
  524. SendClientMessage(playerid,COLOR_ORANGE,"You've successfully purchased molotov cocktails.");
  525. return 1;
  526. }
  527.  
  528.  
  529. CMD:firecanon(playerid,params[])
  530. {
  531. new Float:X,Float:Y,Float:Z;
  532. if(Canon[playerid] == 0) return SendClientMessage(playerid,COLOR_BLUE,"[P:TDM]{AFAFAF} You don't have a canon.");
  533. if(Team[playerid] == TEAM_RED)
  534. {
  535. GetVehiclePos(ShipBlue,X,Y,Z);
  536. CreateExplosion(X,Y,Z,7,10);
  537. Canon[playerid] = 0;
  538. }
  539. else
  540. {
  541. GetVehiclePos(ShipRed,X,Y,Z);
  542. CreateExplosion(X,Y,Z,7,10);
  543. Canon[playerid] = 0;
  544. }
  545. return 1;
  546. }
  547.  
  548. CMD:commandship(playerid, params[])
  549. {
  550. new Float:HP;
  551. if(Team[playerid] == TEAM_BLUE)
  552. {
  553. for(new i = 0; i < MAX_PLAYERS; i++)
  554. {
  555. if(ControllingBlueShip[i] == 1) return SendClientMessage(playerid,COLOR_BLUE,"[P:TDM]{AFAFAF} The ship is being held in command by someone else.");
  556. }
  557. GetPlayerHealth(playerid, HP);
  558. OldHP[playerid] = HP;
  559. SetPlayerHealth(playerid,99999);
  560. bCamera = CreateObject(0, 0,0,0,0,0,0);
  561. AttachObjectToVehicle(bCamera, ShipBlue,0,-35,23,0.000000,0.000000,0.0);
  562. PutPlayerInVehicle(playerid, ShipBlue, 0);
  563. AttachCameraToObject(playerid, bCamera);
  564. ControllingBlueShip[playerid] = 1;
  565. SendClientMessage(playerid, -1,"Type /quitship or press 'F' if you want to stop commanding this ship.");
  566. }
  567. else if(Team[playerid] == TEAM_RED)
  568. {
  569. for(new i = 0; i < MAX_PLAYERS; i++)
  570. {
  571. if(ControllingRedShip[i] == 1) return SendClientMessage(playerid,COLOR_BLUE,"[P:TDM]{AFAFAF} The ship is being held in command by someone else.");
  572. }
  573. GetPlayerHealth(playerid, HP);
  574. OldHP[playerid] = HP;
  575. SetPlayerHealth(playerid,99999);
  576. rCamera = CreateObject(0, 0,0,0,0,0,0);
  577. AttachObjectToVehicle(rCamera, ShipRed,0,-35,23,0.000000,0.000000,0.0);
  578. PutPlayerInVehicle(playerid, ShipRed, 0);
  579. AttachCameraToObject(playerid, rCamera);
  580. ControllingRedShip[playerid] = 1;
  581. SendClientMessage(playerid, -1,"Type /quitship or press 'F' if you want to stop commanding this ship.");
  582. }
  583. return 1;
  584. }
  585.  
  586. CMD:quitship(playerid, params[])
  587. {
  588. new Float:X,Float:Y,Float:Z;
  589. if(Team[playerid] == TEAM_BLUE || ControllingBlueShip[playerid] == 1)
  590. {
  591. ControllingBlueShip[playerid] = 0;
  592. RemovePlayerFromVehicle(playerid);
  593. GetPlayerPos(playerid, X,Y,Z);
  594. SetPlayerPos(playerid, X,Y+2,Z+6);
  595. SetCameraBehindPlayer(playerid);
  596. DestroyObject(bCamera);
  597. SetPlayerHealth(playerid,OldHP[playerid]);
  598. }
  599. else if(Team[playerid] == TEAM_RED || ControllingRedShip[playerid] == 1)
  600. {
  601. ControllingRedShip[playerid] = 0;
  602. RemovePlayerFromVehicle(playerid);
  603. GetPlayerPos(playerid, X,Y,Z);
  604. SetPlayerPos(playerid, X,Y+2,Z+6);
  605. SetCameraBehindPlayer(playerid);
  606. DestroyObject(rCamera);
  607. SetPlayerHealth(playerid,OldHP[playerid]);
  608. }
  609. return 1;
  610. }
  611.  
  612. CMD:swapteams(playerid, params[])
  613. {
  614. SetPlayerHealth(playerid,0);
  615. ForceClassSelection(playerid);
  616. return 1;
  617. }
  618.  
  619. //Admin commands.
  620. //=========================================================================================================================================
  621. CMD:adminhelp(playerid, params[])
  622. {
  623. if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid,COLOR_BLUE,"[P:TDM]{AFAFAF} You aren't authorized to use this command.");
  624. SendClientMessage(playerid,COLOR_WHITE,"LEVEL 1: /kick - /ban");
  625. SendClientMessage(playerid,COLOR_WHITE,"LEVEL 2: /setstats - /givecanonball");
  626. SendClientMessage(playerid,COLOR_WHITE,"LEVEL 3: /makeadmin - /fireadmin");
  627. return 1;
  628. }
  629.  
  630. CMD:makeadmin(playerid, params[])
  631. {
  632. new playerb,level;
  633. if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdmin] >= 3)
  634. {
  635. if(sscanf(params,"ui",playerb,level)) return SendClientMessage(playerid, COLOR_BLUE,"[P:TDM]{AFAFAF} /makeadmin [playerid] [level]");
  636. new string[128];
  637. PlayerInfo[playerb][pAdmin] = level;
  638. format(string,sizeof(string),"Admin %s has promoted you to a level %d admin.",GPN(playerid),level);
  639. SendClientMessage(playerb,COLOR_WHITE,string);
  640. format(string,sizeof(string),"You've promoted %s to a level %d admin",GPN(playerb),level);
  641. SendClientMessage(playerid,COLOR_WHITE,string);
  642. }
  643. else return SendClientMessage(playerid,COLOR_BLUE,"[P:TDM]{AFAFAF} You aren't authorized to use this command.");
  644. return 1;
  645. }
  646.  
  647. CMD:setstats(playerid, params[])
  648. {
  649. new playerb,choice,amount,string[128];
  650. if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid,COLOR_BLUE,"[P:TDM]{AFAFAF} You aren't authorized to use this command.");
  651. if(sscanf(params, "uii", playerb,choice,amount))
  652. {
  653. SendClientMessage(playerid, COLOR_BLUE,"[P:TDM]{AFAFAF} /setstats [playerid] [choice] [amount]");
  654. SendClientMessage(playerid, COLOR_BLUE,"[P:TDM]{AFAFAF} 1|Level 2|Coins");
  655. return 1;
  656. }
  657. switch(choice)
  658. {
  659. case 1:
  660. {
  661. PlayerInfo[playerb][pLevel] = amount;
  662. SetPlayerScore(playerb,PlayerInfo[playerb][pLevel]);
  663. format(string, sizeof(string), "You've set %s's level to %d.",GPN(playerb),amount);
  664. SendClientMessage(playerid, COLOR_WHITE, string);
  665. format(string, sizeof(string), "Admin %s has set your level to %d.",GPN(playerid),amount);
  666. SendClientMessage(playerb, COLOR_WHITE, string);
  667. }
  668. case 2:
  669. {
  670. PlayerInfo[playerb][pCoins] = amount;
  671. ResetPlayerMoney(playerb);
  672. GivePlayerMoney(playerb,PlayerInfo[playerb][pCoins]);
  673. format(string, sizeof(string), "You've set %s's coins to %d.",GPN(playerb),amount);
  674. SendClientMessage(playerid, COLOR_WHITE, string);
  675. format(string, sizeof(string), "Admin %s has set your coins to %d.",GPN(playerid),amount);
  676. SendClientMessage(playerb, COLOR_WHITE, string);
  677. }
  678. }
  679. return 1;
  680. }
  681.  
  682. CMD:givecanonball(playerid, params[])
  683. {
  684. new playerb,string[128];
  685. if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid,COLOR_BLUE,"[P:TDM]{AFAFAF} You aren't authorized to use this command.");
  686. if(sscanf(params,"u",playerb)) return SendClientMessage(playerid, COLOR_BLUE,"[P:TDM]{AFAFAF} /givecanon [playerid]");
  687. Canon[playerb] = 1;
  688. format(string, sizeof(string), "You've given %s a canonball.",GPN(playerb));
  689. SendClientMessage(playerid, COLOR_WHITE, string);
  690. format(string, sizeof(string), "Admin %s has given you a canonball.",GPN(playerid));
  691. SendClientMessage(playerb, COLOR_WHITE, string);
  692. return 1;
  693. }
  694.  
  695. CMD:givemolotovcocktails(playerid, params[])
  696. {
  697. new playerb,string[128];
  698. if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid,COLOR_BLUE,"[P:TDM]{AFAFAF} You aren't authorized to use this command.");
  699. if(sscanf(params,"u",playerb)) return SendClientMessage(playerid, COLOR_BLUE,"[P:TDM]{AFAFAF} /givemolotovcoktails [playerid]");
  700. GivePlayerWeapon(playerid,18,5);
  701. format(string, sizeof(string), "You've given %s molotov cocktails.",GPN(playerb));
  702. SendClientMessage(playerid, COLOR_WHITE, string);
  703. format(string, sizeof(string), "Admin %s has given you molotov cocktails.",GPN(playerid));
  704. SendClientMessage(playerb, COLOR_WHITE, string);
  705. return 1;
  706. }
  707.  
  708. CMD:kick(playerid, params[])
  709. {
  710. new playerb,string[128];
  711. if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid,COLOR_BLUE,"[P:TDM]{AFAFAF} You aren't authorized to use this command.");
  712. if(sscanf(params,"u",playerb)) return SendClientMessage(playerid, COLOR_BLUE,"[P:TDM]{AFAFAF} /kick [playerid]");
  713. if(PlayerInfo[playerb][pAdmin] > PlayerInfo[playerid][pAdmin]) return SendClientMessage(playerid, COLOR_BLUE,"[P:TDM]{AFAFAF} You can't kick a admin with higher level then you.");
  714. SetTimerEx("Kicked",1000,false,"i",playerb);
  715. format(string, sizeof(string), "Admin %s kicked %s from the server.",GPN(playerid),GPN(playerb));
  716. SendClientMessageToAll(COLOR_ORANGE,string);
  717. return 1;
  718. }
  719.  
  720. CMD:ban(playerid, params[])
  721. {
  722. new playerb,string[128];
  723. if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid,COLOR_BLUE,"[P:TDM]{AFAFAF} You aren't authorized to use this command.");
  724. if(sscanf(params,"u",playerb)) return SendClientMessage(playerid, COLOR_BLUE,"[P:TDM]{AFAFAF} /ban [playerid]");
  725. if(PlayerInfo[playerb][pAdmin] > PlayerInfo[playerid][pAdmin]) return SendClientMessage(playerid, COLOR_BLUE,"[P:TDM]{AFAFAF} You can't ban a admin with higher level then you.");
  726. SetTimerEx("Banned",1000,false,"i",playerb);
  727. format(string, sizeof(string), "Admin %s banned %s from the server.",GPN(playerid),GPN(playerb));
  728. SendClientMessageToAll(COLOR_ORANGE,string);
  729. return 1;
Advertisement
Add Comment
Please, Sign In to add comment