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

Sometimes a player can't open doors

broken avatar :(
Created 8 years ago
by Soy-Yo
0 Members and 1 Guest are viewing this topic.
2,661 views
broken avatar :(
×
broken avatar :(
Location: esMadrid
Date Registered: 27 March 2015
Last active: 3 years ago
Posts
371
Respect
Forum Rank
Perk Hacker
Primary Group
Member
My Contact & Social Links
More
Personal Quote
JIGGLYPUFF used SING! YOU fell asleep!
Signature
×
Soy-Yo's Groups
Soy-Yo's Contact & Social LinksSoy-yoElCerdoRey
So one day while testing coop, one player didn't see the hint on any door and he couldn't open them either. And it still happens sometimes with either player 1 or 2.
I think it has something to do with dying or reviving or both, but I just can't understand why.
This is a part of the script I have for the doors:
Code Snippet
Plaintext
handleDoorsInit() {
   
    level endon( "round_break_finished" );
   
    players = get_players();
    array_thread( players,::fakeTrigger, self );
   
while(1) {
       
        self waittill( "fake_trigger",player );

        // some checks before doing anything
        if( player in_revive_trigger() ) {
            if( getDvarInt( "door_test" ) == 1 )
                player iprintln( "PLAYER TOUCHING A ^4REVIVE TRIGGER" );
            wait(1); // to avoid a player reviving another to open the door just after
            continue;
        }
        if( player maps\_laststand::player_is_in_laststand() ) {
            if( getDvarInt( "door_test" ) == 1 )
                player iprintln( "PLAYER IN ^1LAST STAND" );
            continue; // dont do anything if the player is bleeding out
        }
        if( isDefined( player.isTouchingTrig ) && player.isTouchingTrig ) {
            if( getDvarInt( "door_test" ) == 1 )
                player iprintln( "PLAYER WAS ALREADY TOUCHING ^6TRIG" );
            continue; // player is in trig, so theres no need to call any function again
        }
       
        if( level.useEnding )
            player thread doorNumbersWait( self );
       
        if( isDefined( self.open ) && self.open ) {
            checkTouchingTrig( player );
            continue;
        }
               
        self thread handleDoorsMain( player );
    }
}

fakeTrigger(struct) {
   
    self endon( "death" );
    self endon( "disconnect" );
    level endon( "round_break_finished" );
   
    while(1) {
        if( distance( self.origin, struct.origin ) <= 144 ||
             distance( self.origin + (0,0,60), struct.origin ) <= 144 )
            struct notify( "fake_trigger",self );
        wait(.1);
    }
}

handleDoorsMain(player) {
   
    self endon( "opening_door" );
    player endon( "player_left" );
    player endon( "player_downed" );
    player endon( "death" );
    player endon( "disconnect" );
    level endon( "round_break_finished" );
   
    self.blockPay = undefined;
   
    // create hud
    if( !isDefined( player.doorhud ) ) {
        player.doorhud = fakeHintString( "Press & hold [{+activate}] to open door [Cost: " + player.doorCost + "]",player );
        self thread hudOffAfterOpen( player );
    }
   
    self thread checkTouchingTrig( player ); // check if the player continues in the trigger and deletes hud and ends this if gone
}

checkTouchingTrig(player) {
    player notify( "checking_player_in_trig" ); // might be called twice
    player endon( "checking_player_in_trig" );
    player.isTouchingTrig = true;
    while( ( distance( player.origin, self.origin ) <= 144  || distance( player.origin + (0,0,60), self.origin ) <= 144 ) &&
                !( player in_revive_trigger() ) )
        wait(.1);
       
    player notify( "player_left" );
    if( isDefined( player.doorhud ) ) self hudOff( player );
    player.isTouchingTrig = undefined;
}
If I use the door_test dvar, it says "PLAYER WAS ALREADY TOUCHING ^6TRIG", so player.isTouchingTrig must be true (it has nothing to do with the endons in checkTouchingTrig(player) because it started happening before having them there), but once the player gets away from the struct, player.isTouchingTrig is set undefined, so it shouldn't be true. :-\
Does anyone have any clue?
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 8 years ago
Posts
2,790
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
Signature
Let's keep this thread on topic from here on in. -DBZ

+1 to off-topic reply -DBZ

lmao. Too funny.

Goliath Script Placer: http://ugx-mods.com/forum/index.php/topic,11234.msg125257/topicseen.html#new

"...Christ, people. Learn C, instead of just stringing random characters
together until it compiles (with warnings)..."

-Linus Torvalds
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
Your making this a lot more complicated that it needs to be. You could have just used a trigger_radius and

Code Snippet
Plaintext
<player> isTouching(<radius>)

To determine if a player is touching the trigger or not. All of these distance checks is just nonsense.

Your also calling checkTouchingTrig() without an entity here:

Code Snippet
Plaintext
        if( isDefined( self.open ) && self.open ) {
            checkTouchingTrig( player );
            continue;
        }


broken avatar :(
×
broken avatar :(
Location: esMadrid
Date Registered: 27 March 2015
Last active: 3 years ago
Posts
371
Respect
Forum Rank
Perk Hacker
Primary Group
Member
My Contact & Social Links
More
Personal Quote
JIGGLYPUFF used SING! YOU fell asleep!
×
Soy-Yo's Groups
Soy-Yo's Contact & Social LinksSoy-yoElCerdoRey
Your making this a lot more complicated that it needs to be. You could have just used a trigger_radius and

Code Snippet
Plaintext
<player> isTouching(<radius>)

To determine if a player is touching the trigger or not. All of these distance checks is just nonsense.

Your also calling checkTouchingTrig() without an entity here:

Code Snippet
Plaintext
        if( isDefined( self.open ) && self.open ) {
            checkTouchingTrig( player );
            continue;
        }
Can't use trigger_radius because I get g-spawn. The functions say trig because I was using triggers at first and I'm too lazy to change their names lol.

And for the second part, I don't think it would affect anything, but I also noticed I forgot to thread that function.
And calling a function without an ent pass the parent's "self" to the function as "self", if I'm not wrong, so "self" should still be correct in checkTouchingTrig(). I've fixed it though.
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 8 years ago
Posts
2,790
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
Can't use trigger_radius because I get g-spawn. The functions say trig because I was using triggers at first and I'm too lazy to change their names lol.

Unless your constantly spawning in trigger_radius's like crazy, I can't see how your getting Gspawn. How many triggers is this even for, exactly? What code did you use to spawn them? something like this:

Code Snippet
Plaintext
	trig = spawn("trigger_radius",self.origin,0,20,20);
trig SetCursorHint("HINT_NOICON");

for(i=0;i<get_players().size;i++)
trig setVisibleToPlayer(get_players()[i]);

trig setHintString("Press & hold [{+activate}] to open door [Cost: " + player.doorCost + "]");

?



broken avatar :(
×
broken avatar :(
Location: esMadrid
Date Registered: 27 March 2015
Last active: 3 years ago
Posts
371
Respect
Forum Rank
Perk Hacker
Primary Group
Member
My Contact & Social Links
More
Personal Quote
JIGGLYPUFF used SING! YOU fell asleep!
×
Soy-Yo's Groups
Soy-Yo's Contact & Social LinksSoy-yoElCerdoRey
Unless your constantly spawning in trigger_radius's like crazy, I can't see how your getting Gspawn. How many triggers is this even for, exactly? What code did you use to spawn them? something like this:

Code Snippet
Plaintext
	trig = spawn("trigger_radius",self.origin,0,20,20);
trig SetCursorHint("HINT_NOICON");

for(i=0;i<get_players().size;i++)
trig setVisibleToPlayer(get_players()[i]);

trig setHintString("Press & hold [{+activate}] to open door [Cost: " + player.doorCost + "]");

?




At first I was using trigger_multiple and I couldn't even compile the map because I got g-spawn during compiling lol. You can imagine more or less the number (basically I don't know how many they were :please:).
So I replaced them with structs and made the script to work with them, so there's no need to use trigger_radius at all.
If I don't find any other solution maybe I could try to spawn triggers when the player is near the door, only for the distance check, so I don't have to use the variable. But I don't want to do this because it will make me change more code, probably.
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 8 years ago
Posts
2,790
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
At first I was using trigger_multiple and I couldn't even compile the map because I got g-spawn during compiling lol. You can imagine more or less the number (basically I don't know how many they were :please: ).
So I replaced them with structs and made the script to work with them, so there's no need to use trigger_radius at all.
If I don't find any other solution maybe I could try to spawn triggers when the player is near the door, only for the distance check, so I don't have to use the variable. But I don't want to do this because it will make me change more code, probably.

Yes, there is. The way your doing this is messy, stupid, and clearly not working. The reason you had Gspawn at start was probably because you where looping it. You don't even need to use a distance check at all.

If this is *only* for one trigger, this should be about all you need:

Code Snippet
Plaintext
handleDoorsInit()
{
   trig = spawn("trigger_radius",self.origin,0,20,20);
   trig SetCursorHint("HINT_NOICON");

   for(i=0;i<get_players().size;i++)
      trig setVisibleToPlayer(get_players()[i]);

   trig setHintString("Press & hold [{+activate}] to open door [Cost: " + player.doorCost + "]");

   while(1)
   {
      trig waittill("trigger", player);
     
      // some checks before doing anything
             if( player in_revive_trigger() )
      {
                  if( getDvarInt( "door_test" ) == 1 )
                      player iprintln( "PLAYER TOUCHING A ^4REVIVE TRIGGER" );
                  wait(1);
                  continue;
           }

           if( player maps\_laststand::player_is_in_laststand() )
      {
                 if( getDvarInt( "door_test" ) == 1 )
                      player iprintln( "PLAYER IN ^1LAST STAND" );
         wait(1);
                  continue; // dont do anything if the player is bleeding out
           }

           if( isDefined( player.isTouchingTrig ) && player.isTouchingTrig )
      {
                  if( getDvarInt( "door_test" ) == 1 )
                      player iprintln( "PLAYER WAS ALREADY TOUCHING ^6TRIG" );
         wait(1);
                  continue; // player is in trig, so theres no need to call any function again
           }

           if( level.useEnding )
                  player thread doorNumbersWait( self );

           self delete(); // Should it be deleted?
   }
}

Might need to do some tweaking(didn't compile, either), but I can't see any reason why this wouldn't work for what your trying to do.



Last Edit: April 30, 2016, 05:37:45 pm by daedra descent
broken avatar :(
×
broken avatar :(
Location: esMadrid
Date Registered: 27 March 2015
Last active: 3 years ago
Posts
371
Respect
Forum Rank
Perk Hacker
Primary Group
Member
My Contact & Social Links
More
Personal Quote
JIGGLYPUFF used SING! YOU fell asleep!
×
Soy-Yo's Groups
Soy-Yo's Contact & Social LinksSoy-yoElCerdoRey
Yes, there is. The way your doing this is messy, stupid, and clearly not working. The reason you had Gspawn at start was probably because you where looping it. You don't even need to use a distance check at all.

If this is *only* for one trigger, this should be about all you need:

Code Snippet
Plaintext
handleDoorsInit()
{
trig = spawn("trigger_radius",self.origin,0,20,20);
trig SetCursorHint("HINT_NOICON");

for(i=0;i<get_players().size;i++)
trig setVisibleToPlayer(get_players()[i]);

trig setHintString("Press & hold [{+activate}] to open door [Cost: " + player.doorCost + "]");

while(1)
{
trig waittill("trigger", player);

// some checks before doing anything
        if( player in_revive_trigger() )
{
            if( getDvarInt( "door_test" ) == 1 )
                player iprintln( "PLAYER TOUCHING A ^4REVIVE TRIGGER" );
            wait(1);
            continue;
        }

        if( player maps\_laststand::player_is_in_laststand() )
{
            if( getDvarInt( "door_test" ) == 1 )
                player iprintln( "PLAYER IN ^1LAST STAND" );
wait(1);
            continue; // dont do anything if the player is bleeding out
        }

        if( isDefined( player.isTouchingTrig ) && player.isTouchingTrig )
{
            if( getDvarInt( "door_test" ) == 1 )
                player iprintln( "PLAYER WAS ALREADY TOUCHING ^6TRIG" );
wait(1);
            continue; // player is in trig, so theres no need to call any function again
        }

        if( level.useEnding )
            player thread doorNumbersWait( self );

                delete(); // Should it be deleted?
}
}

Might need to do some tweaking(didn't compile, either), but I can't see any reason why this wouldn't work for what your trying to do.
The way I'm doing it is not stupid and does work. The only thing is that a few times somehow one player (never happened to more than one) gets its isTouchingTrig attribute fucked up and it's always true.
I couldn't even compile the map because I got g-spawn during compiling
Wasn't looping anything...
And no, it's not for one trigger. That code will make me have g-spawn.
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 8 years ago
Posts
2,790
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
The way I'm doing it is not stupid and does work. The only thing is that a few times somehow one player (never happened to more than one) gets its isTouchingTrig attribute fucked up and it's always true.Wasn't looping anything...
And no, it's not for one trigger. That code will make me have g-spawn.

Trying to replicate something that already exists(and works) by creating and threading a bunch of functions isn't stupid? lol

You have to be doing somekind of loop. Gspawn errors don't just show up for no reason, and that reason sure as hell isn't because you spawned a few trigger_radius(unless your close to the limit somehow.).

I did basically the same thing for the Soviet mod's weapons. It works just fine:

Code Snippet
Plaintext
init()
{
if(!is_declared(level.weapon))
level.weapon = [];

level.weapon["weapons"] = getentarray("weapon","targetname");

if(!is_declared(level.weapon["weapons"]))
assertMsg("No Weapons!");

array_thread(level.weapon["weapons"], ::init_guns);

}
init_guns()
{
if(!is_declared(self.script_noteworthy))
assertMsg("No script noteworthy for weapon at " + self.origin);

self.cost = level.cost[level.soviet["gamemode"]][self.script_noteworthy];

if(!is_declared(self.cost))
assertMsg("Cost not defined for weapon: " + self.script_noteworthy);

trig = spawn("trigger_radius",self.origin,0,20,20);
trig SetCursorHint("HINT_NOICON");

for(i=0;i<get_players().size;i++)
trig setVisibleToPlayer(get_players()[i]);

self.script_noteworthy_old = self.script_noteworthy;

if(strTok(self.script_noteworthy, "_").size > 1)
self.script_noteworthy = strTok(self.script_noteworthy, "_")[0] + " " + strTok(self.script_noteworthy, "_")[1];

if(is_declared(level.soviet["weapon_cost_mod"]) && is_declared(level.soviet["ammo_cost_mod"]))
{
self.cost = set_difficulty_mod(self.cost, level.soviet["weapon_cost_mod"]);
self.ammo_cost = set_difficulty_mod(self.cost, level.soviet["ammo_cost_mod"], self.cost);

if(self.cost == self.ammo_cost)
self.ammo_cost++;
}
else
assertMsg("No weapon cost mods for diff: " + level.soviet["dif"]);

dev_add_playback("weapons", "Weapon: " + self.script_noteworthy + " || Cost: " + self.cost + " || Ammo Cost " + self.ammo_cost + " || Origin: " + self.origin + " initalized successfully!");

trig sethintstring("Press F for " + self.script_noteworthy + "[" + self.cost  + level.soviet["cType"] + " required for weapon, " + (self.ammo_cost) + " for ammo]");


while(1)
{
trig waittill("trigger", player);

if(!isAI(player))
{
if(player istouching(trig) && !player hasweapon(self.script_noteworthy_old) && player usebuttonpressed())
{
if(player.score >= self.cost)
{
thread play_sound_on_entity("cha_ching");
player takeweapon(player getcurrentweapon());
player giveweapon(self.script_noteworthy_old);
player switchtoweapon(self.script_noteworthy_old);
}
}
else if(player istouching(trig) && player hasweapon(self.script_noteworthy_old) && player getCurrentWeapon() == self.script_noteworthy_old && player usebuttonpressed())
if(player.score >= self.ammo_cost)
player giveMaxAmmo(player getCurrentWeapon());
wait(.01);
}
}
}
Last Edit: April 30, 2016, 06:05:09 pm by daedra descent
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 4 years ago
Posts
1,895
Respect
Forum Rank
Zombie Destroyer
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
BE ORIGINAL
Signature
×
MakeCents's Groups
Community Mapper Has released one or more maps to the UGX-Mods community which have been added to the UGX Map Manager.
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
I think you may be slightly confused. Scripting, unless spawning in ents like you are suggesting, isn't the cause for gspawn. Gspawn typcially occurs when you have too many interactive ents and what you are suggesting is to spawn more ents. He is attempting to relieve his interactive ents by scripting around it. I've done it in ORBiT as well, slightly different. Triggers for me were just the easiest, most used ent that I could get around easily. I'm sorry that is confusing or stupid to you. He did agree that spawning one ent per door if a player is near could be an alternative, and he is completely capable of figuring out that method. He was merely asking for "help" to see if anyone could see the error in his code, he wanted to use.

On a side note, you need to either learn to speak to people or stop trying to help. No matter how much more you think you know, no one will care if you call them stupid, or what they thing they are doing is stupid.
Last Edit: April 30, 2016, 06:32:43 pm by MakeCents
broken avatar :(
×
broken avatar :(
Location: esMadrid
Date Registered: 27 March 2015
Last active: 3 years ago
Posts
371
Respect
Forum Rank
Perk Hacker
Primary Group
Member
My Contact & Social Links
More
Personal Quote
JIGGLYPUFF used SING! YOU fell asleep!
×
Soy-Yo's Groups
Soy-Yo's Contact & Social LinksSoy-yoElCerdoRey
I think you may be slightly confused. Scripting, unless spawning in ents like you are suggesting, isn't the cause for gspawn. Gspawn typcially occurs when you have too many interactive ents and what you are suggesting is to spawn more ents. He is attempting to relieve his interactive ents by scripting around it. I've done it in ORBiT as well, slightly different. Triggers for me were just the easiest, most used ent that I could get around easily. I'm sorry that is confusing or stupid to you. He did agree that spawning one ent per door if a player is near could be an alternative, and he is completely capable of figuring out that method. He was merely asking for "help" to see if anyone could see the error in his code, he wanted to use.

On a side note, you need to either learn to speak to people or stop trying to help. No matter how much more you think you know, no one will care if you call them stupid, or what they thing they are doing is stupid.
Yeah, thank you. Wouldn't have expressed it better.
broken avatar :(
×
broken avatar :(
Location: esMadrid
Date Registered: 27 March 2015
Last active: 3 years ago
Posts
371
Respect
Forum Rank
Perk Hacker
Primary Group
Member
My Contact & Social Links
More
Personal Quote
JIGGLYPUFF used SING! YOU fell asleep!
×
Soy-Yo's Groups
Soy-Yo's Contact & Social LinksSoy-yoElCerdoRey
Well, I think it's probably solved. Haven't happened again but can't promise it won't appear the next time I test the map lol.
MakeCents sent me some script he has yesterday and he used player.activeTrig instead of player.isTouchingTrig. So, with this attribute he sets the fake trigger the player is touching rather than saying that the player is touching any fake trigger (mine).
Now it is:
Code Snippet
Plaintext
        //if( isDefined( player.isTouchingTrig ) && player.isTouchingTrig ) {
        if( isDefined( player.activeTrig ) && player.activeTrig == self ) {
            if( getDvarInt( "door_test" ) == 1 )
                player iprintln( "PLAYER WAS ALREADY TOUCHING ^6TRIG" );
            continue; // player is in trig, so theres no need to call any function again
        }
        // ···
        self thread handleDoorsMain( player );

//*************************************\\

checkTouchingTrig(player) {
    player notify( "checking_player_in_trig" ); // might be called twice
    player endon( "checking_player_in_trig" );
    //player.isTouchingTrig = true;
    player.activeTrig = self;
So let's say the bug appears. With my code, player.isTouchingTrig will remain true, so handleDoorsMain will be never called and everything will stop working because checkTouchingTrig won't be called either, so it can't be undefined again.
With this other method, the check will only be true for one door, so the player won't be able to open that certain door. But when he triggers another "trigger", the check is false because it's not the same door, so handleDoorsMain and checkTouchingTrig will be called and he will be able to open the door and the attribute will change its value to that door.
I think it does make sense lol.
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 4 years ago
Posts
1,895
Respect
Forum Rank
Zombie Destroyer
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
BE ORIGINAL
×
MakeCents's Groups
Community Mapper Has released one or more maps to the UGX-Mods community which have been added to the UGX Map Manager.
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
Lol, glad its working  ;D

 
Loading ...