Repository navigation
LuaAPI Events
itvnnnd87 edited this page Oct 24, 2026
·
3 revisions
aIndex is the player index; every Player.* function takes it. All events run on the GameServer main thread.
Write your code inside the functions below (System\Callbacks.lua, CallbacksDB.lua, Timers.lua), after the existing BridgeFunction_... line, which runs the modules. Functions you do not need can be deleted.
| Function | Called when |
|---|---|
onGameServerStart() |
Scripts have just been loaded (startup or reload). |
onScriptUnload() |
Before a reload or a server shutdown. |
onPlayerLogin(aIndex) |
A character enters the game (once, after entering is complete). |
onPlayerLogout(aIndex) |
A character leaves the game (exit or back to character select). Data can be read and messages sent, but nothing can be changed. |
onPlayerDie(aIndex, killerIndex) |
A character dies. killerIndex = -1 if unknown. |
onLuaCommand(aIndex, code, name, arg) |
A chat command from LuaCommands.xml (below). Return 1 if handled. |
onDBQueryResult(label, param, result) |
Result of DB.Query (Database). Return 1 to run the query again. |
onTimerProcessSecond() |
Every second. |
onTimerProcessMinute() |
When a new minute starts. |
onTimerProcessHour() |
When a new hour starts. |
onTimerProcessDayChange() |
When a new day starts (00:00). |
function onPlayerLogin(aIndex)
BridgeFunction_OnCharacterEntry(aIndex) -- keep this line first (attached modules)
Message.Send(aIndex, 1, "Welcome " .. Player.GetName(aIndex))
endFile Data\Commands\LuaCommands.xml:
<CommandList>
<CommandSystem Type="16">
<Command ID="2000" name="myitems" Authority="0"/>
</CommandSystem>
</CommandList>| Attribute | Meaning |
|---|---|
ID |
Identifier, passed to the script as code. |
name |
What the player types: /myitems (or .myitems). Not case sensitive. Any language can be used (save the file as UTF-8). |
Authority |
0 = everyone, 2 = GM only (after .auth). |
If a command has the same name as a built-in server command, the server command wins.
Reading the arguments after the command name (positions start at 0):
-- /myitems 5 abc -> arg = "5 abc"
Util.ArgNumber(arg, 0) -- 5
Util.ArgString(arg, 1) -- "abc"function onLuaCommand(aIndex, code, name, arg)
if BridgeFunction_OnCommandManager(aIndex, 16, code, arg) == 1 then return 1 end
if code == 2000 then
Message.Send(aIndex, 1, "You typed /" .. name .. " " .. arg)
return 1
end
return 0
endNext: Function reference