Jump to content

Is MTA Script Editor bugged or is it my error?


proracer

Recommended Posts

I was testing simple functions like example these ones.

addEventHandler("onResourceStart", resourceRoot, blowAllPlayers, 
    function blowAllPlayers() 
        for i,v in iterElements("player") do 
            if getElementHealth(v) == 0 then return false 
            else 
            setElementHealth(v, 0) 
            outputChatBox("Everyone are now dead!", root, 0, 252, 255, false) 
            end 
        end 
    end 
) 

And simple one...

addEventHandler("onResourceStart", resourceRoot, testFunc, 
    function testFunc() 
        outputChatBox("Hello World") 
        end 
    end 
) 

In both says I forgot to close a bracket in first line...

If it's a bug I think it should be fixed ;)

Link to comment

Actually, you should know that 50p isn't anymore developing Script Editor.

And your codes are wrong.

Errors:

1. The function MUST NOT be named when it only is attached to a specific event handler.

2. If the function may be used by more than just an event handler then you should name it and place it before the event handler, without being inside the addEventHandler function, like this:

function a () 
--Code... 
end 
addEventHandler ("onResourceStart", getResourceRootElement(), a) 

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