138 Commits

Author SHA1 Message Date
Lucca Jiménez Könings
29f4d0d286 run clang-format 2024-06-26 14:06:06 +02:00
Lucca Jiménez Könings
25739cb1bd Merge branch 'minor' into 158-bug-running-settings-help-returns-nothing 2024-06-26 11:43:38 +02:00
sla-ppy
1b60e89f26 add lua info on LuaEngine startup 2024-05-24 12:31:01 +02:00
Maximilian Rehms
7f54bcfaec
successful implemented suggested change to "lua_nil"
Co-authored-by: Lion <development@kortlepel.com>
2024-05-18 22:36:57 +02:00
Maximilian Rehms
40e5496819 compiles now on macos 2024-05-18 15:06:26 +02:00
Lucca Jiménez Könings
8c15b87628
Refactor all references to settings to use new Settings type
Signed-off-by: Lucca Jiménez Könings <development@jimkoen.com>
2024-05-15 12:52:09 +02:00
Lion Kortlepel
c5dff8b913
fix lua assertion on event argument passing
When adding elements to a table, the .add() function does not behave as
expected in various cases, making it really shit and difficult to use.
Instead, we keep our own index and just add one by one. It works, and
it's easy to understand.

This may lead to indices which are nil, i.e. non-fully-sequential
tables, but I can't be asked to worry about it because that shouldn't be
an issue when we use .set() everywhere.
2024-05-10 14:45:06 +02:00
Lion
586510041d
fix TriggerGlobalEvent not passing event arguments correctly (#307)
This is supposed to close #106 (The code is by @lionkor from
b068a9b48f)
2024-05-08 11:47:23 +02:00
Lion
1794c3fe45
Add Lua execution profiler Util.DebugExecutionTime() (#267)
Adds `Util.DebugExecutionTime()`, which returns a table of
`function_name: milliseconds`, in which each function's execution time
is averaged over all time.

You can call this function like so:
```lua
-- event to print the debug times
MP.RegisterEvent("printStuff", "printStuff")
-- prints the execution time of all event handlers
function printStuff()
	print(Util.DebugExecutionTime())
end
-- run every 5 seconds (or 10, or 60, whatever makes sense for you
MP.CreateEventTimer("printStuff", 5000)
```

Pretty print function:
```lua
function printDebugExecutionTime()
    local stats = Util.DebugExecutionTime()
    local pretty = "DebugExecutionTime:\n"
    local longest = 0
    for name, t in pairs(stats) do
        if #name > longest then
            longest = #name
        end
    end
    for name, t in pairs(stats) do
        pretty = pretty .. string.format("%" .. longest + 1 .. "s: %12f +/- %12f (min: %12f, max: %12f) (called %d time(s))\n", name, t.mean, t.stdev, t.min, t.max, t.n)
    end
    print(pretty)
end
```

`Util.DebugExecutionTime()` returns a table, where each key is an event
handler function name, and each value is a table consisting of `mean`
(simple average), `stddev` (standard deviation aka mean of the
variance), `min` and `max`, all in milliseconds, as well as `n` as the
number of samples taken.
2024-05-08 11:46:02 +02:00
Lion Kortlepel
40158dc252
fix compile error 2024-05-08 11:31:12 +02:00
Neptnium
5ece60574a
Make Plugin load order deterministic
fix typo "mResourceServerPath" named "mFolder"

Fix typo number 2
2024-05-08 11:31:05 +02:00
Neptnium
c605498a2d
Merge branch 'BeamMP:minor' into minor 2024-05-07 08:26:44 +02:00
Lion Kortlepel
5cf6d1d228
add Util.LogDebug 2024-04-20 20:16:57 +02:00
Lion Kortlepel
1237e7e533
add lua logging facilities as Util.Log*() functions 2024-04-19 11:10:50 +02:00
Neptnium
d81087b5af
fix TriggerGlobalEvent not passing event arguments correctly (closes #106) 2024-04-18 18:43:04 +02:00
Lion Kortlepel
e4826e8bf1
remove test code 2024-03-07 00:42:36 +01:00
Lion Kortlepel
590b159f14
switch to a runnning calculation for stdev and mean 2024-03-07 00:25:47 +01:00
Lion Kortlepel
40533c04bc add total calls to stats 2024-03-06 10:27:22 +01:00
Lion Kortlepel
946c1362e1 add custom profiling via Debug(Start|Stop)Profile 2024-03-06 10:27:22 +01:00
Lion Kortlepel
4347cb4af2 add min, max, stddev to stats 2024-03-06 10:27:22 +01:00
Lion Kortlepel
7deea900fb add Util.DebugExecutionTime 2024-03-06 10:27:22 +01:00
Lion Kortlepel
aff537afdf add AGPL-3.0 license header 2024-01-23 21:00:11 +01:00
Lion Kortlepel
a4eb10b6a4 fix MP.GetPositionRaw 2024-01-09 15:34:33 +01:00
rgnter
b7b578bf3e add conditional variable to LuaResult 2022-12-18 14:45:33 +01:00
Lion Kortlepel
5d3dff3c88
add identifiers (beammp id, ip) as an argument to onPlayerAuth 2022-10-03 15:31:32 +02:00
Lion Kortlepel
cb0cb30797
fix windows compiler not understanding a CLEAR AND SIMPLE FUNCTION-STYLE
CONSTRUCTOR CALL

AHHHHHHH
2022-10-03 15:12:59 +02:00
Lion Kortlepel
658b37acac
fix error sometimes not displaying when failing inside global event handler 2022-10-03 14:38:19 +02:00
Lion Kortlepel
24c98eb2b2
add more compile-time diagnostics, implement fixes for them
Before, a lot of common errors went unnoticed, due to insufficient
compiler diagnostics. This commit fixes this by adding a lot of new
diagnostics, and fixing the issues found by this.
2022-09-26 12:02:05 +02:00
20dka
b71aa2db04
advanced autocomplete for lua 2022-09-26 00:13:16 +02:00
20dka
44b94c9e58 add MP.GetPositionRaw(pid, vid)
fix vehicles sometimes not deleting for all players
2022-09-14 01:54:49 +02:00
Lion Kortlepel
054016a099
remove debug print 2022-07-20 16:08:56 +02:00
Lion Kortlepel
8b57f6e35a
fix missing Lua error messages in ResultCheckThread 2022-07-20 16:07:00 +02:00
Lion Kortlepel
fd7b11f436
fix event loop timing issue
The event loop tries to run no faster than every 10ms. If it detects
that it goes faster, it would incorrectly calculate the difference, and
then wait (what I assume was) way too long or too short.
Either way, now it's fixed and it correctly works, even when introducing
new lua states.
2022-07-20 14:33:19 +02:00
Lion Kortlepel
dfa90da8af
check if Resources/Server directory exists, and only create it if it doesnt
While this doesn't make a difference with usual setups, it does if the
server path exists but is a symlink. In that case, the
create_directories call fails, and the server aborts.

this fixes that. :^)
2022-06-30 20:19:48 +02:00
Lion Kortlepel
36547d1e9e
Move PluginMonitor out of TLuaEngine 2022-05-26 20:59:53 +02:00
Lion Kortlepel
f06f31c2a0
add moar tests!!! 2022-05-26 16:58:13 +02:00
Lion Kortlepel
23af76dba1
Only warn once about event handlers taking >60s 2022-03-31 23:12:50 +02:00
Lion Kortlepel
450f0a6875
Fixup merge 2022-03-31 22:17:10 +02:00
Lion Kortlepel
104737571c
Merge branch 'rc-v3.0.2' into rc-v3.1.0
This is a periodic merge to keep 3.1.0 up to date with 3.0.2
2022-03-31 22:10:49 +02:00
Lion Kortlepel
d4b30a2583
CreateEventTimer: Implement CallStrategy
There are two CallStrategies:

- BestEffort (default): Will try to get your event to trigger at the specified
  interval, but will refuse to queue handlers if a handler takes too
  long.
- Precise: Will enqueue event handlers at the exact interval specified.
  Can lead to the queue filling up if the handler takes longer than the
  interval.
2022-03-31 20:13:59 +02:00
Lion Kortlepel
b97397132d
TLuaEngine: improve result queue handling 2022-03-31 15:59:31 +02:00
Lion Kortlepel
d0bb32ec63
cleanup fixme's, todo's 2022-03-24 14:26:02 +01:00
Lion Kortlepel
c1e216957b
move Json* to Util, add Random, RandomRange, RandomIntRange, catch
errors in TPluginMonitor
2022-03-18 01:52:31 +01:00
Lion Kortlepel
be498be661
change TriggerClientEvent to take object, not string, and add TriggerClientEventJson 2022-03-17 18:48:50 +01:00
20dka
3c08e54471 Add basic autocomplete (fix #95) 2022-03-15 01:58:26 +01:00
Lion Kortlepel
ca3314b416
add JsonDiffApply, JsonMinify, JsonPrettify, JsonFlatten, JsonUnflatten 2022-03-03 12:25:06 +01:00
Lion Kortlepel
7d97c3b560
add FS.ListFiles, FS.ListDirectories 2022-03-02 23:41:32 +01:00
Lion Kortlepel
9a0cdc6517
rename JsonSerialize to JsonEncode, JsonDeserialize to JsonDecode 2022-03-02 13:26:53 +01:00
Lion Kortlepel
965935a0e6
catch invalid json to JsonDeserialize, use lua_nil instead of nil 2022-03-02 13:25:29 +01:00
Lion Kortlepel
b52677e585
Add JsonDeserialize 2022-03-02 13:22:26 +01:00