Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tutorial Intermediate RandomInt switch/Thread's
#1
Information 
this is a follow on from my tut here
today we will see two examples of RandomInt switch first random killstreaks on spawn then death messages and alittle explanation at the end

Lets start

Like before we start by makeing a thread called randomstuff in OnPlayerSpawned like so
Code:
onPlayerSpawned()
{
    self endon("disconnect");

    for(;;)
    {
        self waittill("spawned_player");
self thread randomstuff();

   }
}
then our thread
Code:
randomstuff()
{
    switch(RandomInt(15))
    {
        case 0:
            self.randomKillstreak = "radar_mp";
        break;
        case 1:
            self.randomKillstreak = "counteruav_mp";
        break;
        case 2:
            self.randomKillstreak = "tow_turret_drop_mp";
        break;
        case 3:
            self.randomKillstreak = "supplydrop_mp";
        break;
        case 4:
            self.randomKillstreak = "turret_drop_mp";
        break;
        case 5:
            self.randomKillstreak = "mortar_mp";
        break;
        case 6:
            self.randomKillstreak = "napalm_mp";
        break;
        case 7:
            self.randomKillstreak = "rcbomb_mp";
        break;
        case 8:
            self.randomKillstreak = "helicopter_mp";
        break;
        case 9:
            self.randomKillstreak = "radardirection_mp";
        break;
        case 10:
            self.randomKillstreak = "m220_tow_drop_mp";
        break;
        case 11:
            self.randomKillstreak = "airstrike_mp";
        break;
        case 12:
            self.randomKillstreak = "helicopter_gunner_mp";
        break;
        case 13:
            self.randomKillstreak = "helicopter_player_firstperson_mp";
        break;
        case 14:
            self.randomKillstreak = "dogs_mp";
        break;
    }
        self maps\mp\gametypes\_hardpoints::giveKillstreak(self.randomKillstreak );

}
and now death message's

this time we are going to call our thread randommessage after death
Code:
onPlayerSpawned()
{
    self endon("disconnect");

    for(;;)
    {
        self waittill("spawned_player");
  
            
self waittill("death");    
self thread maps\mp\gametypes\_hud::fadeToBlackForXSec( 0.0, 4, 0, 1 );
                      
self thread randommessage();

   }
}
and the randomswitch
Code:
randommessage ()
{
    switch(RandomInt(15))
    {
        case 0:
            self.randommessage = "^1A man's dying is more the survivors' affair than his own.";
        break;
        case 1:
            self.randommessage = "^1If the enemy is in range, so are you.";
        break;
        case 2:
            self.randommessage = "^1War does not determine who is right - only who is left.";
        break;
        case 3:
            self.randommessage = "^1Never forget that your weapon was made by the lowest bidder.";
        break;
        case 4:
            self.randommessage = "^1Teamwork is essential, it gives them other people to shoot at";
        break;
        case 5:
            self.randommessage = "^1For death begins with life's first breath And life begins at touch of death";
        break;
        case 6:
            self.randommessage = "^1All that is necessary for evil to succeed is for good men to do nothing";
        break;
        case 7:
            self.randommessage = "^1If you can't remember, the claymore is pointed toward you.";
        break;
        case 8:
            self.randommessage = "^1It is a blessing to die for a cause, because you can so easily die for nothing.";
        break;
        case 9:
            self.randommessage = "^1Older men declare war. But it's the youth who must fight and die";
        break;
        case 10:
            self.randommessage = "^1When you have to kill a man it costs nothing to be polite.";
        break;
        case 11:
            self.randommessage = "^1Death takes the good, too good to stay, And leaves the bad, too bad to take away";
        break;
        case 12:
            self.randommessage = "^1use emotion for the many and reserve reason for the few";
        break;
        case 13:
            self.randommessage = "^1Battle is an orgy of disorder.";
        break;
        case 14:
            self.randommessage = "^1There is no glory in battle worth the blood it costs";
        break;
    }
        self iPrintlnBold( self.randommessage );

}
now lets break it down
Code:
switch(RandomInt(15))
is the random switch of 15 starting with case 0: ending on case 14:
and after the last break; is what what want to do ie
Code:
break;
    }
        self iPrintlnBold( self.randommessage );

}
OR
        break;
    }
        self maps\mp\gametypes\_hardpoints::giveKillstreak(self.randomKillstreak );

}
as always hope this helps someone learn xD as im am still verymuch a learner myself
credit's: iAegle for helping a noob Smile
Reply

#2
nice tut man keep it up
Reply

#3
thanks i plan to xD
Reply

#4
Well explained tutorial, keep it up.
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
Shocked [Request] Switch plugin axel-le-meilleur 6 4,663 10-19-2013, 06:59
Last Post: iRoNinja
  Thread removed [HARD] Tony. 4 3,464 10-01-2013, 17:53
Last Post: DidUknowiPwn
  Help Thread removed [HARD] Tony. 5 3,664 09-26-2013, 20:26
Last Post: Casper
  Thread removed [HARD] Tony. 3 2,696 09-22-2013, 16:23
Last Post: d0h!
  Thread removed [HARD] Tony. 2 2,371 09-20-2013, 18:03
Last Post: [HARD] Tony.
  Thread removed [HARD] Tony. 3 2,849 09-20-2013, 16:00
Last Post: Nekochan
  Help Official Teckno Gods Thread [Stickied] aceed 3 3,052 08-27-2013, 16:55
Last Post: SuperNovaAO
  Help Easiest Way To Thread a Display Icon? DidUknowiPwn 1 2,076 01-04-2013, 13:02
Last Post: Yamato
  Official moron thread AZUMIKKEL 127 46,991 10-14-2012, 21:13
Last Post: kokole
  FUT Team sharing thread iAegle 2 2,357 10-09-2012, 12:45
Last Post: iAegle

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.