Jump to content

Why is the second function not working?


Recommended Posts

function CriarGemeo (source)
    local sourceModel = getElementModel(source)
    local sX, sY, sZ = getElementPosition(source)
    outputChatBox ("Criaste um ped com o modelo: " .. sourceModel .. ".")
    twin = createPed(sourceModel, sX, sY, sZ)
end
addCommandHandler("criargemeo", CriarGemeo)


function GemeoMorreu()
    outputChatBox ("O teu gémeo morreu.")
end
addEventHandler("onPedWasted", twin, GemeoMorreu)

The first function works perfectly (the first one that's not super basic and that I created all by myself (YEY). But the second doesn't work and returns me this ERROR:

@ Bad Argument @ 'addEventHandler' [Expected element at argument 2, got nil]

I tried to add source and player between the function GemeoMorreu() parenthisis, but it still doesn't work.

Link to comment
12 minutes ago, Hugo_Almeidowski said:

function CriarGemeo (source)
    local sourceModel = getElementModel(source)
    local sX, sY, sZ = getElementPosition(source)
    outputChatBox ("Criaste um ped com o modelo: " .. sourceModel .. ".")
    twin = createPed(sourceModel, sX, sY, sZ)
end
addCommandHandler("criargemeo", CriarGemeo)


function GemeoMorreu()
    outputChatBox ("O teu gémeo morreu.")
end
addEventHandler("onPedWasted", twin, GemeoMorreu)

The first function works perfectly (the first one that's not super basic and that I created all by myself (YEY). But the second doesn't work and returns me this ERROR:

@ Bad Argument @ 'addEventHandler' [Expected element at argument 2, got nil]

I tried to add source and player between the function GemeoMorreu() parenthisis, but it still doesn't work.

function CriarGemeo (source)
    local sourceModel = getElementModel(source)
    local sX, sY, sZ = getElementPosition(source)
    outputChatBox ("Criaste um ped com o modelo: " .. sourceModel .. ".")
    twin = createPed(sourceModel, sX, sY, sZ)
    addEventHandler("onPedWasted", twin, GemeoMorreu)
end
addCommandHandler("criargemeo", CriarGemeo)


function GemeoMorreu()
    outputChatBox ("O teu gémeo morreu.")
end

 

Link to comment
2 minutes ago, KillerX said:

function CriarGemeo (source)
    local sourceModel = getElementModel(source)
    local sX, sY, sZ = getElementPosition(source)
    outputChatBox ("Criaste um ped com o modelo: " .. sourceModel .. ".")
    twin = createPed(sourceModel, sX, sY, sZ)
    addEventHandler("onPedWasted", twin, GemeoMorreu)
end
addCommandHandler("criargemeo", CriarGemeo)


function GemeoMorreu()
    outputChatBox ("O teu gémeo morreu.")
end

 

Thank you very much. I get it now! It works!

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