Skip to content

RegisterEvent anonymous functions implementation (Additionally prevent CreateEventTimer() to register the same event more than one time)#474

Open
boubouleuh wants to merge 7 commits intoBeamMP:minorfrom
boubouleuh:anonymous_functions
Open

RegisterEvent anonymous functions implementation (Additionally prevent CreateEventTimer() to register the same event more than one time)#474
boubouleuh wants to merge 7 commits intoBeamMP:minorfrom
boubouleuh:anonymous_functions

Conversation

@boubouleuh
Copy link
Contributor

@boubouleuh boubouleuh commented Feb 23, 2026

This PR implements the usage of the function directly inside RegisterEvent() while keeping the possibility of using the function name.

MP.RegisterEvent("Test",function()
Util.LogInfo("TEST")
end)
MP.TriggerLocalEvent("Test")

This needed A LOT of changes; since I'm still a beginner in C++, there are probably a couple of issues that I would be happy to fix (can't imagine that there aren't any).

If this gets merged, it would be better to merge it before #473 to prevent conflicts regarding the DontCallOnInit variable that isn't completely removed in this PR but is in #473.

ofc, I tested every changeand it seemed to work well (im just not sure about the queued lua console cmd)

Closes #449
Closes #441 the panichandler is fixed in this PR

By creating this pull request, I understand that code that is AI generated or otherwise automatically generated may be rejected without further discussion.
I declare that I fully understand all code I pushed into this PR, and wrote all this code myself and own the rights to this code.

…FromCustomEvent that was crashing the server on script reload, mStateFunctionQueue is now a deque

additionally createEventTimer cant register the same event more than one time now
@boubouleuh boubouleuh changed the title RegisterEvent nonymous functions implementation RegisterEvent anonymous functions implementation Feb 23, 2026
@boubouleuh boubouleuh changed the title RegisterEvent anonymous functions implementation RegisterEvent anonymous functions implementation (Additionally prevent CreateEventTimer() to register the same event more than one time) Feb 23, 2026
@boubouleuh
Copy link
Contributor Author

When trying to add more than one event timer it break tho idk how to fix 🫡

@boubouleuh
Copy link
Contributor Author

seems like i found the issues now it doesnt crash anymore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support anonymous functions and multiple handlers in MP.RegisterEvent Lua Stack Corruption leads to x86 stack overflow

1 participant