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:
// 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 );
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?
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.
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:
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:
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 ). 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.
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 ). 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:
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
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:
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.
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:
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
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.
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.