Modme Forums

How to add debug (on/off)

Game Modding | Call of Duty: Black Ops 3 | Scripting


ModmeBot:

Thread By: mathfag
TUTORIAL

In this 2 part tutorial I'll show you how to add a debug which you can turn on and off.

Part 1 will be the main part and part 2 will be the optional in game trigger.
The code was taken from NSZ's brutus and slightly modified.


PART 1:

As always, initiate the function and add the variable

level.SDFMdebug = false;   //replace SDFMdebug with your custom variable,  just remember it for later. MAKE SURE IT'S ABOVE THE FUNCTION INITIATION (level thread SDFM_debug)
level thread SDFM_Debug(); //function initiation


The function:
function SDFM_Debug( string )  //remember the function name because that's what you will use instead of IPrintLnBold (choose your own)

{
    if( isDefined(level.SDFMdebug) && level.SDFMdebug ) //instead of SDFMdebug you can use your own variable from before
        iprintlnbold( "^6Debug:^7 "+string ); //this is what it will print out
}


Now to use this you need to type
SDFM_debug("insert text here");  //function name (SDFM_debug)

instead of
IPrintLnBold("text");
and you can turn it on with "true" and off with "false" in the variable that we declared in the beginning (I declared it as off)

You can copy paste this script into other .gsc files but DON'T DECLARE THE VARIABLE AGAIN because it already globally turns the function on and off.



PART 2 (optional):

To add an in game trigger go into radiant and add a trigger_use or multiple or whichever you want. I'm using trigger use.
I'll call mine "debug_trig"

Now for the script part:

Init the function
level thread ask_debug();

and the function

function ask_debug(player)
{
    trig = GetEnt("debug_trig", "targetname");
 
    trig SetCursorHint("HINT_NOICON");
 
    while(1)
    {
        if(level.SDFMdebug == false) //level.SDFMdebug is the variable name. Change it if you need to
        {
        trig SetHintString("Press ^3[{+activate}]^7 to enable debug");
        }

        else if(level.SDFMdebug == true)  //level.SDFMdebug is the variable name. Change it if you need to
        {
        trig SetHintString("Press ^3[{+activate}]^7 to disable debug");    
        }


        trig waittill("trigger", player);
        
        if(level.SDFMdebug == false)  //level.SDFMdebug is the variable name. Change it if you need to
            {
            level.SDFMdebug = true;  //level.SDFMdebug is the variable name. Change it if you need to
            IPrintLnBold("Debug enabled");
            }

        else if(level.SDFMdebug == true)  //level.SDFMdebug is the variable name. Change it if you need to
            {
            level.SDFMdebug = false;  //level.SDFMdebug is the variable name. Change it if you need to
            IPrintLnBold("Debug disabled");
            }

        wait(0.5);  //do not put break; here
        
    }
 
}


So that's pretty much it. Credit to NSZ


For the people that don't understand what this does:


ModmeBot:

Reply By: Ahmed02354

mathfag
TUTORIAL In this 2 part tutorial I'll show you how to add a debug which you can turn on and off. Part 1 will be the main part and part 2 will be the optional in game trigger. The code was taken from NSZ's brutus and slightly modified. PART 1: As always, initiate the function and add the variable level.SDFMdebug = false; //replace SDFMdebug with your custom variable, just remember it for later. MAKE SURE IT'S ABOVE THE FUNCTION INITIATION (level thread SDFM_debug) level thread SDFM_Debug(); //function initiation The function: function SDFM_Debug( string ) //remember the function name because that's what you will use instead of IPrintLnBold (choose your own) { if( isDefined(level.SDFMdebug) && level.SDFMdebug ) //instead of SDFMdebug you can use your own variable from before iprintlnbold( "^6Debug:^7 "+string ); //this is what it will print out } Now to use this you need to type SDFM_debug("insert text here"); //function name (SDFM_debug) instead of IPrintLnBold("text"); and you can turn it on with "true" and off with "false" in the variable that we declared in the beginning (I declared it as off) You can copy paste this script into other .gsc files but DON'T DECLARE THE VARIABLE AGAIN because it already globally turns the function on and off. PART 2 (optional): To add an in game trigger go into radiant and add a trigger_use or multiple or whichever you want. I'm using trigger use. I'll call mine "debug_trig" Now for the script part: Init the function level thread ask_debug(); and the function function ask_debug(player) { trig = GetEnt("debug_trig", "targetname"); trig SetCursorHint("HINT_NOICON"); while(1) { if(level.SDFMdebug == false) //level.SDFMdebug is the variable name. Change it if you need to { trig SetHintString("Press ^3[{+activate}]^7 to enable debug"); } else if(level.SDFMdebug == true) //level.SDFMdebug is the variable name. Change it if you need to { trig SetHintString("Press ^3[{+activate}]^7 to disable debug"); } trig waittill("trigger", player); if(level.SDFMdebug == false) //level.SDFMdebug is the variable name. Change it if you need to { level.SDFMdebug = true; //level.SDFMdebug is the variable name. Change it if you need to IPrintLnBold("Debug enabled"); } else if(level.SDFMdebug == true) //level.SDFMdebug is the variable name. Change it if you need to { level.SDFMdebug = false; //level.SDFMdebug is the variable name. Change it if you need to IPrintLnBold("Debug disabled"); } wait(0.5); //do not put break; here } } So that's pretty much it. Credit to NSZ



what does this do? is this for an easteregg?


ModmeBot:

Reply By: easyskanka
No, this is used for testing purposes