Jump to content

AreaVerde\greenzone.lua:19: Bad argument @ 'getElementType' [Expected element at argument 1] [DUP x25]


Recommended Posts

  1. AreaVerde\greenzone.lua:5: Bad argument @ 'addEventHandler' ['onClientPlayerDamage' whith this function is alrealdy handled] [DUP x72]
    addEventHandler ("onResourceStart", getRootElement(), 
    function()
      setTimer (moneyZoneTimerFunction, 2500, 0)
      local allGreenzones = getElementsByType ("radararea")
      for i,v in ipairs (allGreenzones) do
        local r,g,b,a = getRadarAreaColor (v)
        if (r == 0) and (g == 255) and (b == 0) and (a == 127) then
    	setRadarAreaFlashing ( v, true )
          local x,y = getElementPosition (v)
          local sx,sy = getRadarAreaSize (v)
          local col = createColCuboid (x,y, -50, sx,sy, 7500)
          setElementID (col, "greenzoneColshape")
        end
      end
    end)
    
    addEventHandler ("onColShapeHit", getRootElement(), 
    function(hitElement, matchingDimension)
      if (getElementType (hitElement) == "player") and (getElementID (source) == "greenzoneColshape") then
        outputChatBox ("", hitElement, 255, 0, 0, true)
        toggleControl (hitElement, "fire", false)
        toggleControl (hitElement, "next_weapon", false)
        toggleControl (hitElement, "previous_weapon", false)
        toggleControl (hitElement, "sprint", true)
        toggleControl (hitElement, "aim_weapon", false)
        toggleControl (hitElement, "vehicle_fire", false)
        showPlayerHudComponent (hitElement, "ammo", false)
        showPlayerHudComponent (hitElement, "weapon", false)
        triggerClientEvent (hitElement, "enableGodMode", hitElement)
      end
      if (source == moneyZoneCol) and (getElementType (hitElement) == "vehicle") then
        setElementVelocity (hitElement, 0, 0, 0)
        setElementPosition (hitElement, 2018.33, 1534.77, 12.37)
        setVehicleRotation (hitElement, 0,0,270)
        if (getVehicleOccupant (hitElement, 0)) then
          outputChatBox ("", getVehicleOccupant (hitElement, 0), 255, 0, 0, false)
        end
      end
    end)
    
    addEventHandler ("onColShapeLeave", getRootElement(), 
    function(leaveElement, matchingDimension)
      if (getElementType (leaveElement) == "player") and (getElementID (source) == "greenzoneColshape") then
        outputChatBox ("", leaveElement, 255, 0, 0, false)
        toggleControl (leaveElement, "fire", true)
        toggleControl (leaveElement, "next_weapon", true)
        toggleControl (leaveElement, "previous_weapon", true)
        toggleControl (leaveElement, "sprint", true)
        toggleControl (leaveElement, "aim_weapon", true)
        toggleControl (leaveElement, "vehicle_fire", true)
        showPlayerHudComponent (leaveElement, "ammo", false)
        showPlayerHudComponent (leaveElement, "weapon", false)
        triggerClientEvent (leaveElement, "disableGodMode", leaveElement)
      end
    end)
    
    --money zone col
    moneyZoneCol = createColCuboid (1993.12, 1519.14, -100, 17.43, 54.24, 117)
    --stop moneyzone col
    
    function moneyZoneTimerFunction ()
      local allPlayersInCol = getElementsWithinColShape (moneyZoneCol, "player")
      for i,v in ipairs (allPlayersInCol) do
        givePlayerMoney (v, 5)
      end
    end
    
    -- marker bij hospital

     

Link to comment
  • Other Languages Moderators

Não coloque títulos muito grandes no seu post. Seja breve com uma pequena frase.

No texto do post dai vc explica com mais detalhes o seu problema.

E você não colocou a parte onde ocorre o problema. Não temos como adivinhar se você não coloca a parte onde o erro ocorre.

  • Thanks 1
Link to comment

Erro linha 5: Bad argument @ 'addEventHandler' ['onClientPlayerDamage' whith this function is alrealdy handled] [DUP x72]

addEvent("enableGodMode", true)
addEvent("disableGodMode", true)
addEventHandler ("enableGodMode", getRootElement(), 
function()
  addEventHandler ("onClientPlayerDamage", getRootElement(), cancelEventEvent)
end)

Erro Linha 19Bad argument @ 'getElementType' [Expected element at argument 1]

addEventHandler ("onResourceStart", getRootElement(), 
function()
  setTimer (moneyZoneTimerFunction, 2500, 0)
  local allGreenzones = getElementsByType ("radararea")
  for i,v in ipairs (allGreenzones) do
    local r,g,b,a = getRadarAreaColor (v)
    if (r == 0) and (g == 255) and (b == 0) and (a == 127) then
	setRadarAreaFlashing ( v, true )
      local x,y = getElementPosition (v)
      local sx,sy = getRadarAreaSize (v)
      local col = createColCuboid (x,y, -50, sx,sy, 7500)
      setElementID (col, "greenzoneColshape")
    end
  end
end)

addEventHandler ("onColShapeHit", getRootElement(), 
function(hitElement, matchingDimension)
  if (getElementType (hitElement) == "player") and (getElementID (source) == "greenzoneColshape") then
    outputChatBox ("", hitElement, 255, 0, 0, true)
    toggleControl (hitElement, "fire", false)
    toggleControl (hitElement, "next_weapon", false)
    toggleControl (hitElement, "previous_weapon", false)
    toggleControl (hitElement, "sprint", true)
    toggleControl (hitElement, "aim_weapon", false)
    toggleControl (hitElement, "vehicle_fire", false)
    showPlayerHudComponent (hitElement, "ammo", false)
    showPlayerHudComponent (hitElement, "weapon", false)
    triggerClientEvent (hitElement, "enableGodMode", hitElement)
  end
  if (source == moneyZoneCol) and (getElementType (hitElement) == "vehicle") then
    setElementVelocity (hitElement, 0, 0, 0)
    setElementPosition (hitElement, 2018.33, 1534.77, 12.37)
    setVehicleRotation (hitElement, 0,0,270)
    if (getVehicleOccupant (hitElement, 0)) then
      outputChatBox ("", getVehicleOccupant (hitElement, 0), 255, 0, 0, false)
    end
  end
end)

addEventHandler ("onColShapeLeave", getRootElement(), 
function(leaveElement, matchingDimension)
  if (getElementType (leaveElement) == "player") and (getElementID (source) == "greenzoneColshape") then
    outputChatBox ("", leaveElement, 255, 0, 0, false)
    toggleControl (leaveElement, "fire", true)
    toggleControl (leaveElement, "next_weapon", true)
    toggleControl (leaveElement, "previous_weapon", true)
    toggleControl (leaveElement, "sprint", true)
    toggleControl (leaveElement, "aim_weapon", true)
    toggleControl (leaveElement, "vehicle_fire", true)
    showPlayerHudComponent (leaveElement, "ammo", false)
    showPlayerHudComponent (leaveElement, "weapon", false)
    triggerClientEvent (leaveElement, "disableGodMode", leaveElement)
  end
end)

--money zone col
moneyZoneCol = createColCuboid (1993.12, 1519.14, -100, 17.43, 54.24, 117)
--stop moneyzone col

function moneyZoneTimerFunction ()
  local allPlayersInCol = getElementsWithinColShape (moneyZoneCol, "player")
  for i,v in ipairs (allPlayersInCol) do
    givePlayerMoney (v, 5)
  end
end

-- marker bij hospital

 

Link to comment
  • Other Languages Moderators

A linha 5 está dando um alerta pois o evento está sendo ativado quando ele já está ativo. Pois falta um removeEventHandler quando o jogador sai da zona verde.

addEventHandler ("disableGodMode", getRootElement(), 
function()
  removeEventHandler ("onClientPlayerDamage", getRootElement(), cancelEventEvent)
end)

E a função cancelEventEvent não existe. Ou então você não mostrou a parte do código que ela aparece.

------------------------

Nem tudo que colide nas zonas é uma entidade válida. Adicione um verificador antes da condição, para ver se o que colidiu é um elemento.

 if isElement (hitElement) and (getElementType (hitElement) == "player") and (getElementID (source) == "greenzoneColshape") then

Obs: Existe um jeito mais fácil e mais leve de criar zonas verdes sem o uso de zonas de colisão. Usando apenas isInsideRadarArea para verificar se o jogador que está recebendo dano está dentro da zona ou não. Se estiver, cancela o dano e pronto.

  • Thanks 1
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...