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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - Soy-Yo

So I added gamemodes to my map and I'm trying to edit the menu so they are selectable in Game Setup in coop lobbies. I could only make it with
Code Snippet
Plaintext
CHOICE_DVARFLOATLIST_VIS()
but when I close the menu without applying the changes, the dvar value keeps being the same.
So basically, I want to make it that the dvar value only changes when I apply the changes. But I don't have any idea, lol. I've been looking at some menu files, but I can't find how they do that.
8 years ago
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.
8 years ago
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.
8 years ago
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.
8 years ago
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.
8 years ago
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.
8 years ago
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?
8 years ago
FINALLY GOT IT WORKING !! :D

Did everything you told me and nothing worked. Today, I decided to move the xanims from my .atr file to generic_human.atr. And, don't know why, but it just worked fine.
8 years ago
What I did was add this line in the check_for_instakill() function alaurenc said and it works:
Code Snippet
Plaintext
if(player.use_weapon_type == "MOD_MELEE")
{
player.last_kill_method = "MOD_MELEE";
            // Soy-yo's 130 points when knifing fix:
                player maps\_zombiemode_score::add_to_player_score( 20 *  level.zombie_vars[ "zombie_point_scalar" ] );
}
It's a shitty way, probably alaurenc's would be better, but it works. Mine gives you +100, +10 and +20 on hud, maybe his gives +130, don't know.
8 years ago
You have to precache your effect first in your preCacheMyFX() function in mapname.gsc for example, like this:
Code Snippet
Plaintext
level._effect[ "name_of_fx" ] = loadfx( "env/light/fx_lgiht_ceiling_amber_dim_dl" );
And then to play the fx, in the function you're making:
Code Snippet
Plaintext
playLoopedFX (level._effect[ "name_of_fx" ], 0.05, (0,180,108));
You missed the ";" at the end of the first line, that's the error you're getting. Also, you can't use the level._effect variable like that, as it's an array and you're resetting it as a normal variable and overwriting every other effect.
8 years ago
Also what is the difference between threading and not threading? and how can you tell when to thread a function and when not to thread a function.
If you thread you call the function but the code continues. If you don't thread it, the code will stop there until the function ends or return something. So for example:
Code Snippet
Plaintext
func1() {
    level.var = 5;
    thread func2();
    iprintlnbold( level.var ); // will print 5
}
func1() {
    level.var = 5;
    func2();
    iprintlnbold( level.var ); // will print 10
}

func2() {
    wait .5;
    level.var = 10;
}
I think it's better not to thread unless you want something to run at the same time, like call the same function on multiple ents at the same time or when you want a function to be active during some time with a while loop (play a sound every x seconds or something), for example.
8 years ago
Code Snippet
Plaintext

if(self.script_noteworthy == level.switch_order[i])
{
iprintlnbold("Button " +self.script_noteworthy+ " is correct");
level.number_correct ++;

if(level.number_correct == 5)
{
}
I think it should be:
Code Snippet
Plaintext
if(level.number_correct == 6)
because you've just summed 1 to level.number_correct. But apart from it, daedra's script seems easier and won't cause you much problems.
8 years ago
This shouldn't be happening. ???
Try printing the level.number_correct after self endon("button_hit"); to see if the function is being called twice and then add some different prints inside the if's.
Also, I wouldn't thread the check_for_correct_button(); function and I'm pretty sure you can simplify it to do just one check for all the numbers. Maybe having the function like this causes problems and if you simplify it, it will work. Don't know.
8 years ago
I wonder if I can use this to 3 or 4 player coop with someone else doing the same thing... probably right?
I don't see why not. If you have two PCs, you can connect 2 players with one and other 2 with the other. But if you want to test it with another person online, then you'll need Tunngle for sure, but I suppose that the other person could connect with two players too.
But I'm just guessing.
8 years ago
Loading ...