India Posted March 7, 2021 Share Posted March 7, 2021 Hello, I get this warning's when i bury up zombies in DayZ game mode Bad argument @'getAttachedElements' [Expected element at argument 1] Bad argument @'destroyElement' [Expected element at argument 1] function respawnZombieInTime ( zomb, immediatly ) if exports.npc_hlc:isHLCEnabled ( zomb ) then exports.npc_hlc:disableHLCForNPC (zomb) end --if isElement ( getElementData ( zomb, "zombieShape" ) ) then destroyElement ( getElementData ( zomb, "zombieShape" ) ) end --if isElement ( getElementData ( zomb, "shapeFar" ) ) then destroyElement ( getElementData ( zomb, "shapeFar" ) ) end local resptimer = timeToRespawnZombie if immediatly then resptimer = 20000 end setTimer ( function ( shape ) local attaches = getAttachedElements ( zomb,1) if attaches then for ElementKey, ElementValue in ipairs ( attaches ) do if isElement ( ElementValue ) then destroyElement ( ElementValue ) end end end destroyElement ( zomb,1) aliveZ = aliveZ - 1 if isElement ( shape ) then setElementData ( shape, "zSpawned", false ) setElementData ( shape, "zombie", false ) end end,resptimer, 1, getElementData ( zomb, "spawnShape" ) ) --setElementData ( root, 'zombiesalive', getElementData ( root, 'zombiesalive' )-1 ) end Link to comment
Other Languages Moderators androksi Posted March 7, 2021 Other Languages Moderators Share Posted March 7, 2021 You need to pass the zomb element as a parameter of the setTimer function, the same way you passed the spawn shape. Also make sure it's an element. Link to comment
India Posted March 8, 2021 Author Share Posted March 8, 2021 6 hours ago, andr0xy said: You need to pass the zomb element as a parameter of the setTimer function, the same way you passed the spawn shape. Also make sure it's an element. can you make for me please? Link to comment
SpecT Posted March 13, 2021 Share Posted March 13, 2021 setTimer ( function ( shape, zomb ) local attaches = getAttachedElements ( zomb,1) if attaches then for ElementKey, ElementValue in ipairs ( attaches ) do if isElement ( ElementValue ) then destroyElement ( ElementValue ) end end end destroyElement ( zomb,1) aliveZ = aliveZ - 1 if isElement ( shape ) then setElementData ( shape, "zSpawned", false ) setElementData ( shape, "zombie", false ) end end,resptimer, 1, getElementData ( zomb, "spawnShape" ), zomb ) Link to comment
India Posted March 13, 2021 Author Share Posted March 13, 2021 1 hour ago, SpecT said: setTimer ( function ( shape, zomb ) local attaches = getAttachedElements ( zomb,1) if attaches then for ElementKey, ElementValue in ipairs ( attaches ) do if isElement ( ElementValue ) then destroyElement ( ElementValue ) end end end destroyElement ( zomb,1) aliveZ = aliveZ - 1 if isElement ( shape ) then setElementData ( shape, "zSpawned", false ) setElementData ( shape, "zombie", false ) end end,resptimer, 1, getElementData ( zomb, "spawnShape" ), zomb ) Still same, this lines gives warning; local attaches = getAttachedElements ( zomb,1) destroyElement ( zomb,1) Link to comment
SpecT Posted March 13, 2021 Share Posted March 13, 2021 (edited) Well then the "zomb" element doesn't exist. To prevent the errors you can put a check if "zomb" is an element in both the timer function and the respawnZombieInTime function and stop the execution of the function with "return". Something like this: function respawnZombieInTime ( zomb, immediatly ) if not isElement(zomb) then return end if exports.npc_hlc:isHLCEnabled ( zomb ) then exports.npc_hlc:disableHLCForNPC (zomb) end --if isElement ( getElementData ( zomb, "zombieShape" ) ) then destroyElement ( getElementData ( zomb, "zombieShape" ) ) end --if isElement ( getElementData ( zomb, "shapeFar" ) ) then destroyElement ( getElementData ( zomb, "shapeFar" ) ) end local resptimer = timeToRespawnZombie if immediatly then resptimer = 20000 end setTimer ( function ( shape, zomb ) if not isElement(zomb) then return end local attaches = getAttachedElements ( zomb,1) if attaches then for ElementKey, ElementValue in ipairs ( attaches ) do if isElement ( ElementValue ) then destroyElement ( ElementValue ) end end end destroyElement ( zomb,1) aliveZ = aliveZ - 1 -- this seems to be useless ?? if isElement ( shape ) then setElementData ( shape, "zSpawned", false ) setElementData ( shape, "zombie", false ) end end,resptimer, 1, getElementData ( zomb, "spawnShape" ), zomb ) --setElementData ( root, 'zombiesalive', getElementData ( root, 'zombiesalive' )-1 ) end Edited March 13, 2021 by SpecT 1 Link to comment
India Posted March 13, 2021 Author Share Posted March 13, 2021 1 hour ago, SpecT said: Well then the "zomb" element doesn't exist. To prevent the errors you can put a check if "zomb" is an element. Something like this: Oh,thank you so much 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