Scripting/Server/Events

Define any of these as a global function in a server script. All are optional. Types in the signatures: player/killer/victim are Player handles, vehicle is a Vehicle handle, other names are plain integers, floats, strings or bools.

Lifecycle and connection

Spawning, deaths and combat

Chat and commands

function onPlayerCommand(player, cmd, params)
{
    if (cmd == "give")                       // /give 5 100   -> weapon 5, 100 ammo
    {
        if (NumTok(params, " ") < 2)
            return MessagePlayer("Usage: /give <weapon> <ammo>", player);
        local weapon = GetTok(params, " ", 1).tointeger();
        local ammo = GetTok(params, " ", 2).tointeger();
        player.SetWeapon(weapon, ammo);
    }
}

Vehicles

Seat numbers: 0 is the driver, 1..8 are passengers. "Entering/Exiting" fire before the state changes; "Entered/Exited" fire after.

World

Input and sync

NPC events

Traffic events

Only fire when traffic_sync on. See the Traffic chapter for the handles.

Bot events

Categories: Server events