Jump to content

help blip


WASSIm.

Recommended Posts

hi guys

i have problem blip zombie he is working only start script and if spawn zombie or wasted nothing :(

  
local zombieBlips = {} 
  
addEventHandler( "onClientResourceStart", getResourceRootElement( getThisResource() ), 
    function () 
        for k, theZombie in ipairs ( getElementsByType( "ped" ) ) do 
            if (getElementData ( theZombie, "zombie" ) == true) then 
                if not ( zombieBlips[theZombie] ) then 
                    zombieBlips[theZombie] = createBlipAttachedTo( theZombie, 0, 1, 162, 2, 2, 100 ) 
                end 
            end 
        end 
    end 
) 
  
addEvent ( "onZombieSpawn", true ) 
addEventHandler ( "onZombieSpawn", root, 
    function() 
        if (getElementData ( source, "zombie" ) == true) then 
            if not ( zombieBlips[source] ) then 
                zombieBlips[source] = createBlipAttachedTo( source, 0, 1, 162, 2, 2, 100 ) 
            end 
        end 
    end 
) 
  
addEvent ( "onZombieWasted", true ) 
addEventHandler ( "onZombieWasted", root, 
    function () 
        if ( isElement( zombieBlips[source] ) ) then 
            destroyElement( zombieBlips[source] ) 
            zombieBlips[source] = nil 
        end 
    end 
) 
  

Link to comment

These events need to be triggered. Are they triggered when zombies spawn/die? To me it looks like these events may be triggered but server-side only and you're trying to use these events in a client-side script.

Link to comment
These events need to be triggered. Are they triggered when zombies spawn/die? To me it looks like these events may be triggered but server-side only and you're trying to use these events in a client-side script.

i change this script server said but nothing

Link to comment

If you simply changed the script type in meta.xml from client to server then it should work only when zombies spawn/die. Your script is a mixture of client and server side scripts.

1. You're using onClientResourceStart - client-side event

2. onZombieSpawn and onZombieWasted - both look like server-side events (check the zombie resource documentation)

Link to comment

nothing changed its like client said !

  
local zombieBlips = {} 
  
addEventHandler( "onResourceStart", getResourceRootElement( getThisResource() ), 
    function () 
        for k, theZombie in ipairs ( getElementsByType( "ped" ) ) do 
            if (getElementData ( theZombie, "zombie" ) == true) then 
                if not ( zombieBlips[theZombie] ) then 
                    zombieBlips[theZombie] = createBlipAttachedTo( theZombie, 0, 1, 162, 2, 2, 100 ) 
                    setBlipVisibleDistance( zombieBlips[theZombie], 100 ) 
                end 
            end 
        end 
    end 
) 
  
addEvent ( "onZombieSpawn", true ) 
addEventHandler ( "onZombieSpawn", root, 
    function() 
        if (getElementData ( source, "zombie" ) == true) then 
            if not ( zombieBlips[source] ) then 
                zombieBlips[source] = createBlipAttachedTo( source, 0, 1, 162, 2, 2, 100 ) 
                setBlipVisibleDistance( zombieBlips[source], 100 ) 
            end 
        end 
    end 
) 
  
addEvent ( "onZombieWasted", true ) 
addEventHandler ( "onZombieWasted", root, 
    function () 
        if ( isElement( zombieBlips[source] ) ) then 
            destroyElement( zombieBlips[source] ) 
            zombieBlips[source] = nil 
        end 
    end 
) 
  

Link to comment
Well, can you read what 50p said?

Also, I found answer for your problem:

https://forum.multitheftauto.com/viewtop ... 87#p515469

Your script should be server-side.

its already server said!!!

thx for link i fix create blip if zombie spawn but if zombie hiding not hiding blip :(

local zombieBlips = {} 
  
addEventHandler( "onResourceStart", getResourceRootElement( getThisResource() ), 
    function () 
        for k, theZombie in ipairs ( getElementsByType( "ped" ) ) do 
            if (getElementData ( theZombie, "zombie" ) == true) then 
                if not ( zombieBlips[theZombie] ) then 
                    zombieBlips[theZombie] = createBlipAttachedTo( theZombie, 0, 1, 162, 2, 2, 100 ) 
                    setBlipVisibleDistance( zombieBlips[theZombie], 100 ) 
                end 
            end 
        end 
    end 
) 
  
addEvent ( "onZombieSpawn", true ) 
addEventHandler ( "onZombieSpawn", root, 
    function() 
        for k, theZombie in ipairs ( getElementsByType( "ped" ) ) do 
            if (getElementData ( theZombie, "zombie" ) == true) then 
                if not ( zombieBlips[theZombie] ) then 
                    zombieBlips[theZombie] = createBlipAttachedTo( theZombie, 0, 1, 162, 2, 2, 100 ) 
                    setBlipVisibleDistance( zombieBlips[theZombie], 100 ) 
                end 
            end 
        end 
    end 
) 
  
addEvent ( "onZombieWasted", true ) 
addEventHandler ( "onZombieWasted", root, 
    function () 
        if ( isElement( zombieBlips[source] ) ) then 
            destroyElement( zombieBlips[source] ) 
            zombieBlips[source] = nil 
        end 
    end 
) 

Link to comment
  • Moderators

Destroys the zombie, not hide it.

It will be hidden when you set it to another dimension/interior/location or something like that.

  
addEventHandler("onElementDestroy", root,  
function () 
      if getElementType(source)=="ped" and isElement(zombieBlips[source]) then 
            destroyElement(zombieBlips[source]) 
      end 
end) 

Link to comment
Destroys the zombie, not hide it.

It will be hidden when you set it to another dimension/interior/location or something like that.

  
addEventHandler("onElementDestroy", root,  
function () 
      if getElementType(source)=="ped" and isElement(zombieBlips[source]) then 
            destroyElement(zombieBlips[source]) 
      end 
end) 

thank you very much :D

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...