Guest User

Medic

a guest
Aug 27th, 2010
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.87 KB | None | 0 0
  1. #include <a_samp>
  2. #include <zcmd>
  3. #include <sscanf2>
  4.  
  5. #define FILTERSCRIPT
  6. #define TEAM_MEDIC      0
  7.  
  8. static gTeam[MAX_PLAYERS];
  9.  
  10. new bool:Injured[MAX_PLAYERS];
  11. new DeathTimer[MAX_PLAYERS];
  12. new RecoveryTimer[MAX_PLAYERS] = -1;
  13.  
  14. public OnFilterScriptInit()
  15. {
  16.     SetTimer("HealthChecker", 1000, 1);
  17.     return 1;
  18. }
  19.  
  20. public OnFilterScriptExit()
  21. {
  22.     return 1;
  23. }
  24.  
  25. forward HealthChecker();
  26. public HealthChecker()
  27. {
  28.     for(new i=0; i<MAX_PLAYERS; i++)
  29.     {
  30.         if(!IsPlayerConnected(i)) continue;
  31.         new Float:pHealth;
  32.         GetPlayerHealth(i, pHealth);
  33.         if(pHealth > 5.0) continue;
  34.         if(RecoveryTimer[i] != -1)
  35.         {
  36.             KillTimer(RecoveryTimer[i]);
  37.             RecoveryTimer[i] = -1;
  38.         }
  39.         Injured[i] = true;
  40.         DeathTimer[i] = SetTimerEx("TimeToDie", 500000, 0, "d", i);
  41.         TogglePlayerControllable(i, 0);
  42.     }
  43. }
  44.  
  45. forward TimeToDie(playerid);
  46. public TimeToDie(playerid)
  47. {
  48.     Injured[playerid] = false;
  49.     SetPlayerHealth(playerid, 0.0);
  50.     TogglePlayerControllable(playerid, 1);
  51. }
  52.  
  53. forward OperationFinish(playerid, id);
  54. public OperationFinish(playerid, id)
  55. {
  56.     new success = random(2);
  57.     if(success == 0)
  58.     {
  59.         SetPlayerHealth(id, 0.0);
  60.         SendClientMessage(id, 0xffffffff, "The medic couldn't help, you died in the operation!");
  61.         SendClientMessage(playerid, 0xffffffff, "Your couldn't help, thepatient died in the operation!");
  62.     }
  63.     else
  64.     {
  65.         SetPlayerHealth(id, 100.0);
  66.         SendClientMessage(id, 0xffffffff, "The operation was successful!");
  67.         SendClientMessage(playerid, 0xffffffff, "The operation was successful!!");
  68.         RecoveryTimer[id] = SetTimerEx("Recovery", 1000, 1, "d", id);
  69.     }
  70.     TogglePlayerControllable(id, 1);
  71.     TogglePlayerControllable(playerid, 1);
  72.     KillTimer(DeathTimer[id]);
  73.     Injured[id] = false;
  74. }
  75.  
  76. forward Recovery(playerid);
  77. public Recovery(playerid)
  78. {
  79.     new Float:pHealth;
  80.     GetPlayerHealth(playerid, pHealth);
  81.     SetPlayerHealth(playerid, pHealth+1.0);
  82.     GetPlayerHealth(playerid, pHealth);
  83.     if(pHealth == 200.0)
  84.     {
  85.         KillTimer(RecoveryTimer[playerid]);
  86.         RecoveryTimer[playerid] = -1;
  87.         SendClientMessage(playerid, 0xffffffff, "You successfully recovered!");
  88.     }
  89. }
  90.  
  91. CMD:operation(playerid, params[])
  92. {
  93.     new id;
  94.     if(sscanf(params, "d", id)) return SendClientMessage(playerid, 0xffffffff, "[Usage]: /operation <playerid>");
  95.     if(gTeam[playerid] != TEAM_MEDIC) return SendClientMessage(playerid, 0xffffffff, "You're not medic!");
  96.     if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xffffffff, "Invalid playerid!");
  97.     if(!Injured[id]) return SendClientMessage(playerid, 0xffffffff, "This person isn't injured!");
  98.     TogglePlayerControllable(id, 0);
  99.     TogglePlayerControllable(playerid, 0);
  100.     SendClientMessage(id, 0xffffffff, "A medic started to operate you!");
  101.     SendClientMessage(playerid, 0xffffffff, "You started an operation!");
  102.     SetTimerEx("OperationFinish", 180000, 0, "dd", playerid, id);
  103.     return 1;
  104. }
Advertisement
Add Comment
Please, Sign In to add comment