Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <zcmd>
- #include <sscanf2>
- #define FILTERSCRIPT
- #define TEAM_MEDIC 0
- static gTeam[MAX_PLAYERS];
- new bool:Injured[MAX_PLAYERS];
- new DeathTimer[MAX_PLAYERS];
- new RecoveryTimer[MAX_PLAYERS] = -1;
- public OnFilterScriptInit()
- {
- SetTimer("HealthChecker", 1000, 1);
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- forward HealthChecker();
- public HealthChecker()
- {
- for(new i=0; i<MAX_PLAYERS; i++)
- {
- if(!IsPlayerConnected(i)) continue;
- new Float:pHealth;
- GetPlayerHealth(i, pHealth);
- if(pHealth > 5.0) continue;
- if(RecoveryTimer[i] != -1)
- {
- KillTimer(RecoveryTimer[i]);
- RecoveryTimer[i] = -1;
- }
- Injured[i] = true;
- DeathTimer[i] = SetTimerEx("TimeToDie", 500000, 0, "d", i);
- TogglePlayerControllable(i, 0);
- }
- }
- forward TimeToDie(playerid);
- public TimeToDie(playerid)
- {
- Injured[playerid] = false;
- SetPlayerHealth(playerid, 0.0);
- TogglePlayerControllable(playerid, 1);
- }
- forward OperationFinish(playerid, id);
- public OperationFinish(playerid, id)
- {
- new success = random(2);
- if(success == 0)
- {
- SetPlayerHealth(id, 0.0);
- SendClientMessage(id, 0xffffffff, "The medic couldn't help, you died in the operation!");
- SendClientMessage(playerid, 0xffffffff, "Your couldn't help, thepatient died in the operation!");
- }
- else
- {
- SetPlayerHealth(id, 100.0);
- SendClientMessage(id, 0xffffffff, "The operation was successful!");
- SendClientMessage(playerid, 0xffffffff, "The operation was successful!!");
- RecoveryTimer[id] = SetTimerEx("Recovery", 1000, 1, "d", id);
- }
- TogglePlayerControllable(id, 1);
- TogglePlayerControllable(playerid, 1);
- KillTimer(DeathTimer[id]);
- Injured[id] = false;
- }
- forward Recovery(playerid);
- public Recovery(playerid)
- {
- new Float:pHealth;
- GetPlayerHealth(playerid, pHealth);
- SetPlayerHealth(playerid, pHealth+1.0);
- GetPlayerHealth(playerid, pHealth);
- if(pHealth == 200.0)
- {
- KillTimer(RecoveryTimer[playerid]);
- RecoveryTimer[playerid] = -1;
- SendClientMessage(playerid, 0xffffffff, "You successfully recovered!");
- }
- }
- CMD:operation(playerid, params[])
- {
- new id;
- if(sscanf(params, "d", id)) return SendClientMessage(playerid, 0xffffffff, "[Usage]: /operation <playerid>");
- if(gTeam[playerid] != TEAM_MEDIC) return SendClientMessage(playerid, 0xffffffff, "You're not medic!");
- if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xffffffff, "Invalid playerid!");
- if(!Injured[id]) return SendClientMessage(playerid, 0xffffffff, "This person isn't injured!");
- TogglePlayerControllable(id, 0);
- TogglePlayerControllable(playerid, 0);
- SendClientMessage(id, 0xffffffff, "A medic started to operate you!");
- SendClientMessage(playerid, 0xffffffff, "You started an operation!");
- SetTimerEx("OperationFinish", 180000, 0, "dd", playerid, id);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment