evasivedocs
CS2 scriptingLua 5.4.9 · 25 guides · 292 API entries
Start here

Permissions

Six switches in Scripts > Security decide what scripts may touch. Only one is on when you install evasive. The others stay off until you turn them on.

The switches are global. They are never saved in a config, so a config someone shares with you cannot turn them on. A change is saved at once and every loaded script it concerns reloads with it. A script that cannot run without a switch you just turned off is stopped. A suspended script picks up the change the next time you load it.

The six switches

Switch Default What it gives scripts
Allow game scripting on game, entities, world and combat: players, the local player, the bomb, grenades, the camera, map traces and what the built in aim and trigger are doing. Also draw.world_line, draw.world_circle, draw.world_text and the bone, hitgroup and weapon_type tables. Read only: nothing is ever written to the game.
Allow internet connections off http. Up to 4 requests at once per script, a 10 second timeout, 2 MiB per response, http and https only, public addresses only.
Allow scripts to edit cfg files off config: read and change evasive's own settings and switch profiles.
Allow insecure FFI off The full io, os and debug libraries. A script with this can read and write any of your files and start programs. Native modules are never allowed.
Allow custom shaders off scene and Player:set_material: chams materials with the script's own HLSL pixel shader, run on your GPU. A slow shader is switched off by itself.
Allow scripts to aim, shoot and press keys off aim, attack, keys, act and the key presses in input. Each version of each script also needs your approval.

Keep Allow insecure FFI off unless you wrote the script yourself or read every line of it. While it is on, action scripts are stopped and cannot load.

Always available

These work with every switch off: events, draw (apart from the three world functions), ui, reading keys and the mouse with input, time, log, json, color, math, storage, files, media, script, vec2, vec3, vk and print.

storage and files only reach the script's own data folder, so they need no switch.

Check before you use it

A namespace behind a switch is not installed while the switch is off. It is nil, and calling into it raises an error. Check it first:

Lua
events.on("paint", function()
    if not game then
        draw.text(20, 20, "turn on Allow game scripting", color(255, 200, 60))
        return
    end
    if game.connected() then
        draw.text(20, 20, "map: " .. game.map(), color(255, 255, 255))
    end
end)

For a script that makes no sense without its switch, stop at the top with a clear message:

Lua
if not http then error("turn on Allow internet connections in Scripts > Security", 0) end

The 0 tells error not to add a line number, so the console shows just your sentence.

Action approvals

A script that aims, shoots or presses keys has to say so in its header:

Lua
-- @name Jump helper
-- @permissions act

Turning on Allow scripts to aim, shoot and press keys is not enough by itself. Every version of such a script needs your approval too.

  • Every file in the scripts folder that has this line, and that you have not decided on yet, shows up under Action approvals on the Scripts page with its SHA-256. The box lists only versions waiting for a decision. With none waiting it reads "No versions waiting for approval".
  • Allow this version approves that exact file and reloads the script if it is loaded. Until then act, aim, attack and keys are nil, so test if act then ... end.
  • Any change to the file revokes the approval, a Workshop update included. A running script stops with action approval revoked, and the new version waits for approval again.
  • Deny is remembered. That version is not offered again, also after a restart, until the file changes.
  • Revoke action approval in Console > Action activity takes the approval back and lets go of any keys the script holds.
  • Stop script actions in Console > Script actions lets go of every key scripts hold and blocks them until you press Reset script panic.

Aim, attack and keys covers how to write such a script.