Jump to content

removeEventHandler


Plate

Recommended Posts

Hola necesito ayuda con este resource es que me da error en el "removeEventHandler"

  
function rdx(message) 
    setTimer(removeEventHandler, 9000, 1, "onClientRender", getRootElement(), dx ) 
    function dx() 
  
        dxDrawText(getPlayerName(localPlayer)..":",12.0,176.0,141.0,214.0,tocolor(255,0,0,255),1.0,"bankgothic","left","top",false,false,false) 
  
        dxDrawText(message,129.0,176.0,796.0,207.0,tocolor(255,255,255,255),2.0,"arial","left","top",false,false,false) 
    end 
    addEventHandler("onClientRender", getRootElement(), dx) 
end 
addEvent("onAdminMessage", true ) 
addEventHandler("onAdminMessage", getRootElement(), rdx) 

Link to comment

intenta esto:

  
function rdx(message) 
  
    setTimer(function() 
    removeEventHandler("onClientRender",getRootElement(),dx) 
    end,9000,1) 
  
    function dx() 
  
        dxDrawText(getPlayerName(localPlayer)..":",12.0,176.0,141.0,214.0,tocolor(255,0,0,255),1.0,"bankgothic","left","top",false,false,false) 
  
        dxDrawText(message,129.0,176.0,796.0,207.0,tocolor(255,255,255,255),2.0,"arial","left","top",false,false,false) 
    end 
    addEventHandler("onClientRender", getRootElement(), dx) 
end 
addEvent("onAdminMessage", true ) 
addEventHandler("onAdminMessage", getRootElement(), rdx) 

Link to comment
function dx() 
dxDrawText(getPlayerName(localPlayer)..":",12.0,176.0,141.0,214.0,tocolor(255,0,0,255),1.0,"bankgothic","left","top",false,false,false) 
dxDrawText(message,129.0,176.0,796.0,207.0,tocolor(255,255,255,255),2.0,"arial","left","top",false,false,false) 
end 
  
function rdx(message) 
    addEventHandler("onClientRender", getRootElement(), dx) 
    setTimer( 
    function() 
    removeEventHandler("onClientRender",getRootElement(),dx) 
    end 
    ,9000,1 
    ) 
end 
addEvent("onAdminMessage", true ) 
addEventHandler("onAdminMessage", getRootElement(), rdx) 

Ahi te va a funcionar.

Link to comment

._. Entonces solid, yo y alvarez respondimos para nada ._. xD

No veo para que le dan todo hecho, con mi comentario ya era suficiente.

Solo lo puse para mostrarle por si las dudas y porque estoy aburrido u.u

Link to comment

Lo unico es que tengo un problema con esto mira yo creo los zombies en el spot y si alguien los mata no respawnea ese respawnean la cantidad que aya en el spot llega un momento que da un lagg terrible!

function Zomb_respawn (ped) 
    if isElement(ped) then 
        if (getElementData (ped, "zombie") == true) then 
            for theKey,thePed in ipairs(zombiesInSpot) do 
                if ped == thePed then 
                    table.remove( zombiesInSpot, theKey ) 
                    break 
                end 
            end 
            local zombieSkin = getElementModel(ped) 
            local zombieLevel = getElementData(ped,"level") 
            local maxHP = getElementData(ped,"maxhealth") 
            local zombieSpot = getElementData(ped,"zombieSpot") 
            local spotRadius = getElementData(zombieSpot,"radius") 
            local sortZombies = spotRadius/1.2 
            local sx,sy,sz = getElementPosition(zombieSpot) 
            local zom = createZombie (sx+math.random(-sortZombies,sortZombies),sy+math.random(-sortZombies,sortZombies),sz+1.5,math.random(1,360),zombieSkin,0,0,zombieLevel,maxHP) 
            table.insert(zombiesInSpot,zom) 
            setElementData(zom,"zombieSpot",zombieSpot) 
        end 
    end 
end 
  
function respawnZombieWhenDead(dataName) 
    if getElementType ( source ) == "ped" and dataName == "status" then 
        if (getElementData (source, "zombie") == true) then 
            if (getElementData ( source, "status" ) ==  "dead" ) then 
                setTimer ( Zomb_respawn, 9000, 1, source) 
            end 
        end 
    end 
end 
addEventHandler ( "onElementDataChange", getRootElement(),respawnZombieWhenDead ) 

Link to comment
  • Recently Browsing   0 members

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