Server-side
The Lua API of scripts running on the game server - players, server-side NPCs, chat, commands and timers.
Server-side scripts run on the game server and handle what concerns all players at once: players joining and leaving, chat, commands, timers - and NPCs created by the server.
Character ids
On the server, characters are not objects but ids (pid):
| Id | Character |
|---|---|
0 to gmp.getMaxSlots() - 1 | a player - one id per player slot of the server |
gmp.getMaxSlots() and above | a server-side NPC created with gmp.createNpc |
Functions with Player in the name work for both: gmp.setPlayerHealth(pid, 100) heals a player
as well as a server-side NPC. Functions with Npc in the name - the NPC's AI and routine actions -
work only for server-side NPCs.
local gmp = require("gmp")
local E = gmp.enum
gmp.on("playerJoin", function(pid)
gmp.sendMessageToAll(gmp.getPlayerName(pid) .. " entered the Colony")
gmp.setPlayerPosition(pid, 2600, -350, 80)
end)
-- a guard that attacks every player who comes close
local guard = gmp.createNpc("CharacterDefinition_Human_OC_GRD_Jackal_201", 1200, -350, 80, 90)
gmp.setPlayerName(guard, "Jackal")
gmp.setPlayerMaxHealth(guard, 500)
gmp.setPlayerHealth(guard, 500)
gmp.setNpcInteractable(guard, false)
gmp.on("playerJoin", function(pid)
gmp.setNpcRelation(guard, pid, E.Relation.Hostile)
end)Server in development
The server is being developed together with the mod; this API describes what its scripts will be able to do.
gmp
Character ids, events, player slots, chat, commands and timers.
Players
Functions for players and server-side NPCs by id: name, attributes, items, skills, position, combat and state.
NPCs
Server-side NPCs: creation, removal, AI and routine actions.
Events
playerJoin, playerLeave, playerChat, playerDead, playerHit, playerRespawn.
Common types and constants are shared with the client side.
