core.inc 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /************************
  2. File:
  3. - core.inc
  4. Description:
  5. - New and improved backup system by Jay Cortez
  6. *************************/
  7. #define MAX_BACKUP_CALLS 100
  8. #define INVALID_BACKUP_ID -1
  9. #define BACKUP_SOUND 1083
  10. #define DIALOG_BACKUPS 9382
  11. // Store backup information
  12. enum backupEnum {
  13. bool:bActive,
  14. bCaller,
  15. bFactionID,
  16. bTimestamp,
  17. bFromFaction
  18. };
  19. new BackupInfo[MAX_BACKUP_CALLS][backupEnum];
  20. // Player bound variables
  21. new backupFaction[MAX_PLAYERS], respondingToBackup[MAX_PLAYERS], backupTimer[MAX_PLAYERS];
  22. // Reasons for cancelling a backup request
  23. enum {
  24. BK_CANCEL_REASON_SELF, // The player cancelled
  25. BK_CANCEL_REASON_DEATH, // The player died
  26. BK_CANCEL_REASON_QUIT, // The player quit the server
  27. BK_CANCEL_REASON_ARRIVE // The player arrives at backup call
  28. };
  29. Hook:backup_OnPlayerDisconnect(playerid, reason) {
  30. KillTimer(backupTimer[playerid]);
  31. backupFaction[playerid] = -1;
  32. respondingToBackup[playerid] = INVALID_BACKUP_ID;
  33. // Cancel backup on disconnect
  34. if(BackupAllowed(playerid)) {
  35. if(IsPlayerCallingBackup(playerid))
  36. CancelAllBackupRequests(playerid, BK_CANCEL_REASON_QUIT);
  37. if(IsPlayerRespondingToBackup(playerid))
  38. CancelBackupResponding(playerid, BK_CANCEL_REASON_QUIT);
  39. }
  40. }
  41. /* Backups dialog */
  42. Hook:backup_OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
  43. if(dialogid == DIALOG_BACKUPS && response && BackupAllowed(playerid))
  44. OnPlayerRespondToBackup(playerid, listitem);
  45. }
  46. /* Cancel backup on death */
  47. Hook:backup_OnPlayerDeath(playerid, killerid, reason) {
  48. if(BackupAllowed(playerid) && pDeathState[playerid] == PLAYER_STATE_REVIVE) {
  49. if(IsPlayerCallingBackup(playerid))
  50. CancelAllBackupRequests(playerid, BK_CANCEL_REASON_DEATH);
  51. if(IsPlayerRespondingToBackup(playerid))
  52. CancelBackupResponding(playerid, BK_CANCEL_REASON_DEATH);
  53. }
  54. }
  55. #include "inc/factions/backup_system/functions.inc"
  56. #include "inc/factions/backup_system/commands.inc"