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

Triggers and Conditions

HOT
broken avatar :(
Created 6 years ago
by Deleted User
0 Members and 1 Guest are viewing this topic.
3,116 views
broken avatar :(
  • DeletedUser
  • Deleted Member
×
broken avatar :(
DeletedUser
This user is deleted :(
Well I started a script, I have to make trigger multiples that make something each one, and also these triggers aren't the same, so I can't put them in one array, something like this:

Code Snippet
Plaintext
        trigger1 = GetEnt("trigger_one","targetname")
        trigger2 = GetEnt("trigger_two","targetname")

The problem is, I don't know how to put a condition to each trigger in a if statement, I've been thinking of a istouching, but that one I think is for trigger radius only, and a waittill, I never see it like a condition in a if, so what can I do?
broken avatar :(
×
broken avatar :(
Location: nlApeldoorn
Date Registered: 17 December 2013
Last active: 1 year ago
Posts
1,187
Respect
1,404Add +1
Forum Rank
Zombie Colossus
Primary Group
Community Scripter Elite
My Groups
More
My Contact & Social Links
More
Personal Quote
It aint much, if it aint Dutch
Signature
×
BluntStuffy's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Community Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
Oil Rig Beta Access
Oil Rig Beta Access
BluntStuffy's Contact & Social LinksBluntstuffy@BluntZombieBluntStuffyStuffyZombie
you can use istouching() for trigger_multiple's, it works fine
broken avatar :(
  • DeletedUser
  • Deleted Member
×
broken avatar :(
DeletedUser
This user is deleted :(
you can use istouching() for trigger_multiple's, it works fine

one problem already solved :) now I need to make another function that detects the last player that touched the trigger, (player already dead and the end game shows).

broken avatar :(
×
broken avatar :(
Location: deDortmund
Date Registered: 20 December 2015
Last active: 5 months ago
Posts
307
Respect
Forum Rank
Perk Hacker
Primary Group
Community Scripter
My Groups
More
Personal Quote
Payback
Signature
Tears Of The Fallen | Join the project https://discord.gg/8gDNQRj
×
fanmagic's Groups
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
fanmagic's Contact & Social LinksTears Of The Fallen
one problem already solved :) now I need to make another function that detects the last player that touched the trigger, (player already dead and the end game shows).
If you want to get the last player who has touched a trigger you can use something like this:
Code Snippet
Plaintext
while(1)
{
     trigger1 waittill ("trigger", who);
     if (isplayer ( who ))
     {
          level.last_player = who;
     }
     wait (.5);
}
The player is stored in the last_player variable. I hope that this will help you. :)
broken avatar :(
  • DeletedUser
  • Deleted Member
×
broken avatar :(
DeletedUser
This user is deleted :(
 What if the comparison is between two triggers?, I mean, to know which is the last trigger touched by the last player?
broken avatar :(
×
broken avatar :(
Location: deDortmund
Date Registered: 20 December 2015
Last active: 5 months ago
Posts
307
Respect
Forum Rank
Perk Hacker
Primary Group
Community Scripter
My Groups
More
Personal Quote
Payback
×
fanmagic's Groups
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
fanmagic's Contact & Social LinksTears Of The Fallen
What if the comparison is between two triggers?, I mean, to know which is the last trigger touched by the last player?
If i understand you correctly this should work. You need 2 instead of 1 loop:
Code Snippet
Plaintext
while (1)
{
      trigger1 waittill ( "trigger" , who);
       if ( isplayer ( who ))
       {
           level.last_player = who;
           level.last_trigger = trigger1;
       }
       wait ( .5 );
}

//and for the second trigger

while (1)
{
      trigger2 waittill ( "trigger" , who);
       if ( isplayer ( who ))
       {
           level.last_player = who;
           level.last_trigger = trigger2;
       }
       wait ( .5 );
}
broken avatar :(
  • DeletedUser
  • Deleted Member
×
broken avatar :(
DeletedUser
This user is deleted :(
With that I have the rest, now I need to know how to break the while if the if statement within that was fulfilled
broken avatar :(
×
broken avatar :(
Location: deDortmund
Date Registered: 20 December 2015
Last active: 5 months ago
Posts
307
Respect
Forum Rank
Perk Hacker
Primary Group
Community Scripter
My Groups
More
Personal Quote
Payback
×
fanmagic's Groups
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
fanmagic's Contact & Social LinksTears Of The Fallen
With that I have the rest, now I need to know how to break the while if the if statement within that was fulfilled
Just put a break at the end of the if-statement:
Code Snippet
Plaintext
level.last_trigger = trigger1;
break;
broken avatar :(
  • DeletedUser
  • Deleted Member
×
broken avatar :(
DeletedUser
This user is deleted :(
Thanks you, now I have all :)

Double Post Merge: January 09, 2018, 04:20:33 am
I don't want to create a new thread, so i will post here my script:

I added this to the main function of zombiemode.gsc

Code Snippet
Plaintext
thread function_one();
thread function_two();

then, before end_game function I added these functions

Code Snippet
Plaintext
function_one()
{
 
        trigger = GetEnt("random_one","targetname");

        level.start = false;

        level.trigger_one_count = 0;

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

                  if( level.countplayerdown == level.players_playing )
                  {
                       level.start = true;
                       
                       break;
                  }
                 
              level.trigger_one_count++;

              wait ( .5 );
        }
}
function_two()
{

        trigger1 = GetEnt("random_two","targetname")

        level.start_two = false;
       
        level.trigger_two_count = 0;
       
        while (1)
        {
             trigger1 waittill ( "trigger" , player);
                 
                  if( level.countplayerdown == level.players_playing )
                  {
                       level.start_two = true;
                       
                       break;
                  }
             
             level.trigger_two_count++;

             wait ( .5 );
        }

}

Well I modified a variable (count) in player_damage_override in to level.countplayerdown, so I can use that in whatever function or gsc I want, I have to clarify that this is my understanding about level variables (maybe I'm wrong), that's why all my variables are level variables. My main error on those functions is this:

Code Snippet
Plaintext
level.start_two = false;

Maybe there is more errors. Also I want to know why I can't use getplayers(); (or get_players():, I've seen this two options) in my functions, because if I use that it gives me a bad syntax error, I wrote something like this:

Code Snippet
Plaintext
players = getplayers();
or
players = get_players();

I read something in this forum about I can't use this function if I don't use an array, I'm not sure about that.
broken avatar :(
×
broken avatar :(
Location: kh
Date Registered: 9 August 2013
Last active: 5 years ago
Posts
503
Respect
Forum Rank
Zombie Enslaver
Primary Group
Member
×
codmoddd1234's Groups
codmoddd1234's Contact & Social Links
Missing ; at the end of the first line of function_two so it shows the next line as the error.
broken avatar :(
  • DeletedUser
  • Deleted Member
×
broken avatar :(
DeletedUser
This user is deleted :(
well now it's fixed, but now another error shows, in the first bracket in the if statement

Code Snippet
Plaintext
        If( level.start == true && level.start_two == false )
        { // Here is the error
            setmusicstate("music_one");
        }

        If( level.start == false && level.start_two == true )
        {
            setmusicstate("music_two");
        }
broken avatar :(
×
broken avatar :(
Location: kh
Date Registered: 9 August 2013
Last active: 5 years ago
Posts
503
Respect
Forum Rank
Zombie Enslaver
Primary Group
Member
×
codmoddd1234's Groups
codmoddd1234's Contact & Social Links
Do you have
#include maps\_music;
At the top of your script?
broken avatar :(
  • DeletedUser
  • Deleted Member
×
broken avatar :(
DeletedUser
This user is deleted :(
Yes, I'm using _zombiemode.gsc to do this script, maybe is it a contradiction in the if sentence?, well I'll post all the file:


Code Snippet
Plaintext
main(init_zombie_spawner_name)
{
precache_shaders();
precache_models();

PrecacheItem( "fraggrenade" );
PrecacheItem( "colt" );

init_strings();
init_levelvars();
init_animscripts();
init_sounds();
init_shellshocks();
init_flags();

//Limit zombie to 24 max, must have for network purposes
SetAILimit( 24 );
// the initial spawners
if( !IsDefined( init_zombie_spawner_name) )
{
level.enemy_spawns = getEntArray( "zombie_spawner_init", "targetname" );
}
else
{
level.enemy_spawns = getEntArray( init_zombie_spawner_name, "targetname" );
}

level.zombie_rise_spawners = [];

//maps\_destructible_type94truck::init();

level.custom_introscreen = ::zombie_intro_screen;
level.custom_intermission = ::player_intermission;
level.reset_clientdvars = ::onPlayerConnect_clientDvars;

init_fx();


// load map defaults
maps\_load::main();

level.hudelem_count = 0;
// Call the other zombiemode scripts
if( level.script == "nazi_zombie_sumpf" )
{
maps\_zombiemode_weapons_sumpf::init();
}
else
{
maps\_zombiemode_weapons::init();
}
maps\_zombiemode_blockers_new::init();
maps\_zombiemode_spawner::init();
maps\_zombiemode_powerups::init();
maps\_zombiemode_radio::init();
maps\_zombiemode_perks::init();
maps\_zombiemode_tesla::init();
maps\_zombiemode_dogs::init();
maps\_zombiemode_bowie::bowie_init();
maps\_zombiemode_cymbal_monkey::init();
maps\_zombiemode_betty::init();
maps\_zombiemode_timer::init();
maps\_zombiemode_auto_turret::init();
       
        thread function_one();
        thread function_two();


/#
maps\_zombiemode_devgui::init();
#/

init_utility();

// register a client system...
maps\_utility::registerClientSys("zombify");

// level thread coop_player_spawn_placement();

// zombie ai and anim inits
init_anims();

if( isDefined( level.custom_ai_type ) )
{
for( i = 0; i < level.custom_ai_type.size; i++ )
{
[[ level.custom_ai_type[i] ]]();
}
}


// Sets up function pointers for animscripts to refer to
level.playerlaststand_func = ::player_laststand;
// level.global_kill_func = maps\_zombiemode_spawner::zombie_death;
level.global_damage_func = maps\_zombiemode_spawner::zombie_damage;
level.global_damage_func_ads = maps\_zombiemode_spawner::zombie_damage_ads;
level.overridePlayerKilled = ::player_killed_override;
level.overridePlayerDamage = ::player_damage_override;

level.melee_miss_func = maps\_zombiemode::zombiemode_melee_miss;

if( !IsDefined( level.Player_Spawn_func ) )
{
level.Player_Spawn_func = ::coop_player_spawn_placement;
}

level thread [[level.Player_Spawn_func]]();
// used to a check in last stand for players to become zombies
level.is_zombie_level = true;
level.player_becomes_zombie = ::zombify_player;

// so we dont get the uber colt when we're knocked out
level.laststandpistol = "colt";

level.round_start_time = 0;

level thread onPlayerConnect();

init_dvars();
initZombieLeaderboardData();


flag_wait( "all_players_connected" );

bbPrint( "sessions: mapname %s gametype zom isserver 1", level.script );



//thread zombie_difficulty_ramp_up();

// Start the Zombie MODE!
level thread end_game();
level thread round_start();
level thread players_playing();
if ( IsDefined( level.crawlers_enabled ) && level.crawlers_enabled == 1 )
{
level thread crawler_round_tracker();
}

//chrisp - adding spawning vo
level thread spawn_vo();

//add ammo tracker for VO
level thread track_players_ammo_count();

//level thread prevent_near_origin();

DisableGrenadeSuicide();

level.startInvulnerableTime = GetDvarInt( "player_deathInvulnerableTime" );

// Do a SaveGame, so we can restart properly when we die
SaveGame( "zombie_start", &"AUTOSAVE_LEVELSTART", "", true );

// TESTING
// wait( 3 );
// level thread intermission();
// thread testing_spawner_bug();

if(!IsDefined(level.eggs) )
{
level.eggs = 0;
}
}

player_damage_override( eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, modelIndex, psOffsetTime )
{
/*
if(self hasperk("specialty_armorvest") && eAttacker != self)
{
iDamage = iDamage * 0.75;
iprintlnbold(idamage);
}*/

if( sMeansOfDeath == "MOD_FALLING" )
{
sMeansOfDeath = "MOD_EXPLOSIVE";
}

if( isDefined( eAttacker ) )
{
if( isDefined( self.ignoreAttacker ) && self.ignoreAttacker == eAttacker )
{
return;
}

if( isDefined( eAttacker.is_zombie ) && eAttacker.is_zombie )
{
self.ignoreAttacker = eAttacker;
self thread remove_ignore_attacker();
}

if( isDefined( eAttacker.damage_mult ) )
{
iDamage *= eAttacker.damage_mult;
}
eAttacker notify( "hit_player" );
}
finalDamage = iDamage;

if( sMeansOfDeath == "MOD_PROJECTILE" || sMeansOfDeath == "MOD_PROJECTILE_SPLASH" || sMeansOfDeath == "MOD_GRENADE" || sMeansOfDeath == "MOD_GRENADE_SPLASH" )
{
if( self.health > 75 )
{
finalDamage = 75;
self maps\_callbackglobal::finishPlayerDamageWrapper( eInflictor, eAttacker, finalDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, modelIndex, psOffsetTime );
return;
}
}

if( iDamage < self.health )
{
if ( IsDefined( eAttacker ) )
{
eAttacker.sound_damage_player = self;
}

//iprintlnbold(iDamage);
self maps\_callbackglobal::finishPlayerDamageWrapper( eInflictor, eAttacker, finalDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, modelIndex, psOffsetTime );
return;
}
if( level.intermission )
{
level waittill( "forever" );
}

players = get_players();
        level.countplayerdown = 0;
for( i = 0; i < players.size; i++ )
{
if( players[i] == self || players[i].is_zombie || players[i] maps\_laststand::player_is_in_laststand() || players[i].sessionstate == "spectator" )
{
level.countplayerdown++;
}
}

if( level.countplayerdown < players.size )
{
self maps\_callbackglobal::finishPlayerDamageWrapper( eInflictor, eAttacker, finalDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, modelIndex, psOffsetTime );
return;
}

self.intermission = true;

self thread maps\_laststand::PlayerLastStand( eInflictor, eAttacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, psOffsetTime );
self player_fake_death();

if( level.countplayerdown == players.size )
{
level notify( "end_game" );         

}
else
{
self maps\_callbackglobal::finishPlayerDamageWrapper( eInflictor, eAttacker, finalDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, modelIndex, psOffsetTime );
}
}

function_one()
{
 
        trigger = GetEnt("random_one","targetname");

        level.start = false;

        level.trigger_one_count = 0;

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

                  if( level.countplayerdown == level.players_playing )
                  {
                       level.start = true;
                       
                       break;
                  }
                 
              level.trigger_one_count++;

              wait ( .5 );
        }
}

function_two()
{

        trigger1 = GetEnt("random_two","targetname");

        level.start_two = false;
       
        level.trigger_two_count = 0;
       
        while (1)
        {
             trigger1 waittill ( "trigger" , player);
                 
                  if( level.countplayerdown == level.players_playing )
                  {
                       level.start_two = true;
                       
                       break;
                  }
             
             level.trigger_two_count++;

             wait ( .5 );
        }

}

end_game()
{
level waittill ( "end_game" );

level.intermission = true;

update_leaderboards();

game_over = NewHudElem( self );
game_over.alignX = "center";
game_over.alignY = "middle";
game_over.horzAlign = "center";
game_over.vertAlign = "middle";
game_over.y -= 10;
game_over.foreground = true;
game_over.fontScale = 3;
game_over.alpha = 0;
game_over.color = ( 1.0, 1.0, 1.0 );
game_over SetText( &"ZOMBIE_GAME_OVER" );

game_over FadeOverTime( 1 );
game_over.alpha = 1;

survived = NewHudElem( self );
survived.alignX = "center";
survived.alignY = "middle";
survived.horzAlign = "center";
survived.vertAlign = "middle";
survived.y += 20;
survived.foreground = true;
survived.fontScale = 2;
survived.alpha = 0;
survived.color = ( 1.0, 1.0, 1.0 );

if( level.round_number < 2 )
{
survived SetText( &"ZOMBIE_SURVIVED_ROUND" );
}
else
{
survived SetText( &"ZOMBIE_SURVIVED_ROUNDS", level.round_number );
}
//TUEY had to change this since we are adding other musical elements


        If( level.start == true && level.start_two == false )
        { // Here is the error
            setmusicstate("music_one");
        }

        If( level.start == false && level.start_two == true )
        {
            setmusicstate("music_two");
        }
           
        If( level.start == true && level.start_two == true && level.trigger_two_count < level.trigger_one_count )
        {
            setmusicstate("music_one");
        }       

        If( level.start == true && level.start_two == true && level.trigger_two_count > level.trigger_one_count )
        {
            setmusicstate("music_two");
        }

        If( level.start == true && level.start_two == true && level.trigger_two_count == level.trigger_one_count )
        {
            setmusicstate("end_of_game");
        }       

//setmusicstate("end_of_game");
//setbusstate("default");

survived FadeOverTime( 1 );
survived.alpha = 1;

wait( 1 );

//play_sound_at_pos( "end_of_game", ( 0, 0, 0 ) );
wait( 2 );
intermission();

wait( level.zombie_vars["zombie_intermission_time"] );

level notify( "stop_intermission" );
array_thread( get_players(), ::player_exit_level );

bbPrint( "zombie_epilogs: rounds %d", level.round_number );

wait( 1.5 );

if( is_coop() )
{
ExitLevel( false );
}
else
{
MissionFailed();
}



// Let's not exit the function
wait( 666 );
}

I had to modify the post, because it will not show the content, only I posted the modifications that I did in the script.
broken avatar :(
  • DeletedUser
  • Deleted Member
×
broken avatar :(
DeletedUser
This user is deleted :(
can anyone help me?
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 11 March 2014
Last active: 3 years ago
Posts
264
Respect
Forum Rank
Mr. Elemental
Primary Group
Member
Signature
"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."
×
buttkicker845's Groups
buttkicker845's Contact & Social Links
not positive since ive never tried to do capitalized operators but I do know in other languages the operators are case sensitive and using a capital I in an if statement would not be recognized as an operator.

try replacing your
Code Snippet
Plaintext
        If( level.start == true && level.start_two == false )
        { // Here is the error
            setmusicstate("music_one");
        }

        If( level.start == false && level.start_two == true )
        {
           
with
Code Snippet
Plaintext
        if( level.start == true && level.start_two == false )
        { // Here is the error
            setmusicstate("music_one");
        }

        if( level.start == false && level.start_two == true )
        {

 
Loading ...