#include forward OnPlayerWounded(playerid); forward OnPlayerSpawnToHospital(playerid); forward OnPlayerWrongAnimation(playerid); static Injuries[MAX_PLAYERS]; static DeadAnimation[MAX_PLAYERS]; static DeathTimer[MAX_PLAYERS]; static Text3D:DeadTD[MAX_PLAYERS]; static bool:ValidDeadTD[MAX_PLAYERS]; timer DeadAnimationCheck[150](playerid) { if(IsPlayerWounded(playerid)) { if(!IsPlayerInAnyVehicle(playerid)) { if(GetPlayerAnimationIndex(playerid) != DeadAnimation[playerid]) { if(DeadAnimation[playerid] != 1701) OnPlayerWrongAnimation(playerid); else if(GetPlayerAnimationIndex(playerid) != 1701 && GetPlayerAnimationIndex(playerid) != 1151) OnPlayerWrongAnimation(playerid); } } else if(GetPlayerAnimationIndex(playerid) != 1019) OnPlayerWrongAnimation(playerid); defer DeadAnimationCheck(playerid); } } public OnPlayerWounded(playerid) { Injuries[playerid] = 1; DeathTimer[playerid] = gettime(); new Float:x, Float:y, Float:z; GetPlayerPos(playerid, x, y, z); if(ValidDeadTD[playerid] == false) { ValidDeadTD[playerid] = true; DeadTD[playerid] = Create3DTextLabel(va_return("(( This player is brutally wounded,\n/injuries %d for more information ))", playerid), 0xFF6666FF, x, y, z, 20, 0, 1); Attach3DTextLabelToPlayer(DeadTD[playerid], playerid, 0.0, 0.0, 0.4); } SetPlayerHealth(playerid, 1); switch(random(6)) { case 0: DeadAnimation[playerid] = 1701; case 1: DeadAnimation[playerid] = 385; case 2: DeadAnimation[playerid] = 387; case 3: DeadAnimation[playerid] = 388; case 4: DeadAnimation[playerid] = 390; case 5: DeadAnimation[playerid] = 392; } if(IsPlayerInAnyVehicle(playerid)) { if(GetPlayerVehicleSeat(playerid) == 0) { new engine, lights, alarm, doors, bonnet, boot, objective; GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective); SetVehicleParamsEx(GetPlayerVehicleID(playerid), VEHICLE_PARAMS_OFF, lights, alarm, doors, bonnet, boot, objective); } } defer DeadAnimationCheck(playerid); SendClientMessage(playerid, 0xff9999ff, "** You were brutally wounded, you must wait 60 seconds before using /acceptdeath."); return 1; } public OnPlayerSpawnToHospital(playerid) { Corpse_Create(playerid); if(ValidDeadTD[playerid] == true) { Delete3DTextLabel(DeadTD[playerid]); ValidDeadTD[playerid] = false; } Injuries[playerid] = 0; DeathTimer[playerid] = 0; DeadAnimation[playerid] = 0; SetPlayerInterior(playerid, 0); SetPlayerVirtualWorld(playerid, 0); SetPlayerPos(playerid, 2032.1594, -1406.6229, 17.2038); SetPlayerFacingAngle(playerid, 153.6930); SetCameraBehindPlayer(playerid); ResetPlayerWeapons(playerid); SetPlayerHealth(playerid, 100); SetPlayerArmour(playerid, 0); SendClientMessage(playerid, 0xff9999ff, "** You have paid $350 to cover your medical expenses."); return 1; } public OnPlayerWrongAnimation(playerid) { if(!IsPlayerInAnyVehicle(playerid)) { switch(DeadAnimation[playerid]) { case 1701: { if(Injuries[playerid] < 4) ApplyAnimation(playerid, "WUZI", "CS_Dead_Guy", 4.1, 1, 1, 1, 1, 0, 1); else ApplyAnimation(playerid, "ped", "FLOOR_hit_f", 4.1, 0, 1, 1, 1, 0, 1); } case 385: ApplyAnimation(playerid, "CRACK", "CRCKDETH1", 4.1, 0, 1, 1, 1, 0, 1); case 387: ApplyAnimation(playerid, "CRACK", "CRCKDETH3", 4.1, 0, 1, 1, 1, 0, 1); case 388: ApplyAnimation(playerid, "CRACK", "CRCKDETH4", 4.1, 0, 1, 1, 1, 0, 1); case 390: ApplyAnimation(playerid, "CRACK", "CRCKIDLE2", 4.1, 0, 1, 1, 1, 0, 1); case 392: ApplyAnimation(playerid, "CRACK", "CRCKIDLE4", 4.1, 0, 1, 1, 1, 0, 1); } } else ApplyAnimation(playerid, "ped", "CAR_dead_RHS", 4.1, 0, 1, 1, 1, 0, 1); return 1; } hook OnPlayerConnect(playerid) { Injuries[playerid] = 0; DeathTimer[playerid] = 0; DeadAnimation[playerid] = 0; ValidDeadTD[playerid] = false; } hook OnPlayerDeath(playerid, killerid, reason) { if(!IsPlayerWounded(playerid)) Injuries[playerid] = 1; } hook OnPlayerFirstSpawn(playerid) { SetPlayerTeam(playerid, DEFAULT_TEAM); } hook OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart) { new Float:health, Float:armour; GetPlayerHealth(playerid, health); GetPlayerArmour(playerid, armour); if(!IsPlayerWounded(playerid)) { switch(weaponid) { case WEAPON_FIST: { amount = 4; if(health > amount) SetPlayerHealth(playerid, health - amount); else CallRemoteFunction("OnPlayerWounded", "i", playerid); } case WEAPON_BRASSKNUCKLE..WEAPON_NITESTICK, WEAPON_BAT..WEAPON_POOLSTICK, WEAPON_CANE: { amount = 9; if(health > amount) SetPlayerHealth(playerid, health - amount); else CallRemoteFunction("OnPlayerWounded", "i", playerid); } case WEAPON_KNIFE, WEAPON_KATANA: { amount = 14; if(health > amount) SetPlayerHealth(playerid, health - amount); else CallRemoteFunction("OnPlayerWounded", "i", playerid); } case WEAPON_COLT45, WEAPON_SILENCED: { switch(bodypart) { case BODY_PART_TORSO: { amount = 25; if(health > amount && armour == 0) SetPlayerHealth(playerid, health - amount); else if(armour == 0) CallRemoteFunction("OnPlayerWounded", "i", playerid); if(armour > amount) SetPlayerArmour(playerid, armour - amount); else SetPlayerArmour(playerid, 0); } case BODY_PART_HEAD: { amount = 40; if(health > amount) SetPlayerHealth(playerid, health - amount); else CallRemoteFunction("OnPlayerWounded", "i", playerid); } case BODY_PART_GROIN..BODY_PART_LEFT_LEG: { amount = 18; if(health > amount) SetPlayerHealth(playerid, health - amount); else CallRemoteFunction("OnPlayerWounded", "i", playerid); } } } case WEAPON_DEAGLE: { switch(bodypart) { case BODY_PART_TORSO, BODY_PART_HEAD: { amount = 40; if(health > amount && armour == 0) SetPlayerHealth(playerid, health - amount); else if(armour == 0) CallRemoteFunction("OnPlayerWounded", "i", playerid); if(armour > amount) SetPlayerArmour(playerid, armour - amount); else SetPlayerArmour(playerid, 0); } case BODY_PART_GROIN..BODY_PART_LEFT_LEG: { amount = 20; if(health > amount) SetPlayerHealth(playerid, health - amount); else CallRemoteFunction("OnPlayerWounded", "i", playerid); } } } case WEAPON_SHOTGUN: { new Float:x, Float:y, Float:z; GetPlayerPos(playerid, x, y, z); new Float:distance = GetPlayerDistanceFromPoint(issuerid, x, y, z); if(distance < 8) { switch(bodypart) { case BODY_PART_TORSO: { amount = 60; if(health > amount && armour == 0) SetPlayerHealth(playerid, health - amount); else if(armour == 0) CallRemoteFunction("OnPlayerWounded", "i", playerid); if(armour > amount) SetPlayerArmour(playerid, armour - amount); else SetPlayerArmour(playerid, 0); } case BODY_PART_HEAD: { amount = 100; CallRemoteFunction("OnPlayerWounded", "i", playerid); } case BODY_PART_GROIN..BODY_PART_LEFT_LEG: { amount = 25; if(health > amount) SetPlayerHealth(playerid, health - amount); else CallRemoteFunction("OnPlayerWounded", "i", playerid); } } } else if(distance < 16) { switch(bodypart) { case BODY_PART_TORSO: { amount = 40; if(health > amount && armour == 0) SetPlayerHealth(playerid, health - amount); else if(armour == 0) CallRemoteFunction("OnPlayerWounded", "i", playerid); if(armour > amount) SetPlayerArmour(playerid, armour - amount); else SetPlayerArmour(playerid, 0); } case BODY_PART_HEAD: { amount = 60; if(health > amount) SetPlayerHealth(playerid, health - amount); else CallRemoteFunction("OnPlayerWounded", "i", playerid); } case BODY_PART_GROIN..BODY_PART_LEFT_LEG: { amount = 18; if(health > amount) SetPlayerHealth(playerid, health - amount); else CallRemoteFunction("OnPlayerWounded", "i", playerid); } } } else { switch(bodypart) { case BODY_PART_TORSO: { amount = 22; if(health > amount && armour == 0) SetPlayerHealth(playerid, health - amount); else if(armour == 0) CallRemoteFunction("OnPlayerWounded", "i", playerid); if(armour > amount) SetPlayerArmour(playerid, armour - amount); else SetPlayerArmour(playerid, 0); } case BODY_PART_HEAD: { amount = 32; if(health > amount) SetPlayerHealth(playerid, health - amount); else CallRemoteFunction("OnPlayerWounded", "i", playerid); } case BODY_PART_GROIN..BODY_PART_LEFT_LEG: { amount = 12; if(health > amount) SetPlayerHealth(playerid, health - amount); else CallRemoteFunction("OnPlayerWounded", "i", playerid); } } } } case WEAPON_UZI, WEAPON_MP5, WEAPON_TEC9: { switch(bodypart) { case BODY_PART_TORSO: { amount = 16; if(health > amount && armour == 0) SetPlayerHealth(playerid, health - amount); else if(armour == 0) CallRemoteFunction("OnPlayerWounded", "i", playerid); if(armour > amount) SetPlayerArmour(playerid, armour - amount); else SetPlayerArmour(playerid, 0); } case BODY_PART_HEAD: { amount = 28; if(health > amount) SetPlayerHealth(playerid, health - amount); else CallRemoteFunction("OnPlayerWounded", "i", playerid); } case BODY_PART_GROIN..BODY_PART_LEFT_LEG: { amount = 9; if(health > amount) SetPlayerHealth(playerid, health - amount); else CallRemoteFunction("OnPlayerWounded", "i", playerid); } } } case WEAPON_AK47: { switch(bodypart) { case BODY_PART_TORSO: { amount = 24; if(health > amount && armour == 0) SetPlayerHealth(playerid, health - amount); else if(armour == 0) CallRemoteFunction("OnPlayerWounded", "i", playerid); if(armour > amount) SetPlayerArmour(playerid, armour - amount); else SetPlayerArmour(playerid, 0); } case BODY_PART_HEAD: { amount = 32; if(health > amount) SetPlayerHealth(playerid, health - amount); else CallRemoteFunction("OnPlayerWounded", "i", playerid); } case BODY_PART_GROIN..BODY_PART_LEFT_LEG: { amount = 12; if(health > amount) SetPlayerHealth(playerid, health - amount); else CallRemoteFunction("OnPlayerWounded", "i", playerid); } } } case WEAPON_M4: { switch(bodypart) { case BODY_PART_TORSO: { amount = 20; if(health > amount && armour == 0) SetPlayerHealth(playerid, health - amount); else if(armour == 0) CallRemoteFunction("OnPlayerWounded", "i", playerid); if(armour > amount) SetPlayerArmour(playerid, armour - amount); else SetPlayerArmour(playerid, 0); } case BODY_PART_HEAD: { amount = 31; if(health > amount) SetPlayerHealth(playerid, health - amount); else CallRemoteFunction("OnPlayerWounded", "i", playerid); } case BODY_PART_GROIN..BODY_PART_LEFT_LEG: { amount = 10; if(health > amount) SetPlayerHealth(playerid, health - amount); else CallRemoteFunction("OnPlayerWounded", "i", playerid); } } } case WEAPON_RIFLE, WEAPON_SNIPER: { switch(bodypart) { case BODY_PART_TORSO: { amount = 60; if(health > amount && armour == 0) SetPlayerHealth(playerid, health - amount); else if(armour == 0) CallRemoteFunction("OnPlayerWounded", "i", playerid); if(armour > amount) SetPlayerArmour(playerid, armour - amount); else SetPlayerArmour(playerid, 0); } case BODY_PART_HEAD: { amount = 100; CallRemoteFunction("OnPlayerWounded", "i", playerid); } case BODY_PART_GROIN..BODY_PART_LEFT_LEG: { amount = 34; if(health > amount) SetPlayerHealth(playerid, health - amount); else CallRemoteFunction("OnPlayerWounded", "i", playerid); } } } } } return 1; } hook OnPlayerShotPlayer(playerid, hitid) { if(0 < Injuries[hitid] < 4) { Injuries[hitid]++; if(Injuries[hitid] >= 4) { SendClientMessage(hitid, 0xff6666ff, "** You're now dead, you will be able to use /acceptdeath in short time."); if(ValidDeadTD[hitid] == true) Update3DTextLabelText(DeadTD[hitid], 0xFF6666FF, "(( This player is dead ))"); if(DeadAnimation[hitid] == 1701) ApplyAnimation(hitid, "ped", "FLOOR_hit_f", 4.1, 0, 1, 1, 1, 0, 1); } } } hook OnPlayerDisconnect(playerid, reason) { if(ValidDeadTD[playerid] == true) { Delete3DTextLabel(DeadTD[playerid]); ValidDeadTD[playerid] = false; } } hook OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) { if(IsPlayerWounded(playerid)) { ClearAnimations(playerid, 1); new Float:x, Float:y, Float:z; GetPlayerPos(playerid, x, y, z); SetPlayerPos(playerid, x, y, z); } } hook OnPlayerExitVehicle(playerid, vehicleid) { if(IsPlayerWounded(playerid)) { new seat = GetPlayerVehicleSeat(playerid); ClearAnimations(playerid, 1); PutPlayerInVehicle(playerid, vehicleid, seat); } } RevivePlayer(playerid) { if(ValidDeadTD[playerid] == true) { Delete3DTextLabel(DeadTD[playerid]); ValidDeadTD[playerid] = false; } if(IsPlayerWounded(playerid)) { ResetPlayerInjuries(playerid); Injuries[playerid] = 0; DeathTimer[playerid] = 0; DeadAnimation[playerid] = 0; if(IsPlayerInAnyVehicle(playerid)) { new seat = GetPlayerVehicleSeat(playerid); new vehicle = GetPlayerVehicleID(playerid); ClearAnimations(playerid, 1); PutPlayerInVehicle(playerid, vehicle, seat); } else ClearAnimations(playerid, 1); } return 1; } IsPlayerWounded(playerid) { if(Injuries[playerid] > 0) { return true; } return false; } CMD:acceptdeath(playerid, params[]) { if(!IsPlayerWounded(playerid)) return SendErrorMessage(playerid, "You are not wounded."); new time = gettime() - DeathTimer[playerid]; if(time < 5) return SendErrorMessageF(playerid, "You can only use this command in %d seconds.", 5 - time); CallRemoteFunction("OnPlayerSpawnToHospital", "i", playerid); return 1; }