SpawnItem

From Wiki G1R-MP G1 Remake Multiplayer
Revision as of 17:32, 2 September 2026 by QCherry (talk | contribs) (Document Lua functions planned for G1R:MP update 0.1.2)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

spawnItem

COMING IN UPDATE 0.1.2
This function is documented in advance and is not yet available in the current public release.

Spawns an allowlisted synchronized pickup near a player.

Syntax

bool spawnItem(int playerId, string itemKey [, number heightOffset])

Parameters

Name Type Required Description
playerId int yes The connected player identifier.
itemKey string yes A verified public world-item key or inventory key from the server catalog allowlist, for example apple or itfo_apple.
heightOffset number no Optional finite vertical offset in metres from -100 through 100. Values outside this range are rejected. Omit it to request ground snapping; an explicit 0 keeps the player's snapshot height without ground snapping.

Returns

Returns true after the server accepts and creates the item; otherwise returns false.

Examples

Example 1

Spawn an allowlisted apple near the invoking player:

addCommandHandler("spawnitem", function(playerId)
    if not spawnItem(playerId, "itfo_apple") then
        outputChatBox("The item could not be spawned.", playerId)
    end
end)

Example 2

Spawn other verified food, weapon, and rune entries:

spawnItem(playerId, "ItFo_Loaf")
spawnItem(playerId, "ItMw_1H_Axe_01")
spawnItem(playerId, "ItAr_Rune_FireBolt")

Notes

  • Available only in server-side resource scripts.
  • Each accepted call spawns exactly one item 0.7 metres in front of the player's latest replicated position and facing direction.
  • The update 0.1.2 catalog contains 681 structurally verified world-item entries. Item codes are case-insensitive; the server canonicalizes every accepted value before replication.
  • The Gothic Remake item-code reference is useful when looking up candidate codes. A code is spawnable only when it also exists in the current server catalog; unsupported codes return false.
  • The server owns the item identity, revision, visibility, pickup validation, inventory award, and late-join state.
  • Only entries mapped by the verified world-item catalog may be spawned; arbitrary asset names and paths are rejected.