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

An another scripting question here

broken avatar :(
Created 12 years ago
by Ege115
0 Members and 1 Guest are viewing this topic.
3,097 views
broken avatar :(
×
broken avatar :(
Location: se
Date Registered: 30 July 2013
Last active: 2 years ago
Posts
517
Respect
Forum Rank
Zombie Enslaver
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
×
Ege115's Groups
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Ege115's Contact & Social LinksEge115
Hello members of UGX!

I have an another scripting question.
Okey, let's say I have two triggers and both are going to do the same thing depending on which trigger the player activates first. For example of a script that will do its task with only one trigger

Code Snippet
Plaintext
#include common_scripts\utility; 
#include maps\_zombiemode_utility;
#include maps\_utility;

random_script()
{
trigger1 = getent("trigger1","targetname");
trigger2 = getent("trigger2","targetname");
moving_object = getent("moving_object","targetname");
move_point = getent("move_point","targetname");

while(1)
{
trigger1 waittill("trigger", player);
moving_object moveto (move_point.origin, 5);
}
}
Okey, now as you see, this just moves an object as soon as you hit a trigger.
But what if the player found the trigger2 instead of trigger1 and hit the trigger2 instead? Then I want it to make the same thing in the script but just the script is being activated with a different trigger if the player would find the other trigger first, so what I am trying to do here is that the script will make its task if the player EITHER hit the trigger1 or the trigger2 and after the script have done its logic from whatever trigger you hit first, it will countinue the loop. But I don't know how I would do that.

I know that you can add like a "else if" in a script but I don't know how that would continue on that line.
I mean so it could look like this.

Code Snippet
Plaintext
#include common_scripts\utility; 
#include maps\_zombiemode_utility;
#include maps\_utility;

random_script()
{
trigger1 = getent("trigger","targetname");
trigger2 = getent("trigger2","targetname");
moving_object = getent("moving_object","targetname");
move_point = getent("move_point","targetname");

player = get_players();
while(1)
{
trigger1 waittill("trigger", player);
moving_object moveto (move_point.origin, 5);
}

else if ( player_activates_the_other_trigger( trigger2 ) ) // This line I mean, how would I do it? Can  someone tell me what I //am supposed to add here to get it working the way I said?
moving_object moveto (move_point.origin, 5);
}
Thanks in advance.  :)
Last Edit: March 09, 2014, 03:53:19 pm by Ege115
Marked as best answer by Ege115 12 years ago
broken avatar :(
×
broken avatar :(
Location: de
Date Registered: 6 August 2012
Last active: 6 years ago
Posts
277
Respect
Forum Rank
Mr. Elemental
Primary Group
Scripter Elite
My Groups
More
×
YaPh1l's Groups
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
YaPh1l's Contact & Social Links
You need to run a thread on each trigger, waiting for it to be triggered and do a notify on a shared entity. Your main code waits for taht notify.

- Phil.
broken avatar :(
  • n123q45
  • Deleted Member
×
broken avatar :(
n123q45
This user is deleted :(
i would set a variable and have it check for that variable befor it  moves it. then alter the variable afte it moves it. thats how im going to be doing my dynamic map stuff


edit: or what yaphill said works too
Last Edit: March 09, 2014, 04:02:42 pm by n123q45
broken avatar :(
×
broken avatar :(
Location: de
Date Registered: 6 August 2012
Last active: 6 years ago
Posts
277
Respect
Forum Rank
Mr. Elemental
Primary Group
Scripter Elite
My Groups
More
×
YaPh1l's Groups
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
YaPh1l's Contact & Social Links
You shouldn't do polling if it can be avoided...

- Phil.
broken avatar :(
×
broken avatar :(
Location: se
Date Registered: 30 July 2013
Last active: 2 years ago
Posts
517
Respect
Forum Rank
Zombie Enslaver
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
×
Ege115's Groups
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Ege115's Contact & Social LinksEge115
You need to run a thread on each trigger, waiting for it to be triggered and do a notify on a shared entity. Your main code waits for taht notify.

- Phil.

I tried that before also, but that got buggy because let's say an object can move between 2 different locations lke this.
Code Snippet
Plaintext
#include common_scripts\utility; 
#include maps\_zombiemode_utility;
#include maps\_utility;

main()
{
thread random_script();
thread other_trigger();
}

random_script()
{
trigger1 = getent("trigger1","targetname");
trigger2 = getent("trigger2","targetname");
moving_object = getent("moving_object","targetname");
move_point1 = getent("move_point1","targetname");
move_point2 = getent("move_point2","targetname");

while(1)
{
trigger1 waittill("trigger", player);
moving_object moveto (move_point2.origin, 5);
trigger1 waittill ("movedone");
moving_object moveto (move_point1.origin, 5);
}
}

other_trigger()
{
trigger1 = getent("trigger1","targetname");
trigger2 = getent("trigger2","targetname");
moving_object = getent("moving_object","targetname");
move_point1 = getent("move_point1","targetname");
move_point2 = getent("move_point2","targetname");

while(1)
{
trigger2 waittill("trigger", player);
moving_object moveto (move_point2.origin, 5);
trigger2 waittill ("movedone");
moving_object moveto (move_point.origin, 5);
}
}
This is hard to explain but when I tested it like this, then let's say, the trigger2 first task is to move the object to what I called it "move_point"
And the the trigger1 first task is to move the object to what I called it "move_point2" right?

And when you test this ingame, then let's say if the player hit the trigger1 which that trigger's first task is to move the object to "move_point2" and when the object have moved to that location, then meanwhile the trigger2 first task is to bring the object to "move_point2" also.

Then it is right there the bug happens, so if the player activates the trigger2 that is mean't to move the object to "move_point2" and now when the player already have activated the trigger1 that already have moved to "move_point2" then when the trigger2 will be called, then the object will not move because the object is already at move_point2 that the trigger2 first task is to make it move there, so you will have to hit the trigger2 twice to get the object moving to "move_point1" since that is the second task the trigger has. And I don't want that because I am going to make the trigger to cost points, so when that bug happens, then the player will have to pay the trigger twice, so if it would cost 1500 and the bug happens, then you will have to pay 3000, and that would not be good.

Phew, finally done typing this, hope someone understands this bug explonation, lol.
Last Edit: March 09, 2014, 04:58:44 pm by Ege115
broken avatar :(
×
broken avatar :(
Location: de
Date Registered: 6 August 2012
Last active: 6 years ago
Posts
277
Respect
Forum Rank
Mr. Elemental
Primary Group
Scripter Elite
My Groups
More
×
YaPh1l's Groups
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
YaPh1l's Contact & Social Links
You are not doing what I described.

- Phil.
broken avatar :(
×
broken avatar :(
Location: se
Date Registered: 30 July 2013
Last active: 2 years ago
Posts
517
Respect
Forum Rank
Zombie Enslaver
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
×
Ege115's Groups
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Ege115's Contact & Social LinksEge115
You are not doing what I described.

- Phil.

Didn't I added them in a thread? Anyway I know you said notify on shared entities. but that is the next thing I want to learn.
How does notifing in scripting works?

Like how would I do it
Code Snippet
Plaintext
level notify ("notify_what?");
On shared entities what?
Last Edit: March 09, 2014, 05:05:38 pm by Ege115
broken avatar :(
×
broken avatar :(
Location: de
Date Registered: 6 August 2012
Last active: 6 years ago
Posts
277
Respect
Forum Rank
Mr. Elemental
Primary Group
Scripter Elite
My Groups
More
×
YaPh1l's Groups
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
YaPh1l's Contact & Social Links
You can notify anything you want, as it is a string. Just choose something that makes sense.
And in your case, you could use the moving_object as the shared entity.

- Phil.
broken avatar :(
×
broken avatar :(
Location: se
Date Registered: 30 July 2013
Last active: 2 years ago
Posts
517
Respect
Forum Rank
Zombie Enslaver
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
×
Ege115's Groups
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Ege115's Contact & Social LinksEge115
You can notify anything you want, as it is a string. Just choose something that makes sense.
And in your case, you could use the moving_object as the shared entity.

- Phil.

Oh, I see.

So where in the script I posted do I have to put a notify then?
trigger1 notify ("moving_object");
So does this fixes the bug where ever I now add this line?
broken avatar :(
×
broken avatar :(
Location: de
Date Registered: 6 August 2012
Last active: 6 years ago
Posts
277
Respect
Forum Rank
Mr. Elemental
Primary Group
Scripter Elite
My Groups
More
×
YaPh1l's Groups
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
YaPh1l's Contact & Social Links
First, you can't put it anywhere in your current script and expect it to work. Your script needs more changes so that it works as I described.
Second, in your line, you notify on the trigger, which is not what I suggested you should use as the shared entity.

- Phil.
Last Edit: March 09, 2014, 07:39:57 pm by YaPh1l
broken avatar :(
×
broken avatar :(
Location: se
Date Registered: 30 July 2013
Last active: 2 years ago
Posts
517
Respect
Forum Rank
Zombie Enslaver
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
×
Ege115's Groups
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Ege115's Contact & Social LinksEge115
Well, alright then, I'll see what I can put together to get it working.

Thank you Phil.

 
Loading ...