Chaos Posted January 3, 2014 Share Posted January 3, 2014 hi, i have problem with this code not working function killzombieinwater() zombie = getElementData(source,"zombie") if isElementInWater(zombie) then killPed(zombie) end end addEventHandler("onZombieSpawn",root,killzombieinwater) i want when the zombie spawn and hit the water then he will die Link to comment
Castillo Posted January 3, 2014 Share Posted January 3, 2014 function killzombieinwater ( ) local zombie = getElementData ( source, "zombie" ) if isElementInWater ( zombie ) then killPed ( zombie ) end end addEvent ( "onZombieSpawn", true ) addEventHandler ( "onZombieSpawn", root, killzombieinwater ) Link to comment
Chaos Posted January 4, 2014 Author Share Posted January 4, 2014 it's working but the zombies die so slowly Link to comment
Castillo Posted January 4, 2014 Share Posted January 4, 2014 What do you mean by "slowly"? Link to comment
Chaos Posted January 4, 2014 Author Share Posted January 4, 2014 i want when the zombie touch the water die directly Link to comment
.:HyPeX:. Posted January 4, 2014 Share Posted January 4, 2014 When you did killped (zombie) it dies.. how it can not be dead? you may say that it does not dissapear...? try with this: destroyElement ( element elementToDestroy ) Maybe...? function killzombieinwater ( ) local zombie = getElementData ( source, "zombie" ) if isElementInWater ( zombie ) then killPed ( zombie ) destroyElement( zombie ) end end addEvent ( "onZombieSpawn", true ) addEventHandler ( "onZombieSpawn", root, killzombieinwater ) Link to comment
isa_Khamdan Posted January 4, 2014 Share Posted January 4, 2014 Guys please help Did you try using destroyElement? Link to comment
Chaos Posted January 5, 2014 Author Share Posted January 5, 2014 When you did killped (zombie) it dies.. how it can not be dead? you may say that it does not dissapear...?try with this: destroyElement ( element elementToDestroy ) Maybe...? function killzombieinwater ( ) local zombie = getElementData ( source, "zombie" ) if isElementInWater ( zombie ) then killPed ( zombie ) destroyElement( zombie ) end end addEvent ( "onZombieSpawn", true ) addEventHandler ( "onZombieSpawn", root, killzombieinwater ) not working Link to comment
.:HyPeX:. Posted January 8, 2014 Share Posted January 8, 2014 BUMP Can you post a pick of the problem so we can understand the real problem?? Link to comment
Chaos Posted January 9, 2014 Author Share Posted January 9, 2014 The problem is the code is working fine but when zombie touch the water won't die directly he spend a lot of time to die Link to comment
xVincenzoDriftx Posted January 9, 2014 Share Posted January 9, 2014 try this... function killzombieinwater ( ) local zombie = getElementData ( source, "zombie" ) if isElementInWater ( zombie ) then setElementHealth ( zombie, 0 ) end end addEvent ( "onZombieSpawn", true ) addEventHandler ( "onZombieSpawn", root, killzombieinwater ) Link to comment
Chaos Posted January 10, 2014 Author Share Posted January 10, 2014 still same problem warning:script.lua:3 Bad argument @ 'isElementInWater' [Expected element at argument 1, got boolean Link to comment
Castillo Posted January 10, 2014 Share Posted January 10, 2014 'source' isn't a ped element then. Link to comment
WASSIm. Posted January 10, 2014 Share Posted January 10, 2014 guys what are doing ? function killzombieinwater ( ) local zombie = getElementData ( source, "zombie" ) if zombie and isElementInWater ( source ) then destroyElement( source ) end end addEvent ( "onZombieSpawn", true ) addEventHandler ( "onZombieSpawn", root, killzombieinwater ) Link to comment
.:HyPeX:. Posted January 10, 2014 Share Posted January 10, 2014 I think i got it, he isnt triggering the event onZombieSpawn on the zombie, he is just triggering (i think becouse we dont have the full script, and source should work) Link to comment
xVincenzoDriftx Posted January 10, 2014 Share Posted January 10, 2014 'source' isn't a ped element then. function killzombieinwater ( ) local zombie = getElementData (ped, "zombie" ) if isElementInWater ( zombie ) then setElementHealth ( zombie, 0 ) end end addEvent ( "onZombieSpawn", true ) addEventHandler ( "onZombieSpawn", root, killzombieinwater ) this work? 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