1LoL1 Posted September 21, 2015 Share Posted September 21, 2015 Hello, please how i can when zombies attacking me so first will armour down and next health. Now its when i have armour and health 100% and zombies attacked me so zombies taked me only health. function zombieattack ( attacker, weapon, bodypart ) if (attacker) then if getElementType ( attacker ) == "ped" then if (getElementData (attacker, "zombie") == true) then local playerHealth = getElementHealth ( getLocalPlayer() ) if playerHealth > 15 then setElementHealth ( source, playerHealth - 15 ) else triggerServerEvent ("playereaten", source, source, attacker, weapon, bodypart ) end end end end end addEventHandler ( "onClientPlayerDamage", getLocalPlayer(), zombieattack ) Link to comment
Simple0x47 Posted September 21, 2015 Share Posted September 21, 2015 (edited) Try this: function zombieattack ( attacker, weapon, bodypart, loss ) if (attacker) then if getElementType ( attacker ) == "ped" then if (getElementData (attacker, "zombie") == true) then local playerHealth = getElementHealth ( getLocalPlayer() ) local playerArmor = getPedArmor ( getLocalPlayer() ) if playerArmor > 0 then setPedArmor ( source, playerArmor - loss ) elseif playerArmor == 0 then setElementHealth ( source, playerHealth - loss ) elseif playerHealth > 15 then setElementHealth ( source, playerHealth - 15 ) else triggerServerEvent ("playereaten", source, source, attacker, weapon, bodypart ) end end end end end addEventHandler ( "onClientPlayerDamage", getLocalPlayer(), zombieattack ) Edited September 21, 2015 by Guest Link to comment
Simple0x47 Posted September 21, 2015 Share Posted September 21, 2015 Sorry for the first one the Submit button activated accidentally :v Link to comment
1LoL1 Posted September 21, 2015 Author Share Posted September 21, 2015 Sorry for the first one the Submit button activated accidentally :v ah ok but i have here error and you forgot to local loss = 15 attempt to call global "setPedArmor" (a nil value) function zombieattack ( attacker, weapon, bodypart, loss ) if (attacker) then if getElementType ( attacker ) == "ped" then if (getElementData (attacker, "zombie") == true) then local playerHealth = getElementHealth ( getLocalPlayer() ) local playerArmor = getPedArmor ( getLocalPlayer() ) if playerArmor > 0 then local loss = 15 setPedArmor ( source, playerArmor - loss ) elseif playerArmor == 0 then local loss = 15 setElementHealth ( source, playerHealth - loss ) elseif playerHealth > 15 then setElementHealth ( source, playerHealth - 15 ) else triggerServerEvent ("playereaten", source, source, attacker, weapon, bodypart ) end end end end end addEventHandler ( "onClientPlayerDamage", getLocalPlayer(), zombieattack ) Link to comment
HUNGRY:3 Posted September 21, 2015 Share Posted September 21, 2015 Sorry for the first one the Submit button activated accidentally :v ah ok but i have here error and you forgot to local loss = 15 attempt to call global "setPedArmor" (a nil value) function zombieattack ( attacker, weapon, bodypart, loss ) if (attacker) then if getElementType ( attacker ) == "ped" then if (getElementData (attacker, "zombie") == true) then local playerHealth = getElementHealth ( getLocalPlayer() ) local playerArmor = getPedArmor ( getLocalPlayer() ) if playerArmor > 0 then local loss = 15 setPedArmor ( source, playerArmor - loss ) elseif playerArmor == 0 then local loss = 15 setElementHealth ( source, playerHealth - loss ) elseif playerHealth > 15 then setElementHealth ( source, playerHealth - 15 ) else triggerServerEvent ("playereaten", source, source, attacker, weapon, bodypart ) end end end end end addEventHandler ( "onClientPlayerDamage", getLocalPlayer(), zombieattack ) Because setPedArmor is server side So just trigger it Link to comment
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