UGX-Mods

Call of Duty 5: World at War => Help Desk => Scripting => Topic started by: HyperFirez on January 04, 2017, 01:16:55 am

Title: Functions not threading properly.
Post by: HyperFirez on January 04, 2017, 01:16:55 am
Yet another problem with my Gobblegum script... When I call the "gumball" function, (that is where it picks a random number and gives you the gumball),  it picks a random number, but doesn't thread the gobblegum that it chose. Script (Simplified) (http://paste.md-5.net/kapinakebi.mel)

Double Post Merge: January 04, 2017, 03:04:36 am
Also, even though I have a playable area trigger, the powerups from the "Kill Joy", "Dead of Nuclear Winter", etc... Doesn't spawn them anymore.
Title: Re: Functions not threading properly.
Post by: death_reaper0 on January 04, 2017, 06:54:57 am
Yet another problem with my Gobblegum script... When I call the "gumball" function, (that is where it picks a random number and gives you the gumball),  it picks a random number, but doesn't thread the gobblegum that it chose. Script (Simplified) (http://paste.md-5.net/kapinakebi.mel)

Double Post Merge: January 04, 2017, 03:04:36 am
Also, even though I have a playable area trigger, the powerups from the "Kill Joy", "Dead of Nuclear Winter", etc... Doesn't spawn them anymore.

would it have anything to do with nothing is defined for threading it, therefor is not defining the player to do the effect?
things like
Code Snippet
Plaintext
 thread gumball();

should be
Code Snippet
Plaintext
player thread gumball();

then in the thread gumball()
Code Snippet
Plaintext

gumball()
{
    gum = RandomIntRange( 0,4 ); // <min value>, <max value> | zero counts as a number!

    switch( gum )
    {
        case 0:
  iprintln("Case 0");
  player thread anywhere_but_here();
          break;

case 1:
  iprintln("Case 1");
  player thread dead_of_nuclear_winter();
  break;

case 2:
  iprintln("Case 2");
  player thread cache_back();
  break;

case 3:
  iprintln("Case 3");
  player thread kill_joy();
  break;

        default:
            break;
    }
}




Double Post Merge: January 04, 2017, 06:59:39 am
Code Snippet
Plaintext

cache_back()
{
//iprintln("cache_back function activated");
for ( i = 0; i < level.zombie_powerup_array.size; i++ )
{
if ( level.zombie_powerup_array[i] == "full_ammo" )
{
level.zombie_powerup_index = i;
break;
}
}

player = get_players();
level.zombie_vars["zombie_drop_item"] = 1;
level.powerup_drop_count = 0;
wait(1);
level thread maps\_zombiemode_powerups::powerup_drop(player.origin + (100, 0, 10));
}


also theres nothing defining the player here, you have it getting an array of all players then dropping it at that spot, which idek how that would work. change the powerup funcions to something like this

Code Snippet
Plaintext

cache_back()
{
//iprintln("cache_back function activated");
for ( i = 0; i < level.zombie_powerup_array.size; i++ )
{
if ( level.zombie_powerup_array[i] == "full_ammo" )
{
level.zombie_powerup_index = i;
break;
}
}
level.zombie_vars["zombie_drop_item"] = 1;
level.powerup_drop_count = 0;
wait(1);
level thread maps\_zombiemode_powerups::powerup_drop(self.origin + (100, 0, 10));
}

Title: Re: Functions not threading properly.
Post by: HyperFirez on January 04, 2017, 01:36:58 pm
When I put player thread in the gumball() function, it says that it is an uninitialized variable...
Title: Re: Functions not threading properly.
Post by: death_reaper0 on January 04, 2017, 07:27:44 pm
When I put player thread in the gumball() function, it says that it is an uninitialized variable...
oh my bad, when a script is called by a player, self is whats used to thread other threads, so chnage all the players in gumball to self
Title: Re: Functions not threading properly.
Post by: HyperFirez on January 04, 2017, 11:21:02 pm
oh my bad, when a script is called by a player, self is whats used to thread other threads, so chnage all the players in gumball to self
When is player used?
Title: Re: Functions not threading properly.
Post by: death_reaper0 on January 05, 2017, 07:27:29 am
well theres lots of things that can define the player, for example:

if you have a trigger to be activated by a player you would normally have something like
Code Snippet
Plaintext
      gumball_machine waittill("trigger", player);

this tells the script that whoever activates the trigger, will be defined as "player" for the rest of that function, or untill that line is reintroduced. it doesnt have to be called "player" either, you can have it as anything you want but id recommend something thats easy to understand, like player or user. if a player is used to call a function like
Code Snippet
Plaintext
player thread function_name();

inside that function the player will be defined as "self" so if you want the player that called that thread to do something, have it as "self do_something()" instead of player.

theres a lot of things to learn for this,  so i dont really have the time to go through them all, but from the look of your script you shouldnt need any other way just yet (you will probably need it for some of the gumball effects)
Title: Re: Functions not threading properly.
Post by: HyperFirez on January 05, 2017, 01:37:59 pm
Thanks again. Also thanks for the mini tutorial.  :P