Commit Graph

166 Commits

Author SHA1 Message Date
Tixx
4af0e4ccac feature: BEAMMP_PROVIDER_DISABLE_MP_SET environment variable (#461)
This pull request adds BEAMMP_PROVIDER_DISABLE_MP_SET variable
(true/false/1/0) to disable MP::Set for providers.

---

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.
2026-03-21 20:11:51 +01:00
TechStreet
f38797a9ab feature: BEAMMP_PROVIDER_DISABLE_MP_SET environment variable 2026-02-24 17:39:22 +00:00
boubouleuh
595247d51d adding logchat boolean to MP.SendChatMessage 2026-02-02 22:33:58 +01:00
Tixx
99476a2c77 Revert "Add stack trace to server lua engine (#350)" 2026-01-15 14:44:13 +01:00
Kipstz
b74f0c7ca8 refactor: optimize string operations and improve code clarity
- Avoid redundant substr() calls in packet parsing hot-path (TServer.cpp)
  The previous code called substr(3) twice per packet, creating
  unnecessary temporary strings. Now stores the result once.

- Replace .size() == 0 with .empty() for idiomatic C++
  (TConsole.cpp, TLuaEngine.cpp)
2025-12-27 23:46:45 +01:00
Tixx
6318ca79e7 Implement Dialog packet and add MP.ConfirmationDialog 2025-06-25 13:22:05 +02:00
Tixx
731599f16e Json vehicle state and apply paint packet (#416)
Converts the vehicle stored client side from a raw string to parsed json
data. This allows us to more easily edit the vehicle state serverside,
which I've started using in this PR for updating the state after a paint
packet.

---

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.
2025-06-19 17:46:49 +02:00
Tixx
6286457fa4 Revert "support for nested lua handlers" 2025-03-15 22:29:37 +01:00
Tixx
00560f7646 Wait for the server to start before loading plugins or allowing connections 2025-02-15 21:47:17 +01:00
Tixx
2f577a2358 Store vehicles in parsed json 2025-01-25 22:16:06 +01:00
Tixx
fb2e26bd28 Allow for empty icon param in MP.SendNotification 2024-11-12 12:35:12 +01:00
Tixx
956d6f50e1 Add setting for the information packet 2024-10-14 00:39:12 +02:00
Lion
cf3985ce00 Add Lua function to get a player's role (#366)
Adds `MP.GetPlayerRole(player_id)` to the Lua API to get a player's role
("USER", "EA", "MDEV", "STAFF", "ET") by their player id.
Currently you can only get someone's role in onPlayerAuth from the
parameters and in onVehicleSpawned and onVehicleEdited from the packet
data, but not in onPlayerJoin for example without storing it.
2024-10-05 16:09:37 +02:00
Lion
0850cde1fb Add MP.SendNotification (#373)
Adds MP.SendNotification(message, icon, category (optional) ) to the Lua
api. Uses the newly added "N" packet in the mod.
2024-10-05 16:07:27 +02:00
Tixx
9a0270cb09 Return nil instead of "" when there's no client 2024-09-28 21:05:04 +02:00
Tixx
3ade7f5743 Add MP.SendNotification 2024-09-28 13:35:25 +02:00
Tixx
17185da53b Add MP.Get 2024-09-21 23:17:08 +02:00
Tixx
623dfa17d5 Remove expiry check and add braces 2024-09-20 14:45:41 +02:00
Tixx
caafb216c9 Add MP.GetPlayerRole(player_id) 2024-09-19 07:51:07 +02:00
20dka
ee03afb9a1 fix gh linux build 2024-08-29 20:17:01 +02:00
20dka
f775678e2e support for nested lua handlers 2024-08-28 22:46:37 +02:00
20dka
45bb6ca6f3 fill out lua EventName 2024-08-28 22:15:57 +02:00
SaltySnail
4a062e5aa0 Fix not following naming convention
Co-authored-by: Lion <development@kortlepel.com>
2024-07-27 19:50:24 +02:00
SaltySnail
012ce08b91 Add proper lua server stacktraces 2024-07-14 03:18:59 +02:00
Lion Kortlepel
9db3619cd8 cleanup and add comments to traceback feature 2024-07-14 01:50:31 +02:00
Lion Kortlepel
6f4c3f0ceb add traceback to lua errors by way of shitty lua hacks 2024-07-14 01:43:01 +02:00
SaltySnail
4fad047bf4 Add working stacktrace 2024-07-14 01:00:57 +02:00
SaltySnail
5502c74229 add stacktrace to the server lua engine (WIP) 2024-07-14 00:22:48 +02:00
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