UGX-Mods Login

or login with an authentication provider below
Sign In with Google
Sign In with Twitter
Sign In with Discord
Sign In with Steam
Sign In with Facebook
Sign In with Twitch

test if a trigger has been triggered

broken avatar :(
Created 11 years ago
by buttkicker845
0 Members and 1 Guest are viewing this topic.
2,900 views
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 11 March 2014
Last active: 5 years ago
Posts
264
Respect
Forum Rank
Mr. Elemental
Primary Group
Member
Signature
"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."
×
buttkicker845's Groups
buttkicker845's Contact & Social Links
i have an array of triggers that i want to be to have something happen at that index of the array but if i do

Code Snippet
Plaintext
trig [i] waittill("trigger");

the code stops at the first iteration until the first trigger has been triggered and so on. how would i go about iterating through each trigger and having it wait until it it has been triggered before calling the next line of code?

sorry if that doesnt make sense, i was trying to think of the best way to word it.

thank you in advance for any help :)
Marked as best answer by buttkicker845 11 years ago
broken avatar :(
×
broken avatar :(
RadihaX
Location: caCanada
Date Registered: 2 September 2012
Last active: 5 years ago
Posts
978
Respect
Forum Rank
The Decider
Primary Group
Mapper Elite
My Groups
More
My Contact & Social Links
More
Signature
Overrun
Lockdown
Overrun (Black Ops Mod)
Snowglobe
Leviathan
Abandoned School
Ski Resort
Leviathan Redux
×
JBird632's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
UGX V.I.P.
UGX V.I.P.
Mapper Elite Has shown excellence and experience in the area of custom mapping in the UGX-Mods community.
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
JBird632's Contact & Social LinksJBird632JBird632JBird632JBird632JBird632Mapper
Thread each trigger another function where that new function will waittill the trigger of each trigger separately.
"Threading" makings the game not wait for the function.
Then if u want something to occur that would happen when any one of the triggers occur, you can have a waittill function in the original function that waits for a notify from any of the triggers (this notify can also end the other functions as well).

Code Snippet
Plaintext
originalFunction()
{
   trig = GetEntArray("custom_triggers", "targetname");

   for(i=0;i<trig.size;i++)
      trig[i] thread watchTrigger();

   level waittill("custom_trigger");

   // Do stuff
}

threadedFunction()
{
   level endon("custom_trigger"); // optional if you want these functions to end if one trigger is triggered
   self waittill("trigger");
   level notify("custom_trigger");
}
Last Edit: February 03, 2015, 04:41:23 pm by JBird632
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 11 March 2014
Last active: 5 years ago
Posts
264
Respect
Forum Rank
Mr. Elemental
Primary Group
Member
×
buttkicker845's Groups
buttkicker845's Contact & Social Links
ok, well how would i find out which player has triggered one of the triggers?
broken avatar :(
×
broken avatar :(
drago
Location: mx
Date Registered: 5 July 2013
Last active: 7 years ago
Posts
941
Respect
Forum Rank
The Decider
Primary Group
Member
My Contact & Social Links
More
×
jjbradman's Groups
jjbradman's Contact & Social Linksjjbradmanjjbradmanjjbradman
ok, well how would i find out which player has triggered one of the triggers?

Code Snippet
Plaintext
trig waittill("trigger", player);
//then you can do stuff with that player
player giveWeapon("m1garand");

broken avatar :(
×
broken avatar :(
Location: gbMilton Keynes
Date Registered: 17 January 2014
Last active: 6 years ago
Posts
6,875
Respect
Forum Rank
Immortal
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
Signature
If you want scripts / features made for you, then contact me by PM or email / skype etc
it will cost you tho so if you have no intention of reciprocating don't even waste my time ;)
×
Harry Bo21's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Harry Bo21's Contact & Social LinksHarryBo000[email protected]HarryBo21
Code Snippet
Plaintext
trigger_init()
{
trig = getEntArray( "trigger_targetname", "targetname" ); // Get array of the triggers using this targetname - This will allow for more than one trigger with the same targetname
array_thread( trig,::trig_watch ); // Thread the second function on each of those triggers
}

trig_watch()
{
while (1) // Need a loop to keep checking
{
player = undefined; // Undeclare this just in case
self waittill( "trigger", player ); // assigns whoever is found touching this trigger to the variable "player"

iPrintLn( "Trigger touched by" + player ); // Print text to the screen to say who touched the trigger

wait 1; // Need to have a wait to prevent engine crashes, something to do with using loops I believe
}
}
broken avatar :(
×
broken avatar :(
Senpai
Location: us
Date Registered: 28 September 2013
Last active: 10 months ago
Posts
602
Respect
Forum Rank
Zombie Enslaver
Primary Group
Box Mappers Elite
My Groups
More
My Contact & Social Links
More
×
arceus's Groups
Box Mappers Elite
Box Mappers Elite
arceus's Contact & Social LinksarceusNT
Code Snippet
Plaintext
trigger_init()
{
trig = getEntArray( "trigger_targetname", "targetname" ); // Get array of the triggers using this targetname - This will allow for more than one trigger with the same targetname
array_thread( trig,::trig_watch ); // Thread the second function on each of those triggers
}

trig_watch()
{
while (1) // Need a loop to keep checking
{
player = undefined; // Undeclare this just in case
self waittill( "trigger", player ); // assigns whoever is found touching this trigger to the variable "player"

iPrintLn( "Trigger touched by" + player ); // Print text to the screen to say who touched the trigger

wait 1; // Need to have a wait to prevent engine crashes, something to do with using loops I believe
}
}
because of the waittill you dont need the wait 1;........ just sayin
broken avatar :(
×
broken avatar :(
Location: gbMilton Keynes
Date Registered: 17 January 2014
Last active: 6 years ago
Posts
6,875
Respect
Forum Rank
Immortal
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
×
Harry Bo21's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Harry Bo21's Contact & Social LinksHarryBo000[email protected]HarryBo21
noted ;)
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 11 March 2014
Last active: 5 years ago
Posts
264
Respect
Forum Rank
Mr. Elemental
Primary Group
Member
×
buttkicker845's Groups
buttkicker845's Contact & Social Links
thanks guys i got it working! although i ended up doing it a slightly different way but it works now :D

 
Loading ...