UGX-Mods

Call of Duty: Black Ops 3 => Help Desk => Scripting => Topic started by: Chadric273 on August 20, 2019, 07:19:37 pm

Title: How to make a trigger temporarily unavailable after pressing it?
Post by: Chadric273 on August 20, 2019, 07:19:37 pm
Hey guys! I'm sure this is a simple thing to script, but I am lost as how to do it. How would one script it so that when I press "F" on a trigger, it will temporarily be unavailable to use until the script for that trigger has run? Example:

I press "F" on a trigger and it turns on a trap. While the trap is running I want the trigger to be unavailable and to have it give no indications of being able to press "F" (it will no longer say press F for blah blah, instead it will saying nothing) until the trap has finished running. Once the trap has finished running I then want the trigger to be able to be used again and to say "Press F to use".

I know how to change the hint icon for the trigger, but what I am mostly wondering is how to make the trigger temporarily unavailable. Any help would be much appreciated!
Title: Re: How to make a trigger temporarily unavailable after pressing it?
Post by: gympie6 on August 20, 2019, 09:10:21 pm
Hey guys! I'm sure this is a simple thing to script, but I am lost as how to do it. How would one script it so that when I press "F" on a trigger, it will temporarily be unavailable to use until the script for that trigger has run? Example:

I press "F" on a trigger and it turns on a trap. While the trap is running I want the trigger to be unavailable and to have it give no indications of being able to press "F" (it will no longer say press F for blah blah, instead it will saying nothing) until the trap has finished running. Once the trap has finished running I then want the trigger to be able to be used again and to say "Press F to use".

I know how to change the hint icon for the trigger, but what I am mostly wondering is how to make the trigger temporarily unavailable. Any help would be much appreciated!
Use this:
Code Snippet
Plaintext
self disable_trigger();

wait 15; // counter

self enable_trigger();
Title: Re: How to make a trigger temporarily unavailable after pressing it?
Post by: Chadric273 on August 20, 2019, 09:27:27 pm
Use this:
Code Snippet
Plaintext
self disable_trigger();

wait 15; // counter

self enable_trigger();
 Thanks! I really appreciate you helping me out! Just curious, what does"self" exactly do in terms of scripting? I've seen it used before, but I don't fully understand how it works.
Title: Re: How to make a trigger temporarily unavailable after pressing it?
Post by: gympie6 on August 21, 2019, 04:18:21 am
Thanks! I really appreciate you helping me out! Just curious, what does"self" exactly do in terms of scripting? I've seen it used before, but I don't fully understand how it works.
The person executing that task.
It could be a player, ai, trigger, model ect..

Cod likes to work with who does what?
Person1 wants to push a button. (player)
Person2 (the trigger) wants to be turned off for 15 seconds.
Person3 likes to walk a path.(ai)

You can also see "self" as "this" but "this" is the owner of the class and "self" is the owner of the method.
 "self" is the person running the method like for example a boss in a restaurant.

I see this is a bo3 question instead of waw, maybe it's just the same or it has another function name. I think you will find something similar in the perk script.
Title: Re: How to make a trigger temporarily unavailable after pressing it?
Post by: BluntStuffy on August 21, 2019, 11:01:59 pm
It's the same as WaW, self is the variable that call's or thread's that funtion:
For example

Code Snippet
Plaintext
init()
{
level start_mission();
}

start_mission()
{
self thread episode_1(); // in this case 'self' is the level variable, that called it in the previous function
}
or
Code Snippet
Plaintext
trigger_start()
{
trig = getent( "door_trigger", "targetname" );

trig waittill( "trigger", player );

player thread open_door();
}

open_door()
{
self iprintln( "you have opened a secret door!" ); // now 'self' is the player from the previous funtion, again 'the one' that called this function
}
Title: Re: How to make a trigger temporarily unavailable after pressing it?
Post by: gympie6 on August 22, 2019, 05:49:30 am
The person "Level" in this case is a static person. You can call him in every script and use his properties to do things.
Title: Re: How to make a trigger temporarily unavailable after pressing it?
Post by: BluntStuffy on August 22, 2019, 07:36:42 pm
That's true, but the point is that 'self' can be anything, it's simply the variable/entity that called that function
Title: Re: How to make a trigger temporarily unavailable after pressing it?
Post by: Chadric273 on August 24, 2019, 09:20:00 pm
That's true, but the point is that 'self' can be anything, it's simply the variable/entity that called that function
 Hey guys! Really appreciate you guys clarifying that for me. It makes a lot more sense now. If you don’t mine me bothering you with one more question, when is it best to use “level”, “player”, or just threading the next function without anything in front of “thread blah blah blah”?
Title: Re: How to make a trigger temporarily unavailable after pressing it?
Post by: gympie6 on August 24, 2019, 11:18:09 pm
Hey guys! Really appreciate you guys clarifying that for me. It makes a lot more sense now. If you don’t mine me bothering you with one more question, when is it best to use “level”, “player”, or just threading the next function without anything in front of “thread blah blah blah”?
It's best to start first with "self" in all the methods but sometimes you need extra hands to make the job done.

If it goes about the player you need to get the player.
In cod waw you can do this:
Code Snippet
Plaintext
players = getplayers();
Maybe you want to check if the player has a certain perk:
Code Snippet
Plaintext
if (players[0] hasperk("specialty_armorvest"))
For all the players:
Code Snippet
Plaintext
for (i = 0; i < players.size; i++)
{
     if (players[i] hasperk("specialty_armorvest"))
     {
        // do stuff
     }
}
Or you want to write functions for the player activating the trigger:
Code Snippet
Plaintext
waittill("trigger", player);
Because of the "waittill" function the game will wait at that point until it's triggered.
But sometimes you want to do other things while waiting and that's where the "thread" comes in.
You should see it as a road way that splits into two directions.
Normally you can only take one of the paths so you have to ask a friend to walk the other path.
That's what a thread does. (I am not sure you are known to this so that's the reason I explain this)

The "level" is a great static global database (don't have a better name for this currently) that can be used in every script.
The problem is that if you change a property somewhere it will be changed in every script where you call "level".
I think you already see the point.

I use "level" to update the scoreboard for example all the points, deaths, kills revives ect.
I used it last time to let all the zombies know that the solo player is in last stand mode.
It show results that the zombies go to a point I marked with a struct on the map.

See "level" as a webpage you want to share with anyone.
If you change the styling and save it then everyone can see the changes.