SpawnTestItem
spawnTestItem
IMPROVED FROM UPDATE 0.1.2
This function is available in earlier releases and has corrected or expanded behavior in G1R:MP 0.1.2 and later. The contract below describes the updated behavior.
Spawns the catalog-backed synchronized test apple near a player.
Syntax
bool spawnTestItem(int playerId [, number heightOffset])
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
playerId |
int |
yes | The connected player identifier. |
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 test item; otherwise returns false.
Examples
Spawn the fixed test apple near the invoking player and snap it to the ground:
addCommandHandler("spawntestitem", function(playerId)
if not spawnTestItem(playerId) then
outputChatBox("The item could not be spawned.", playerId)
end
end)
Notes
- Available only in server-side resource scripts.
- Each accepted call spawns exactly one apple 0.7 metres in front of the player's latest replicated position and facing direction.
- The server owns the item identity, revision, visibility, pickup validation, inventory award, and late-join state.
- This compatibility and test helper deliberately spawns only the validated apple. Use
spawnItemwhen selecting an allowlisted item key.