Introduction to Lua scripting
Lua was the scripting language used in place of GSC (the game's scripting language) on the X Labs clients. This was because at the time of IW6x, there was no GSC compiler. On H1-Mod, we adapt this language from the former clients because it is easy to work with provide a API that adds additional features. Although Lua scripting is the alternative language for the game's scripting, it can still communicate with GSC just fine. Alongside that, it adds new features that help you modify the game's stock GSC scripts to make it all the better.
Writing a basic script
In this little tutorial, we are going to write a simple Lua script that will count the amount of spawns on a player and do a bold print only the first time a player spawns.
-- this callback function will run EVERY TIME a new player has connected
player.spawns = 0 -- we setup a new variable to keep count of spawns on the player entity
-- this callback function will run EVERY TIME the player has spawned
player.spawns = player.spawns + 1 -- we add 1 to this variable everytime the player spawns
print("Player " .. player.name .. " has spawned " .. player.spawns .. " times!")
-- this callback function will run when the player has spawned for the first time only.
-- this is because we use `onnotifyonce` instead on `onnotify`