Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
https://roderickvella.wordpress.com
Mission Objectives
Welcome to your fifth mission. In this
mission we are going to learn how to
use if conditions and random
numbers.
If/Else Statements
The if Statement
my_num = 5;
if( my_num == 5 )
{
self IprintLnBold( "The number is five!" );
}
else
{
self IprintLnBold( "The number is NOT five!" );
}
The if Statement
my_name = "John";
if(my_name == "John" )
{
self IprintLnBold("Name is John");
}
else
{
self IprintLnBold("Name is not John");
}
Switch Blocks
my_number = 5;
switch( my_number )
{
case 5:
self IprintLnBold(
break;
case 6:
self IprintLnBold(
break;
case 7:
self IprintLnBold(
break;
default:
self IprintLnBold(
break;
}
Random Numbers
RandomInt( <max> )
Returns a random integer between 0 and max-1
inclusive
myRandomValue = RandomInt(5);
Step 1
Create a new mod like we did in Mission
3 and name it Mission 5
Step 2
myRandomValue
Line 122
RandomInt(3)
Line 124
if(myRandomValue == 0)
Line 126
Line 127
iPrintlnBold("^2Jumping
Not Allowed");
Line 128
AllowJump(false)
Line 133
AllowSprint(false);
Line 138
self AllowAds(false);
Step 3
Practical Tasks
Mission 5 Task 1
Create the same MOD we did in Mission 5
Prog 1. This time use a Switch instead of an If
statement. Test it with your friends.
Mission 5 Task 2
Create a MOD that checks your name.
IF your name is GODMODE THEN
1. On the screen the following message
should appear: You are in
GODMODE
2. The player should have a lot of health.
ELSE
1. On the screen the following message
should appear: You are not in
GODMODE
Mission 5 Task 2
Hint: Use the below code for maximum health:
self.maxhealth = 90000;
self.health = self.maxhealth;
Mission 5 Task 2
Testing: Change your name to GODMODE
Mission 5 Task 2
Testing: Test your code by throwing a grenade at
yourself
Mission 5 Task 2
Testing: Play against your friends and test your
new abilities.