public OnPlayerSpawn(playerid) { SetPlayerHealth(playerid, 9999999); SetPlayerTeam(playerid, 0); return 1; } // reason = weaponid // hp = hp to set forward SetPlayerHealthEx(playerid,Float:hp,reason = 0); stock SetPlayerHealthEx(playerid,Float:hp,reason = 0) { new Float:oldhp = GetPlayerHealthEx(playerid); if(hp <= 0.0) { SetPlayerHealth(playerid,0); hp = 0.0; } if(reason != 18 && reason != 37) hp = float(floatround(hp,floatround_floor)); SetPVarFloat(playerid,"ScriptHealth",hp); //insert here any hud function you have to update player HP return 1; } forward SetPlayerArmourEx(playerid,Float:armour,reason = 0); stock SetPlayerArmourEx(playerid,Float:armour,reason = 0) { if(armour < 0.0) armour = 0.0; if(reason != 18 && reason != 37) armour = float(floatround(armour,floatround_floor)); SetPlayerArmour(playerid,armour); SetPVarFloat(playerid,"ScriptArmour",armour); // insert here any hud function you have to update player's armor return 1; } forward Float:GetPlayerHealthEx(playerid); stock Float:GetPlayerHealthEx(playerid) { return GetPVarFloat(playerid, "ScriptHealth"); } forward Float:GetPlayerArmourEx(playerid); stock Float:GetPlayerArmourEx(playerid) { return GetPVarFloat(playerid, "ScriptArmour"); } // function example taken from my TF2 (removed specific mode parts) Gamemode // This does not include armor calculations as armor is not in the GM but they are easily done forward DamagePlayer(playerid, Float:amount, weaponid, Float:hp, Float:armour, issuerid); public DamagePlayer(playerid, Float:amount, weaponid, Float:hp, Float:armour, issuerid) { //33% Less damage from explosions to Demos & Soldiers //25% resistance for rockets to Soldiers //66% Fall damage reduced for Scouts //100% Fire damage reduced for Pyros //100% damage resistance while round warmup //10% fire resistance to medic //100% - amount //toremove% - x //formula: (toremove * amount) / 100 if(amount == 0.0) return 1; if( (weaponid == 18 || weaponid == 37) && GetPlayerClassEx(playerid) == PYRO) return 1; // This means fire damage wont affect you if you're a PYRO if(GetPVarInt(playerid,"OnSpawn") == 1 || GetPlayerTeamEx(playerid) == GetPlayerTeamEx(issuerid)) return 1; //ignore all damage if on spawn or same team if(MissionInfo[Mission_Warming] != 999) return 1; //ignore all damage if mission hasn't started if(weaponid == 5 || weaponid == 8 || weaponid == 6 || weaponid == 2 || weaponid == 1) amount = amount+40.0; //Melees damage +40 if(weaponid == 22) // Pistol amount = amount-((50.0*amount)/100.0); //pistol damage reduced by 50% if(weaponid == 24) // Deagle amount = amount-((50.0*amount)/100.0); //deagle damage reduced by 50% if(weaponid == 25) // Shotgun amount = amount+((25.0*amount)/100.0); //shotgun damage increased 25% if(weaponid == 38 && GetPlayerClassEx(issuerid) != MEDIC) // Minigun amount = amount-((95.0*amount)/100.0); //minigun damage decreased 95% if(weaponid == 35 || weaponid == 51) //RPG/Explosion amount = amount+((20.0*amount)/100.0); //Explosions damage increased 20% if(weaponid == 26) //Sawnoff amount = amount-((5.0*amount)/100.0); // Sawnoff damage decreased 5% if(weaponid == 34) //Sniper rifle amount = amount+((110.0*amount)/100.0); //sniper damage increased 110% if(weaponid == 23) //Silenced amount = 35; // Silenced damage to 35hp if(weaponid == 37) //Flame amount = amount+((5.0*amount)/100.0); // flame thrower initial damage +5% if(weaponid == 18) //Mooltovs amount = amount-((90.0*amount)/100.0); // molotov damage -90% if(weaponid == 31) //M4 amount = amount+((25.0*amount)/100.0); //m4 damage +25% if(weaponid == 42) //Fire ex amount = amount-((40.0*amount)/100.0); //fire ex damage -40% if(weaponid == 8 && GetPlayerClassEx(issuerid) == DEMOMAN) //Demoman amount = amount*2; //Double damage for demoman & katana if( (weaponid == 18 || weaponid == 37) && GetPlayerClassEx(playerid) == MEDIC) amount = amount-((10.0*amount)/100.0); //10% Fire Resistance for medics if( (weaponid == 51 || weaponid == 35 || weaponid == 16 || weaponid == 39)) if(GetPlayerClassEx(playerid) == SOLDIER || GetPlayerClassEx(playerid) == DEMOMAN) amount = amount-((66.0*amount)/100.0); //Blast Resistance for soldier & demoman if( weaponid == 54 && GetPlayerClassEx(playerid) == SCOUT) amount = amount-((66.0*amount)/100.0); //-66% fall damage for scouts hp = hp-amount; SetPlayerHealthEx(playerid, hp, weaponid, amount); return 1; } // another damageplayer example without reductions but armour calculations //playerid, amount of damage, weaponid of damage, current player HP, current player armor forward DamagePlayer(playerid, Float:amount, weaponid, Float:hp, Float:armour); public DamagePlayer(playerid, Float:amount, weaponid, Float:hp, Float:armour) { if(weaponid == 41 || weaponid == 42) //spray amount = amount-((25.0*amount)/100.0); if(weaponid != 54 && weaponid != 53) { if(armour > 0.0) { new Float:tmp = armour; tmp = tmp-amount; if(tmp < 0.0) { amount = amount - armour; armour = 0.0; } else { armour = tmp; amount = 0; } if(armour > GetPlayerArmourEx(playerid)) armour = 0.0; SetPlayerArmourEx(playerid, armour,weaponid); } hp = (hp - amount); if(hp > GetPlayerHealthEx(playerid)) hp = 0.0; SetPlayerHealthEx(playerid, hp, weaponid); } else { hp = (hp - amount); if(hp > GetPlayerHealthEx(playerid)) hp = 0.0; SetPlayerHealthEx(playerid, hp, weaponid); } return 1; } public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart) { if(weaponid == 34) if(bodypart == 9) //sniper headshoot 2.5x damage amount = amount*2.5; DamagePlayer(playerid, amount, weaponid, GetPlayerHealthEx(playerid), GetPlayerArmourEx(playerid), issuerid); return 1; }