Skip to content

Player API

The Player API provides functions for interacting with the player character in Schedule I. This includes getting player state information, manipulating player attributes, checking the player's location, and more.

Implementation Status: Partially implemented. Basic functionality works, but some advanced features are still in development.

Available Functions

Player State

Player Movement

Player Location

Player Events

Your script can implement these event handlers to respond to player-related events:

lua
-- Called when the player is fully loaded and ready
function OnPlayerReady()
    Log("Player is now ready!")
    -- Initialize your player-dependent code here
end

-- Called when player health changes
function OnPlayerHealthChanged(newHealth)
    Log("Health changed to: " .. newHealth)
    -- React to health changes
end

-- Called when player energy changes
function OnPlayerEnergyChanged(newEnergy)
    Log("Energy changed to: " .. newEnergy)
    -- React to energy changes
end

Example Usage

lua
function OnPlayerReady()
    -- Get player state
    local playerState = GetPlayerState()
    if playerState then
        Log("Player name: " .. (playerState.playerName or "Unknown"))
        Log("Player health: " .. (playerState.health or 0) .. "/" .. (playerState.maxHealth or 100))
        Log("Player is alive: " .. tostring(playerState.isAlive or false))
        
        -- Get position from the state table
        local pos = playerState.position
        if pos then
            Log("Position: X=" .. pos.x .. ", Y=" .. pos.y .. ", Z=" .. pos.z)
        end
    end
    
    -- Get player region
    local region = GetPlayerRegion()
    Log("Player is in region: " .. (region or "Unknown"))
    
    -- Check if player has enough money
    local money = GetPlayerMoney()
    if money >= 100 then
        Log("Player has enough money to buy the item")
    else
        Log("Player needs " .. (100 - money) .. " more money")
    end
end

Explore the sections in the sidebar for detailed documentation of each function.

Released as Beta Software under the GPL-3.0 License.