
Posts
86
Respect
34Add +1
Forum Rank
Rotting Walker
Primary Group
Community Mapper
Login Issues
Forgot password?Activate Issues
Account activation email not received? Wrong account activation email used?Other Problems?
Contact Support - Help Center Get help on the UGX Discord. Join it now!![]() | Has released one or more maps to the UGX-Mods community which have been added to the UGX Map Manager. |
while(condition)notice:
{
IPrintLnBold("Hello");
wait(0.05);
}
while(1)In this example, the line "Are we there yet?" will be printed to the screen every 2 seconds once this while loop is initiated, and will never stop. Just like those damn children.
{
IPrintLnBold("Are we there yet?");
wait(2);
}
times = 0;In the above case the code will run 10 times before it stops, and the code below it can begin. It should be noted that this specific example could probably be better done using a for loop, but we'll talk about that later.
while(times < 10)
{
if(times == 1)
{
IPrintLnBold(times + " minute has passed"); //account for pluralization
}
else
{
IPrintLnBold(times + " minutes have passed");
}
times ++;
wait(60);
}
steve notify("stop_eating_my_sandwich");assuming steve is an already defined variable.
door = GetEnt("specific_magical_door","targetname");notice how you can also use that level variable on notifies, waittills, and endons.
level notify("magic_door_opened", door, (0,0,50));
level notify( "end_of_round" ); //used when round endsThere are definitely more Treyarch notifies than these that you can use, you'll just have to look for them.
level notify( "start_of_round" ); //used when next round starts
level notify( "all_players_connected" ); //used when all players have connected into the game
player notify( "bled_out" ); //used when a player bleeds out, on a specific player
player notify( "player_revived" ); //used when a player is revived, on the revived player
entity notify("death"); //used when some character, such as a player or zombie, dies
entity notify("movedone"); //used when an entity is done moving after being give some sort of move command
player notify("weapon_fired", weapon); //used when a player fires a weapon. also passes the weapon entity
entity notify( "damage", amount, attacker, direction_vec, point, type, tagName, ModelName, Partname, weapon ); //used when an entity takes damage. Passes a whole bunch of useful arguments. Note that you can use this on more than just players/zombies, so long as you use the function SetCanDamage() on the entity first.
trigger notify("trigger", player); //used when a player activates a trigger. Also passes the player who activated it as an argument. VERY USEFUL
steve waittill("stop_eating_my_sandwich");waittills can also accept those useful arguments you may have passed in the notify:
IPrintLnBold("oh, sorry");
level waittill("magic_door_opened", entity, vector);but perhaps one of the most used waittills is for waiting until a use_trigger is triggered:
entity MoveTo(entity.origin + vector, 5);
trig = GetEnt("button_trig","targetname");The code above is a good example of how while loops and waittills can work together, in this case in what is known as a purchase loop.
trig SetHintString( "Press and Hold ^3[{+activate}]^7 to Press Button [Cost: 500 ]");
trig.activated = false;
while(trig.activated == false)
{
trig waittill("trigger", player);
if(player.score >= 500)
{
player zm_score::minus_to_player_score( 500 );
trig.activated = true;
}
else
{
IPrintLnBold("You need some more cash");
}
}
IPrintLnBold("Button Activated");
level endon("intermission");In the example above, I have two different endons, placed above my while loop. for the first one, the while loop will break when game ends, and the level variable is given the "intermission" notify. For the second one, if the player is given the notify "death" (which should automatically happen when a player dies), the while loop will also break.
player endon("death");
while(1)
{
if(player IsTouching(trigger))
{
player zm_score::add_to_player_score( 10 );
wait(0.95);
}
wait(0.05);
}