how can i check if 2 triggers are pressed at the same time?
Posted: May 29th, 2013, 11:35 pm
does anyone know?
CoDJumper.com - For all your CoDJumping needs!
https://codjumper.com/forums/
Code: Select all
main()
{
    level.trigsPressed = 0;
    n = 2;
    for(i = 0; i < n; i++)
        getEnt("triggggger"+i, "targetname") thread trig(i);
}
Â
trig(i)
{
    while(1)
    {
        self waittill("trigger");
        level.trigsPressed++;
        if(level.trigsPressed >= 2)
        {
            //both triggers are pressed at the same time, do your stuff.
        }
        wait .05;    // optional?
        level.trigsPressed--;
    }
}
Â
Code: Select all
if(level.trigsPressed >= 2 && i == 1)
{
/* both triggers are pressed at the same time, do your stuff. */
}
I doubt it. If two triggers are pressed at the same server frame, either function will be done first way. But not both two at the very same time. So, the first function to start will set level.trigsPressed to 1, then without any pauses it will do the if statement, leaving no chance for the second function to change it to 2. And then the second function will start - and the check will be successfull in that case.Drofder2004 wrote:anything inside the "if" statement will run twice when both buttons are pressed.
It's so you can index your triggers in Radiant (for example "trigger_0", "trigger_1", "trigger_2" and so on) and easily get each of them using a loop.pcbouncer wrote:i dont get why you have "trigger"+i