Some of you folks wondered how to do Vscript.
Vscript is actually very easy, it's like c++ except you don't get any help about what a function does except by testing it, no inputs what to call it with and almost zero information why something doesn't work.
So here we go.
Create a .nut file and place it in D:\Games\Steam\SteamApps\common\Counter-Strike Global Offensive\csgo\scripts\vscripts\insert_fancy_name_here\name_of_script.nut
Create some code for it! Here's mine which will change the model of everyone. Note that you need to have the models placed somewhere in your map, or they will not become precached and the game will cry (crash).
- Code: Select all
function startGame()
{
local ply = null;
while (Entities.FindByModel(ply, "models/player/tm_phoenix.mdl") != null)
{
ply = Entities.FindByModel(ply, "models/player/tm_phoenix.mdl");
//printl("A player with the terrorist model was found!");
ply2.SetModel("models/props_docks/dockpole01a.mdl");
}
local ply2 = null;
while (Entities.FindByModel(ply2, "models/player/ctm_st6.mdl") != null)
{
ply2 = Entities.FindByModel(ply2, "models/player/ctm_st6.mdl");
printl("A player with the police model was found!");
ply2.SetModel("models/chicken/chicken.mdl");
}
}
startGame();
Yes, you need to use the Entities.FindByModel function because you can't search for players.
Now, make a map, draw it with all the colours of the sun and then place a logic_script name it something fancy and then click on
Entity Scripts and add your script.
On Outputs, add a
OnUser1 targeting the script with the input
RunScriptFile with a
parameter override of insert_fancy_name/insert_script_name_here.nut
Now whenever you want your function, just call the script with a
fireUser1. So if you want more functions, just create more .nut files.
Here's a small shitty wait function I made.
- Code: Select all
function awesomeTimer()
{
local time = Time();
local time2 = Time() + 50000;
printl("time: " + time);
while (time < time2)
{
time = time + 1;
}
}
I've yet to been able to get the function
RunScriptCode so for now I'm sticking with
RunScriptFile.
Here are some useful links:
CS GO FunctionsL4d2 ExamplesL4d2 Mutations ExamplesAlliedModders Forum