Jump to content

Suporte para Script - Taser


Recommended Posts

Boa noite, eu fiz um sistema de taser, porém ele está com problemas, preciso de ajuda para aprimorar o código, e ajudar a fazer ele a funcionar a opção setanimation, porque ele até funciona, porém não está executando a função setpedanimation, o erro identificado no debug é o seguinte > server.lua:77: Bad Argument @ 'setPedAnimation' [Expected number at argument 4, got boolean (true)]

addEventHandler("onPlayerWeaponFire", root,
function (weapon, endX, endY, endZ, hitElement, startX, startY, startZ)
     local weaponType = getPlayerWeapon (source)
     if weaponType == 23 then
        local x,y,z = getElementPosition(source)
        if (isElement(hitElement) and getElementType(hitElement) == "player") then
             local hx,hy,hz = getElementPosition(hitElement)
        else
             local hx,hy,hz = endX, endY, endZ
        end
        for key, value in ipairs(getElementsByType("player")) do
             local px, py, pz = getElementPosition(value)
             local distance = getDistanceBetweenPoints3D(x, y, z, px, py, pz)
             if distance < 15 then
                 triggerClientEvent(value, "fire_effect", root, source, hitElement, weapon, endX, endY, endZ)
                 print("tiro")
             end
        end
   end
end)

for key, value in ipairs(getElementsByType("player")) do
      toggleControl ( value, "fire", true )
      setElementData(value, "teaser:caido", false)
      setPedAnimation(value)
end

addEvent("teaser_letal", true )
addEventHandler("teaser_letal", getRootElement(), 
function ()
     if not (getElementData(source, "teaser:caido")) then
         setElementData(source, "teaser:caido", true)
         setTimer(setElementData, 15000, 1, source, "teaser:caido", false)
         setElementFrozen(source, true)
         setTimer(setElementFrozen, 16000, 1, source, false)
         setPedAnimation(source, "crack", "crckidle"..math.random(1,4), true, false, false, false )
         setTimer(setPedAnimation, 15000, 1, source)
     end
end)

imagem https://i.postimg.cc/vB5cygQH/image.png

Edited by Lord Henry
Script convertido de texto para Lua.
Link to comment
  • Human Resources Trainee

Hi,

Your topic has been moved to the Portuguese scripting section so that you can get better assistance in your native language.
Make sure to always use English when posting out of this language-specific section.

Link to comment
  • Other Languages Moderators

@thebossofc O erro está dizendo que o 4º argumento do seu setPedAnimation deveria ser um número, mas vc colocou um true no lugar.

setPedAnimation(source, "crack", "crckidle"..math.random(1,4), true, false, false, false )
--                1        2                  3                 4 (era pra ser um número inteiro, o true é só depois)

Faltou você declarar o parâmetro time. Normalmente o valor dele é -1.

  • Like 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...