You can use ALS hooking to give them health, and when they loose it, etc... And use global variables,
- HP[MAX_PLAYERS], Armour[MAX_PLAYERS], etc... And on a timer check if the player has the health/armor they should, and if not just set it to what they should have. |
While I hate posting raw code without actually telling you what to do, there is no point in not posting this since I've already done it.
Example taken from my TF2/other Gamemode: http://pastebin.com/VaS1qSAG That's a complete scriptside health system where all the damage is recalculated and modified, I do have a distance reduction formula too; The only downside with this is that you need a custom player label system, since if you set a player's health to infinite the other players will not see the health bar of the player decrease when being damaged. There's also a shorter way to calculate damage on armor/hp, as Mike provided in one of his posts. Anyways, basically what the code does is: Set everyone's team to the same (This prevents damage from player to player), then their HP to 9999999 so the enviroment can not kill them (without this, you cannot control falling/explosions damage). Then the damage the player receives (OnPlayerTakeDamage) is processed at DamagePlayer function where the correct calculations for armor (if you use the second method) are applied (including rounding up/decimal hp for weapons such as spray can); the first method is from my GM where armor is not used so only damage reductions/multipliers are applied. The only downside of having the player HP set to 9999999 is that you need sort of a custom label system where you script your own player's HP bar, as by having 9999999 HP your HP bar will never go down. You can remove this however you will not be able to control the damage correctly on falling / explosions. You should also make sure to use the scripted functions when setting / getting HP or armour as otherwise the scripted health/armour will not be updated scriptwise. |
D:\+ANGGA+\SA-MP SERVER\SA-MP Venom Gaming\0.3z-R1\gamemodes\MJ-FR.pwn(27559) : warning 204: symbol is assigned a value that is never used: "oldhp" D:\+ANGGA+\SA-MP SERVER\SA-MP Venom Gaming\0.3z-R1\gamemodes\MJ-FR.pwn(27584) : warning 217: loose indentation D:\+ANGGA+\SA-MP SERVER\SA-MP Venom Gaming\0.3z-R1\gamemodes\MJ-FR.pwn(27623) : error 017: undefined symbol "GetPlayerClassEx" D:\+ANGGA+\SA-MP SERVER\SA-MP Venom Gaming\0.3z-R1\gamemodes\MJ-FR.pwn(27626) : error 017: undefined symbol "GetPlayerTeamEx" D:\+ANGGA+\SA-MP SERVER\SA-MP Venom Gaming\0.3z-R1\gamemodes\MJ-FR.pwn(2762 : warning 217: loose indentation D:\+ANGGA+\SA-MP SERVER\SA-MP Venom Gaming\0.3z-R1\gamemodes\MJ-FR.pwn(2762 : error 017: undefined symbol "MissionInfo" D:\+ANGGA+\SA-MP SERVER\SA-MP Venom Gaming\0.3z-R1\gamemodes\MJ-FR.pwn(2762 : error 017: undefined symbol "Mission_Warming" D:\+ANGGA+\SA-MP SERVER\SA-MP Venom Gaming\0.3z-R1\gamemodes\MJ-FR.pwn(2762 : error 029: invalid expression, assumed zero D:\+ANGGA+\SA-MP SERVER\SA-MP Venom Gaming\0.3z-R1\gamemodes\MJ-FR.pwn(2762 : fatal error 107: too many error messages on one line |