commands.inc 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /************************
  2. File:
  3. - commands.inc
  4. Description:
  5. - New and improved backup system by Jay Cortez
  6. *************************/
  7. /* Command to call backup */
  8. CMD:backuptest(playerid, params[]) {
  9. if(!BackupAllowed(playerid))
  10. return AdmErrorMsg;
  11. if(IsPlayerRestricted(playerid))
  12. return SendClientMessage(playerid, COLOR_GREY, "You cannot call backup at this moment.");
  13. if(CheckForJammer(playerid))
  14. return SendClientMessage(playerid, COLOR_GREY, "Backup signal has been jammed.");
  15. new bkType[10];
  16. if(sscanf(params, "s[10]", bkType)) {
  17. if(PlayerInfo[playerid][pGroup] == GROUP_S9)
  18. SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /backup [SAPD, DoC, SAFMD, S9]");
  19. else
  20. SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /backup [SAPD, DoC, SAFMD]");
  21. return 1;
  22. }
  23. new bkFaction;
  24. if(strmatch(bkType, "sapd")) {
  25. bkFaction = FACTION_SAPD;
  26. }
  27. else if(strmatch(bkType, "doc")) {
  28. bkFaction = FACTION_ARMY;
  29. }
  30. else if(strmatch(bkType, "safmd")) {
  31. bkFaction = FACTION_FMD;
  32. }
  33. else if(strmatch(bkType, "s9") && PlayerInfo[playerid][pGroup] == GROUP_S9) {
  34. bkFaction = FACTION_S9;
  35. }
  36. else return cmd_backuptest(playerid, "");
  37. // Check if already called backup for this fac
  38. if(IsPlayerCallingBackup(playerid, bkFaction))
  39. return SendClientMessage(playerid, COLOR_GREY, "You have already sent a backup request to this faction, be patient.");
  40. // S9 anti reveal
  41. if(PlayerInfo[playerid][pGroup] == GROUP_S9 && bkFaction != FACTION_S9 && !PlayerInfo[playerid][pMask])
  42. return SendClientMessage(playerid, COLOR_GREY, "You should put on a mask or be in a fake faction to prevent revealing yourself.");
  43. // Send notification to faction
  44. new backupStr[128];
  45. format(backupStr, sizeof(backupStr), "HQ: Incoming backup request from %s. (/backups)", GetPlayerBackupName(playerid, bkFaction));
  46. foreach(new i:Player)
  47. {
  48. if(PlayerInfo[i][pMember] != bkFaction && PlayerInfo[i][pLeader] != bkFaction && FakeFaction[i] != bkFaction && RadioFrequency[i] != bkFaction)
  49. continue;
  50. if(CheckForJammer(i))
  51. continue;
  52. SendClientMessage(i, GetFactionColour(bkFaction), backupStr);
  53. DoBackupSound(i, 1);
  54. }
  55. // Create the backup request
  56. CreateBackupRequest(playerid, bkFaction);
  57. // Show action above head
  58. if(bkFaction != FACTION_S9) {
  59. format(backupStr, sizeof(backupStr), "* %s reaches down and presses a button on their waistbelt.", PlayerICName(playerid));
  60. SetPlayerChatBubble(playerid, backupStr, COLOR_PURPLE, 20.0, 15000);
  61. }
  62. // Show HUD info
  63. format(backupStr, sizeof(backupStr), "~b~%s ~w~backup called.", GetFactionName(bkFaction));
  64. displayCenterHUDInfo(playerid, backupStr, 4);
  65. // Show notification in chat
  66. format(backupStr, sizeof(backupStr), "* You have called for {%06x}%s{33CCFF} backup.", GetFactionColour(bkFaction) >>> 8, GetFactionName(bkFaction));
  67. SendClientMessage(playerid, COLOR_LIGHTBLUE, backupStr);
  68. return 1;
  69. }
  70. /* Command to see backup calls */
  71. CMD:backups(playerid, params[]) {
  72. if(!BackupAllowed(playerid))
  73. return AdmErrorMsg;
  74. if(IsPlayerRestricted(playerid))
  75. return SendClientMessage(playerid, COLOR_GREY, "You cannot see backup calls at this moment.");
  76. if(CheckForJammer(playerid))
  77. return SendClientMessage(playerid, COLOR_GREY, "Signal has been jammed.");
  78. new facToDisplay = PlayerInfo[playerid][pMember];
  79. // Check fake faction backups
  80. new fakeCheck[5];
  81. if(!sscanf(params, "s[5]", fakeCheck)) {
  82. if( PlayerInfo[playerid][pMember] == FACTION_S9 &&
  83. strmatch(fakeCheck, "fake")
  84. ) {
  85. if(!FakeFaction[playerid])
  86. return SendClientMessage(playerid, COLOR_GREY, "You are not undercover in a faction at the moment.");
  87. facToDisplay = FakeFaction[playerid];
  88. }
  89. }
  90. // The faction currently has no open backup requests
  91. if(!FactionBackupCallsCount(facToDisplay)) {
  92. if(facToDisplay == PlayerInfo[playerid][pMember])
  93. return SendClientMessage(playerid, COLOR_GREY, "There are currently no backup calls for your faction.");
  94. else
  95. return SendClientMessage(playerid, COLOR_GREY, "There are currently no backup calls for your fake faction.");
  96. }
  97. // Display the list of backups
  98. ShowFactionBackups(playerid, facToDisplay);
  99. return 1;
  100. }
  101. /* Command to see backup calls for fake faction (Sector 9) */
  102. CMD:fakebackups(playerid, params[])
  103. return cmd_backups(playerid, "fake");
  104. CMD:fbackups(playerid, params[])
  105. return cmd_backups(playerid, "fake");
  106. /* Command to cancel responding to current backup call */
  107. CMD:bkctest(playerid, params[]) {
  108. if(!BackupAllowed(playerid))
  109. return AdmErrorMsg;
  110. if(IsPlayerRestricted(playerid))
  111. return SendClientMessage(playerid, COLOR_GREY, "You cannot do this at this moment.");
  112. if(!IsPlayerCallingBackup(playerid))
  113. return SendClientMessage(playerid, COLOR_GREY, "You don't have any backup requests out.");
  114. CancelAllBackupRequests(playerid, BK_CANCEL_REASON_SELF);
  115. SendClientMessage(playerid, COLOR_LIGHTBLUE, "* Your backup requests have been cancelled.");
  116. return 1;
  117. }