WASSIm. Posted February 14, 2013 Share Posted February 14, 2013 hi guys i have problem want if destroy zombie and destroy blip zombie blips = { } addEvent ( "onZombieSpawn", true ) addEventHandler ( "onZombieSpawn", root, function ( ) for _, v in ipairs ( getElementsByType ( "ped" ) ) do if getElementData ( v, "zombie" ) then if ( not blips [ v ] ) then blips [ v ] = createBlipAttachedTo ( v, 0 ) end end end end ) addEvent ( "onZombieWasted", true ) addEventHandler ( "onZombieWasted", root, function ( ) if ( isElement ( blips [ source ] ) ) then destroyElement ( blips [ source ] ) end end ) Link to comment
50p Posted February 14, 2013 Share Posted February 14, 2013 What you're doing is creating new blip for every zombie every time a zombie spawns. then you end up with plenty of blips attached to all zombies. This is what you're doing: spawned 1st zombie:- loop through all peds and check if they have "zombie" data (only 1 zombies found) - if a ped from the loop is a zombie create new blip for him (just 1 blip - that's fine) spawned 2nd zombie: - loop through all peds and check if they have "zombie" data (2 zombies found) - if a ped from the loop is a zombie then create new blip for him (loop found 2 zombies to create 2 new blips, 1st zombie will have 2 blips now, the new zombie will have 1 blip) spawned 3rd zombie: - loop through all peds and check if they have "zombie" data (3 zombies found) - if a ped from the loop is a zombie then create new blip for him (loop found 3 zombies to create 3 new blips, 1st zombie will have 3 blips now, 2nd zombie will have 2 blips now, the new zombie will have 1 blip) When they die you destroy only the latest blip for the dying zombie, what about the other blips that you created in the pointless loop? They stay on the map. See what you're doing wrong? Link to comment
WASSIm. Posted February 14, 2013 Author Share Posted February 14, 2013 What you're doing is creating new blip for every zombie every time a zombie spawns. then you end up with plenty of blips attached to all zombies.This is what you're doing: spawned 1st zombie:- loop through all peds and check if they have "zombie" data (only 1 zombies found) - if a ped from the loop is a zombie create new blip for him (just 1 blip - that's fine) spawned 2nd zombie: - loop through all peds and check if they have "zombie" data (2 zombies found) - if a ped from the loop is a zombie then create new blip for him (loop found 2 zombies to create 2 new blips, 1st zombie will have 2 blips now, the new zombie will have 1 blip) spawned 3rd zombie: - loop through all peds and check if they have "zombie" data (3 zombies found) - if a ped from the loop is a zombie then create new blip for him (loop found 3 zombies to create 3 new blips, 1st zombie will have 3 blips now, 2nd zombie will have 2 blips now, the new zombie will have 1 blip) When they die you destroy only the latest blip for the dying zombie, what about the other blips that you created in the pointless loop? They stay on the map. See what you're doing wrong? blip no destroyed ! 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