Skip to content

Creating new effects in VScript

Mikusch edited this page Feb 5, 2023 · 6 revisions

The VScript API is very similar to the SourcePawn one, but it only has 3 callbacks: OnStart, Update, and OnEnd. The return values of these functions are completely ignored, so it is not possible to programmatically halt an effect.

It also not needed to prefix each callback with the effect name, because all functions are put into their own scope. The name of this scope can be accessed using the Chaos_EffectName variable.

"my_effect"
{
    "name"          "#Chaos_Effect_MyEffect"
    "duration"      "60"
    "script_file"   "myeffect"
}

myeffect.nut:

function ChaosEffect_OnStart()
{
    // Called once when the effect starts
}

function ChaosEffect_Update()
{
    // Called every frame
}

function ChaosEffect_OnEnd()
{
    // Called once when the effect ends
}

function Chaos_OnGameEvent_player_spawn(params)
{
    local player = GetPlayerFromUserID(params.userid)
    if (player == null)
        return

    // Handle player_spawn event here
}

Chaos_CollectEventCallbacks(this)

Chaos offers a chaos_util.nut file that can be included.

Clone this wiki locally