BeamMP Server-Side Lua Plugins

How to create and install Lua plugins for server-side scripting on your BeamMP server.

BeamMP supports server-side Lua 5.3 plugins for custom logic, chat commands, events, and automation.

Plugin Structure

main.lua

Each folder in Resources/Server/ is a plugin. Lua files are loaded alphabetically.

Installing a Plugin

  1. Upload the plugin folder to Resources/Server/
  2. Restart the server

Key Events

Register handlers with MP.RegisterEvent():

function onPlayerJoining(id)
    MP.SendChatMessage(-1, "Welcome, player " .. id .. "!")
end

MP.RegisterEvent("onPlayerJoining", "onPlayerJoining")

Common Events

EventFires when
onInitPlugin loads
onShutdownServer shutting down
onPlayerAuth(name, role, isGuest, ids)Player authenticating (return string to deny)
onPlayerJoining(id)Player joining after mods load
onPlayerDisconnect(id)Player leaves
onChatMessage(id, name, msg)Chat message (return "" to cancel)
onVehicleSpawn(pid, vid, data)Vehicle spawned (return "" to cancel)
onVehicleEdited(pid, vid, data)Vehicle modified

Key API Functions

FunctionDescription
MP.SendChatMessage(id, msg)Send chat (-1 = broadcast)
MP.GetPlayers()Table of id → name
MP.GetPlayerCount()Current player count
MP.DropPlayer(id, reason)Kick player
MP.RemoveVehicle(pid, vid)Delete a vehicle
MP.GetPositionRaw(pid, vid)Get position/rotation/velocity
MP.TriggerClientEvent(pid, event, data)Send event to client
MP.CreateEventTimer(event, ms)Recurring timer

Live Debugging

Use the lua console command to open a live Lua interpreter for any running plugin state.

How is this guide?

40% Off — Limited TimeGet your Beammp server todayInstant setup, DDoS protection, and 24/7 support included.
Get a Server

On this page