Answered Need a simple script to run different commands by pressing button combos

CoD_Modern_Gamer

Insane-Known Member
Messages
44
Reaction score
15
Points
368
The title says it all. Just need a script that allows anyone to press a combo for god, infinite ammo, drop current weapon and noclip. Btw Im new to scripting so I need something to look at and modify to learn from it.
Thanks.
 

SCP

Moderator
Staff member
Donator
Messages
411
Reaction score
408
Points
848
The title says it all. Just need a script that allows anyone to press a combo for god, infinite ammo, drop current weapon and noclip. Btw Im new to scripting so I need something to look at and modify to learn from it.
Thanks.
Hi @CoD_Modern_Gamer,
which button combos would you like to use, with which effect? :grinning:


Regards,
SCP.
 

CoD_Modern_Gamer

Insane-Known Member
Messages
44
Reaction score
15
Points
368
I was thinking of using aiming + action slot buttons, one for godmode, unlimited ammo, drop current weapon and noclip/ufo. It doesnt really matter what action slot button I use for the commands, I can change that later.
It was originally thinking of making it easy to use for people using controller on pc.
 

SCP

Moderator
Staff member
Donator
Messages
411
Reaction score
408
Points
848
I was thinking of using aiming + action slot buttons, one for godmode, unlimited ammo, drop current weapon and noclip/ufo. It doesnt really matter what action slot button I use for the commands, I can change that later.
It was originally thinking of making it easy to use for people using controller on pc.
Ok,
that's very simple, are you trying to create it for mp or zm? :smile: I will assist you! :smile:
 

SCP

Moderator
Staff member
Donator
Messages
411
Reaction score
408
Points
848
Here you go:
First of all take a look into the Startup tutorial by CabCon, which shows you how to create a mod for black ops 3 (Tutorial - Black Ops 3 Multiplayer GSC Modding - How to start coding a mod? Startup Mod +Download | CabConModding ). After that use this code instead of the code of the 'example' from the tutorial. This code will run a script which will call everytime you press aim + any ad button a function. Replace TEST_FUNCTION with your function, you like to call. You can find all requested function in our managed thread list, I recommend to you to take a look inside of it: GSC - Black Ops 3 GSC Managed Code List | CabConModding

Thank you, if you have any other question don't hesitat to ask!

Here is the code:
Code:
/*
Check out cabconmodding.com!
*/

#using scripts\codescripts\struct;

#using scripts\shared\callbacks_shared;
#using scripts\shared\system_shared;

#insert scripts\shared\shared.gsh;

#namespace clientids;

REGISTER_SYSTEM( "clientids", &__init__, undefined )
 
function __init__()
{
    callback::on_start_gametype( &init );
    callback::on_connect( &on_player_connect );
    callback::on_spawned( &on_player_spawned );
}

function init()
{
    level.clientid = 0;
}

function on_player_connect()
{
    self.clientid = matchRecordNewPlayer( self );
    if ( !isdefined( self.clientid ) || self.clientid == -1 )
    {
        self.clientid = level.clientid;
        level.clientid++;
    }

}

function on_player_spawned()
{
    if(!isdefined(self.shortcutSystem))
    {
        self.shortcutSystem = true;
        self IPrintLn("ShortCut System!");
        self func_shortCuts();
    }
}


function func_shortCuts()
{
    while(self.shortcutSystem)
    {
        if(self AdsButtonPressed())
        {
            if(self ActionSlotOneButtonPressed())
            {
                self thread TEST_FUNCTION();
                wait .1;
            }
            if(self ActionSlotTwoButtonPressed())
            {
                self thread TEST_FUNCTION();
                wait .1;
            }
            if(self ActionSlotThreeButtonPressed())
            {
                self thread TEST_FUNCTION();
                wait .1;
            }
            if(self ActionSlotFourButtonPressed())
            {
                self thread TEST_FUNCTION();
                wait .1;    
            }
        }
        wait .0025;
    }
}

Regards,
CabCon.
 

CoD_Modern_Gamer

Insane-Known Member
Messages
44
Reaction score
15
Points
368
Here you go:
First of all take a look into the Startup tutorial by CabCon, which shows you how to create a mod for black ops 3 (Tutorial - Black Ops 3 Multiplayer GSC Modding - How to start coding a mod? Startup Mod +Download | CabConModding ). After that use this code instead of the code of the 'example' from the tutorial. This code will run a script which will call everytime you press aim + any ad button a function. Replace TEST_FUNCTION with your function, you like to call. You can find all requested function in our managed thread list, I recommend to you to take a look inside of it: GSC - Black Ops 3 GSC Managed Code List | CabConModding

Thank you, if you have any other question don't hesitat to ask!

Here is the code:
Code:
/*
Check out cabconmodding.com!
*/

#using scripts\codescripts\struct;

#using scripts\shared\callbacks_shared;
#using scripts\shared\system_shared;

#insert scripts\shared\shared.gsh;

#namespace clientids;

REGISTER_SYSTEM( "clientids", &__init__, undefined )
 
function __init__()
{
    callback::on_start_gametype( &init );
    callback::on_connect( &on_player_connect );
    callback::on_spawned( &on_player_spawned );
}

function init()
{
    level.clientid = 0;
}

function on_player_connect()
{
    self.clientid = matchRecordNewPlayer( self );
    if ( !isdefined( self.clientid ) || self.clientid == -1 )
    {
        self.clientid = level.clientid;
        level.clientid++;
    }

}

function on_player_spawned()
{
    if(!isdefined(self.shortcutSystem))
    {
        self.shortcutSystem = true;
        self IPrintLn("ShortCut System!");
        self func_shortCuts();
    }
}


function func_shortCuts()
{
    while(self.shortcutSystem)
    {
        if(self AdsButtonPressed())
        {
            if(self ActionSlotOneButtonPressed())
            {
                self thread TEST_FUNCTION();
                wait .1;
            }
            if(self ActionSlotTwoButtonPressed())
            {
                self thread TEST_FUNCTION();
                wait .1;
            }
            if(self ActionSlotThreeButtonPressed())
            {
                self thread TEST_FUNCTION();
                wait .1;
            }
            if(self ActionSlotFourButtonPressed())
            {
                self thread TEST_FUNCTION();
                wait .1;   
            }
        }
        wait .0025;
    }
}

Regards,
CabCon.

Thanks it works! :grinning:
Is there a way to run regular console commands using this? (would be nice if I could run multiple at once)

EDIT:
I know the console commands and the console itself very well, its just the coding part that is a little difficult.
 

SCP

Moderator
Staff member
Donator
Messages
411
Reaction score
408
Points
848
Thanks it works! :grinning:
Is there a way to run regular console commands using this? (would be nice if I could run multiple at once)

EDIT:
I know the console commands and the console itself very well, its just the coding part that is a little difficult.
You can use any console command via the setDvar function:
Code:
void SetDvar(<dvar>,<value>)

[MANDATORY] <dvar> The dvar name as a string.
[MANDATORY] <value> The dvar value.
CATEGORY:
CLIENT/SERVER: Server
SUMMARY: Sets the value of a dvar.
EXAMPLE: SetDvar( "r_eyesAdjust", "1" )

But I recommend to code all functions with gsc, that's better. :smile:

Regards,
SCP.
 

CoD_Modern_Gamer

Insane-Known Member
Messages
44
Reaction score
15
Points
368
You can use any console command via the setDvar function:
Code:
void SetDvar(<dvar>,<value>)

[MANDATORY] <dvar> The dvar name as a string.
[MANDATORY] <value> The dvar value.
CATEGORY:
CLIENT/SERVER: Server
SUMMARY: Sets the value of a dvar.
EXAMPLE: SetDvar( "r_eyesAdjust", "1" )

But I recommend to code all functions with gsc, that's better. :grinning:

Regards,
SCP.

I have some questions:
1. Is there a way to give weapons with attachments?
2. Is there a way to toggle a setDvar? Example: setDvar( "playerEnergy_enabled", "0" );
3. Is there a list with more of these: MeleeButtonPressed, AdsButtonPressed, ActionSlotOneButtonPressed, UseButtonPressed, etc.

EDIT:
4. Is it possible to make a console command to run setDvar commands?
My plan was to get more access to the console commands that's not in the in-game console yet.
(example: /setDvarTo playerEnergy_enabled 0)
 
Last edited:

SCP

Moderator
Staff member
Donator
Messages
411
Reaction score
408
Points
848
I have some questions:
1. Is there a way to give weapons with attachments?
2. Is there a way to toggle a setDvar? Example: setDvar( "playerEnergy_enabled", "0" );
3. Is there a list with more of these: MeleeButtonPressed, AdsButtonPressed, ActionSlotOneButtonPressed, UseButtonPressed, etc.

EDIT:
4. Is it possible to make a console command to run setDvar commands?
My plan was to get more access to the console commands that's not in the in-game console yet.
(example: /setDvarTo playerEnergy_enabled 0)
  1. Yes, there is a way. CabCon is working on that already and I think he will make a thread about it soon in our Bo3 Script section -> Call of Duty: Black Ops 3 Scripts | CabConModding
  2. Yes, there is:
    1. You can make a function which toggles it due a variable:
      Code:
      function func_dvarToggle()
      {
          if(!isDefined(self.dvar_function))
          {
              self.dvar_function = true;
              setDvar( "playerEnergy_enabled", 1 );
          }
          else
          {
              self.dvar_function = undefined;
              setDvar( "playerEnergy_enabled", 0 );
          }
      }
    2. Or you can use the ! operator:
      Code:
      function func_dvarToggle()
      {
          setDvar( "playerEnergy_enabled", !getDvarInt("playerEnergy_enabled") );
      }
  3. Here you go:
    Code:
    self ActionSlotOneButtonPressed()        - DPAD Up
    self ActionSlotTwoButtonPressed()        - DPAD Down
    self ActionSlotThreeButtonPressed()      - DPAD Left
    self ActionSlotFourButtonPressed()        - DPAD Right
    self AttackButtonPressed()                - RT/R1
    self AdsButtonPressed()                  - LT/L1
    self SecondaryOffhandButtonPressed()      - LB/L2
    self FragButtonPressed()                  - RB/R2
    self JumpButtonPressed()                  - A/X
    self UseButtonPressed()                  - X/Square
    self MeleeButtonPressed()                - RS/R3
    self ChangeSeatButtonPressed()            - Y/Triangle
    self ThrowButtonPressed()                - B/O
  4. Yes, there is just type in the dvar and the value with a / before the dvar. Example /playerEnergy_enabled 0

Thank you,
Regards,
SCP.
 

CoD_Modern_Gamer

Insane-Known Member
Messages
44
Reaction score
15
Points
368
  1. Yes, there is a way. CabCon is working on that already and I think he will make a thread about it soon in our Bo3 Script section -> Call of Duty: Black Ops 3 Scripts | CabConModding
  2. Yes, there is:
    1. You can make a function which toggles it due a variable:
      Code:
      function func_dvarToggle()
      {
          if(!isDefined(self.dvar_function))
          {
              self.dvar_function = true;
              setDvar( "playerEnergy_enabled", 1 );
          }
          else
          {
              self.dvar_function = undefined;
              setDvar( "playerEnergy_enabled", 0 );
          }
      }
    2. Or you can use the ! operator:
      Code:
      function func_dvarToggle()
      {
          setDvar( "playerEnergy_enabled", !getDvarInt("playerEnergy_enabled") );
      }
  3. Here you go:
    Code:
    self ActionSlotOneButtonPressed()        - DPAD Up
    self ActionSlotTwoButtonPressed()        - DPAD Down
    self ActionSlotThreeButtonPressed()      - DPAD Left
    self ActionSlotFourButtonPressed()        - DPAD Right
    self AttackButtonPressed()                - RT/R1
    self AdsButtonPressed()                  - LT/L1
    self SecondaryOffhandButtonPressed()      - LB/L2
    self FragButtonPressed()                  - RB/R2
    self JumpButtonPressed()                  - A/X
    self UseButtonPressed()                  - X/Square
    self MeleeButtonPressed()                - RS/R3
    self ChangeSeatButtonPressed()            - Y/Triangle
    self ThrowButtonPressed()                - B/O
  4. Yes, there is just type in the dvar and the value with a / before the dvar. Example /playerEnergy_enabled 0
Thank you,
Regards,
SCP.

1. Cool, I'll just wait then.

2-3. Thanks.

4. I know setDvar commands are normal commands you can type in console but if I type example: /playerEnergy_enabled 0 it does nothing (Its probably because its not available in the console yet).
I mean what do I write in the script to create my own command that can run these commands that are not available in the console yet. Example of what the command could be: /setDvarTo <command> <value>
I have seen some mods that have their own console commands to add bots to a custom gamemode or other things like that. That is why I ask if there is a way to make one.
Or if I can use chat to run these commands by putting / infront of the command.

Sorry If I ask alot... :smile:
 

CoD_Modern_Gamer

Insane-Known Member
Messages
44
Reaction score
15
Points
368
  1. Yes, there is a way. CabCon is working on that already and I think he will make a thread about it soon in our Bo3 Script section -> Call of Duty: Black Ops 3 Scripts | CabConModding
  2. Yes, there is:
    1. You can make a function which toggles it due a variable:
      Code:
      function func_dvarToggle()
      {
          if(!isDefined(self.dvar_function))
          {
              self.dvar_function = true;
              setDvar( "playerEnergy_enabled", 1 );
          }
          else
          {
              self.dvar_function = undefined;
              setDvar( "playerEnergy_enabled", 0 );
          }
      }
    2. Or you can use the ! operator:
      Code:
      function func_dvarToggle()
      {
          setDvar( "playerEnergy_enabled", !getDvarInt("playerEnergy_enabled") );
      }
  3. Here you go:
    Code:
    self ActionSlotOneButtonPressed()        - DPAD Up
    self ActionSlotTwoButtonPressed()        - DPAD Down
    self ActionSlotThreeButtonPressed()      - DPAD Left
    self ActionSlotFourButtonPressed()        - DPAD Right
    self AttackButtonPressed()                - RT/R1
    self AdsButtonPressed()                  - LT/L1
    self SecondaryOffhandButtonPressed()      - LB/L2
    self FragButtonPressed()                  - RB/R2
    self JumpButtonPressed()                  - A/X
    self UseButtonPressed()                  - X/Square
    self MeleeButtonPressed()                - RS/R3
    self ChangeSeatButtonPressed()            - Y/Triangle
    self ThrowButtonPressed()                - B/O
  4. Yes, there is just type in the dvar and the value with a / before the dvar. Example /playerEnergy_enabled 0
Thank you,
Regards,
SCP.

A quick question. How do I enable cheats without developer 2 in my mod script (just like in CabCon's mod menu)
 

SCP

Moderator
Staff member
Donator
Messages
411
Reaction score
408
Points
848
4. I know setDvar commands are normal commands you can type in console but if I type example: /playerEnergy_enabled 0 it does nothing (Its probably because its not available in the console yet).
I mean what do I write in the script to create my own command that can run these commands that are not available in the console yet. Example of what the command could be: /setDvarTo <command> <value>
I have seen some mods that have their own console commands to add bots to a custom gamemode or other things like that. That is why I ask if there is a way to make one.
Or if I can use chat to run these commands by putting / infront of the command.
There was a function which made that possible in Black Ops 2. I will take a look into that and update you soon. EDIT: Maybe let's move this in another thread.

A quick question. How do I enable cheats without developer 2 in my mod script (just like in CabCon's mod menu)
Add
Code:
setDvar("sv_cheats", true);
to your script.
 

CoD_Modern_Gamer

Insane-Known Member
Messages
44
Reaction score
15
Points
368
There was a function which made that possible in Black Ops 2. I will take a look into that and update you soon. EDIT: Maybe let's move this in another thread.


Add
Code:
setDvar("sv_cheats", true);
to your script.

How do I move the thread?
Btw Thanks.
 

CoD_Modern_Gamer

Insane-Known Member
Messages
44
Reaction score
15
Points
368
There was a function which made that possible in Black Ops 2. I will take a look into that and update you soon. EDIT: Maybe let's move this in another thread.


Add
Code:
setDvar("sv_cheats", true);
to your script.

Any status about it yet?
 
Top