Skip to content
Gothic MultiplayerMultiplayer
Gothic MP Wiki

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):

IdCharacter
0 to gmp.getMaxSlots() - 1a player - one id per player slot of the server
gmp.getMaxSlots() and abovea 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.

server/main.lua
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.

Common types and constants are shared with the client side.

On this page