CS Jailbreak Hammer Freddy FazTutorials Part 3

mouse pouch

Fazbear
=(eG)=

Introduction ✰

Hello Friends, It is I, Freddy Fazbear back for another hammer editor tutorial!

Today we will be covering how to initialize your very own game_ui inside of a vscript!
A game_ui can be used to track certain player key inputs or movement inputs! Such as left or right click!

For what reason you say? So we can save on entities in hammer editor and only need game_ui's when we need them of course, plus this opens opportunities to have it so we can have up to 64 players at once using a game_ui with the same properties without needing to copy and paste! (However we will not be covering that in this tutorial only for 1 player this time)

This tutorial will only cover the basics though! So it is up to you friends, to come up with creative ideas!



Tutorial ✰

--------------------------

First as discussed last part place your logic_script on the floor of your wonderful map!

Then we are going to make a new vscript in our csgo/scripts/vscripts file path! As for me I will call it pizza.nut as we all love eating pizza here at the Mega Pizzaplex!


Then as discussed last time I will define a function called UI()

C++:
function UI() {
    
}

Next I will want to add another function as an output for the game_ui to run in this case we will call it simply Pizza()

C++:
function Pizza() {
    printl("pizza") //will print pizza to the console
}


Now superstars, we go back to our UI() function as we will now make the game_ui by using the vscript function Entities.CreateByClassname

C++:
function UI() {
    ui <- Entities.CreateByClassname( "game_ui" )
    ui.ValidateScriptScope() //creates the ui's scope in the script
    local scope = ui.GetScriptScope() //we get it's "scope"
    ui.__KeyValueFromInt( "spawnflags", 64 ) //hides weapons (you can learn more about these by using smartedit and changing the flags on a [B]game_uI[/B] in hammer itself)
    ui.__KeyValueFromString( "FieldOfView", "-1.0" ) //just do this friends!
}


Now you my friend have made your very own game_ui in hammer editor without even needing to place an entity! But we want to run functions through it right?

So let's say our player really likes telling his friends how much he loves pizza through the console. And he wants to do this by pressing LeftClick
By using the ConnectOutput function of vscript we can do this

C++:
function UI() {
    ui <- Entities.CreateByClassname( "game_ui" )
    ui.ValidateScriptScope()
    local scope = ui.GetScriptScope()
    //printl(ui.GetOrigin())
    ui.__KeyValueFromInt( "spawnflags", 64 )
    ui.__KeyValueFromString( "FieldOfView", "-1.0" )

    scope.Pizza <- Pizza //add the function to our game_ui's scope
    ui.ConnectOutput( "PressedAttack", "Pizza") //connect a function with an output of the game_ui
    

}

Hooray! We've connected the outputs! Now all we need to use the EntFireByHandle() function we looked at in the last tutorial to activate the game_ui! Lets also add a boolean for a later part of the tutorial and also call the activator a variable! (in this case player)

C++:
thank <- false;
player <- null;

function UI() {
    ui <- Entities.CreateByClassname( "game_ui" )
    ui.ValidateScriptScope()
    local scope = ui.GetScriptScope()
    //printl(ui.GetOrigin())
    ui.__KeyValueFromInt( "spawnflags", 64 )
    ui.__KeyValueFromString( "FieldOfView", "-1.0" )

    scope.Pizza <- Pizza //add the function to our game_ui's scope
    ui.ConnectOutput( "PressedAttack", "Pizza") //connect a function with an output of the game_ui

    EntFireByHandle(ui, "Activate", "", 0.1, activator, activator)//activates the game_ui for the player to access

    thank <- true;
    player <- activator;

}


Now superstars, you've made it to the final stretch.

Well What if our player is dead, don't we want to disable them from using the game_ui? Well yes of course! But there is something SCARY about game_ui's.

If we run the Deactivate output on a player who is left the server.
The entire server will.... fatally crash!

So we need to be careful!
In this case we will use the Think() function described before to Deactivate the game_ui on the player's death as long as they are in the server.

(Put "Think" in the "Script Think Function" keyvalue/section of your logic_script entity!~)

Here's my think function in action!

C++:
function Think() {
    if (thank == false) return; //don't think unless we have this boolean set to true

    if (ui) { //if the ui exists

        if (player == null || !player.IsValid()) return; //stop the function if the player has left the server or is null

        if (player.GetHealth() < 0) { //if the player has less then zero health
            EntFireByHandle(ui, "Deactivate", "", 0.0, player, player) //deactivates the game_ui!
            player <- null; //set player back to null
            thank <- false; //stop thinking
            EntFireByHandle(ui, "Kill", "", 0.5, null, null) //kill the game_ui
            ui <- null; //reset the ui variable to null
        }
    }
}

Now you've made your very own game_ui just using vscript! Way to go superstar! I knew you could do it!







(Disclaimer: Freddy Fazbear is not responsible for any issues you have as he is a chemistry student)
 
Last edited:
Wow! I can't wait to use this information on my next CS:GO jailbreak map! Thank you Mr. Fazbear <3
 
Back
Top