PauloCascus Posted July 14, 2014 Posted July 14, 2014 When i have added damage blocker into the Client-side, medic stopped to heal .... Anybody can say what's wrong here ? Server-side local skin = {[274]=true, [275] = true, [276]=true} function healFlowers (attacker, attackerweapon, bodypart, loss) theHealth = getElementHealth (source) if not skin[getElementModel(attacker)] then return end if ( theHealth == 100 ) then givePlayerMoney( attacker, 0 ) end if (attackerweapon == 14) and (loss > 1) and ( theHealth < 100 ) then setElementHealth ( source, theHealth+20 ) givePlayerMoney (attacker, 10*theHealth) end end addEventHandler ("onPlayerDamage", getRootElement(), healFlowers ) medicVehicles = { [416]=true } medicSkins = { [274]=true, [275]=true, [276]=true } function medicenterVehicle ( player, seat, jacked ) if ( medicVehicles[getElementModel ( source )] ) and ( not medicSkins[getElementModel ( player )] ) and ( seat == 0 ) then cancelEvent() outputChatBox ( "Only paramedics can drive this vehicle.", player ) end end addEventHandler ( "onVehicleStartEnter", getRootElement(), medicenterVehicle ) Client-side addEventHandler ( "onClientPlayerDamage",localPlayer, function ( attacker, weapon, bodypart) if weapon == 14 then cancelEvent() end end)
12p Posted July 14, 2014 Posted July 14, 2014 setElementHealth triggers the onClientPlayerDamage event, therefore your cancelEvent() will cancel the healing for obvious reasons. The solution is simple: delete those client-side lines of code.
PauloCascus Posted July 14, 2014 Author Posted July 14, 2014 setElementHealth triggers the onClientPlayerDamage event, therefore your cancelEvent() will cancel the healing for obvious reasons.The solution is simple: delete those client-side lines of code. But if i will remove this code, flowers will damage players which i want to heal
12p Posted July 15, 2014 Posted July 15, 2014 onClientPlayerDamage has a health loss percentage parameter. You could add an IF statement to check whether that value is higher than 0 (which means that the player receives damage instead of being healed), and if it IS higher than zero, it cancels the damage.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now