Hugo_Almeidowski Posted January 24, 2019 Share Posted January 24, 2019 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
KillerX Posted January 24, 2019 Share Posted January 24, 2019 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
Hugo_Almeidowski Posted January 24, 2019 Author Share Posted January 24, 2019 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! 1 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now