Sign in to follow this  
Followers 0
Ali Sajjad

Mini games for map!

5 posts in this topic

Hello.

So, here's the mini game script for mappers who want mini games in their map.

Script:

EndRooms()
{
level.endroom = [];
level.playerinroom = 0;
thread AddRoom("Snipe Room","trigger_sniper","sniper_jumper","sniper_activator","remington700_mp","max",0,0);
thread AddRoom("Old Room","trigger_old","old_jumper",undefined,undefined,undefined,1,1);
}
AddRoom(roomname,trig,tele_jumper,tele_activator,weap,ammo,old,rush)
{
if(!isDefined(old) || !old)
	level.endroom[level.endroom.size] = getEnt(trig,"targetname");
while( 1 )
{
	if(DefinedEntities(trig,tele_jumper))
	{
		getEnt(trig,"targetname") waittill("trigger",player);
		if(level.playerinroom)
			continue;
		if(isDefined(old) && old)
		{
			for(i=0;i< level.endroom.size;i++)
			{
				if(isDefined(level.endroom[i]))
					level.endroom[i] delete();
			}
		}
		if(isDefined(level.activ))
			if(player == level.activ)
				continue;
		level.playerinroom = 1;
		if(isDefined(player) && isAlive(player))
		{
			player setOrigin(getEnt(tele_jumper,"targetname").origin);
			player setPlayerAngles(getEnt(tele_jumper,"targetname").angles);
			if(!isDefined(old) || !old)
			{
				player takeAllWeapons();
			}
			if(isDefined(weap) && isDefined(ammo))
			{
				player giveWeapon(weap);
				if(ammo == "max")
					player giveMaxAmmo( weap );
				else
					player setWeaponAmmoClip( weap, ammo );
				player switchToWeapon( weap );
			}
		}
		if(isDefined(level.activ) && isAlive(level.activ))
		{
			if(isDefined(tele_activator))
			{
				level.activ setOrigin(getEnt(tele_activator,"targetname").origin);
				level.activ setPlayerAngles(getEnt(tele_activator,"targetname").angles);
			}
			if(!isDefined(old) || !old)
			{
				level.activ takeAllWeapons();
			}
			if(isDefined(weap) && isDefined(ammo))
			{
				level.activ giveWeapon(weap);
				if(ammo == "max")
					level.activ giveMaxAmmo( weap );
				else
					level.activ setWeaponAmmoClip( weap, ammo );
				level.activ switchToWeapon( weap );
			}
		}
		iprintlnBold(Player.name + " Entered in " + roomname);
		if(!rush)
			WaitForDeath(player);
		level.playerinroom = 0;
	}
	else
	{
		printLn("Check Endrooms entities!");
		return;
	}
}
}
DefinedEntities(trig,tele_jumper)
{
if(!isDefined(trig) || !isDefined(tele_jumper))
	return 0;
return 1;
}
WaitForDeath(player)
{
player waittill("death");
}

Intructions:

1)For weapons you have to precache them at the start of your script.

2)you have to add this at main function:

thread EndRooms();

3) Too add endrooms you have to copy one line from EndRooms() function then paste it below

The syntax of it is:

thread AddRoom("Name of the room","trigger of the room","origin entity for the jumper","origin entity for the Activator(if old type undefined without "")","weapon name(type undefined without "" if old)",ammo number(type undefined without "" if old),if this endroom is old then type 1 else 0,if you want rush in this endroom then type 1 else 0);

4)Explaination:

EndRooms() //the main function of this script
{
level.endroom = [];
level.playerinroom = 0; //define a var which will be used for turning.
thread AddRoom("Snipe Room","trigger_sniper","sniper_jumper","sniper_activator","remington700_mp","max",0,0); //adds new room
thread AddRoom("Old Room","trigger_old","old_jumper",undefined,undefined,undefined,1,1); //same as above
}
AddRoom(roomname,trig,tele_jumper,tele_activator,weap,ammo,old,rush)
{
if(!isDefined(old) || !old) //checks if var 'old' is defined or this var is false.If not it will exec next line
	level.endroom[level.endroom.size] = getEnt(trig,"targetname"); //defines a array var which will be used for deleting it when player picks old endroom
while( 1 ) //while loop 
{
	if(DefinedEntities(trig,tele_jumper)) //checks if required triggers are defined or not.
	{
		getEnt(trig,"targetname") waittill("trigger",player); //waits for player entity to trigger it.
		if(level.playerinroom) //var which is defined above, checks if player is in room or not. if this var is 1(true) cod4 will exec the below "continue" command else cod4 won't.
			continue; //stops further script then continues loop
		if(isDefined(old) && old) 
		{
			for(i=0;i< level.endroom.size;i++) //For loop for(set var;expression,steps)
			{
				if(isDefined(level.endroom[i])) //if statement, checks if current array var 'level.endroom' is defined 
					level.endroom[i] delete(); //if it's defined then deletes it because it can make bug when another player picks some other room than old.
			}
		}
		level.playerinroom = 1; //defines if player is in room.
		if(isDefined(player) && isAlive(player)) //checks if player who triggered is defined&alive
		{
			player setOrigin(getEnt(tele_jumper,"targetname").origin); //sets new player origin of player
			player setPlayerAngles(getEnt(tele_jumper,"targetname").angles); //sets player angle
			if(!isDefined(old) || !old) //checks if it is old endroom or not. if no then it will exec  below command.
			{
				player takeAllWeapons(); // takes all weapon ofc
			}
			if(isDefined(weap) && isDefined(ammo)) //checks if var 'weap' isDefined
			{
				player giveWeapon(weap); //gives 'weap' to player
				if(ammo == "max")	//statement which checks var 'ammo' is equal to max if 1 then cod4 exec below command
					player giveMaxAmmo( weap ); //gives max ammo of 'weap' to player
				else 	//if 0 then cod4 exec below command
					player setWeaponAmmoClip( weap, ammo ); //gives some specific ammount of ammo to player syntax is playerentity setWeaponAmmoClip("weapnamestring",ammonumInt)
				player switchToWeapon( weap ); //switches the current weapon with string var 'weap'
			}
		}
		if(isDefined(level.activ) && isAlive(level.activ)) //checks if var 'level.activ' is defined (it's defined by mod every round except free run)
		{
			//NOT GONNA EXPLAIN THIS AGAIN all same but for activator.
			if(isDefined(tele_activator)) 
			{
				level.activ setOrigin(getEnt(tele_activator,"targetname").origin);
				level.activ setPlayerAngles(getEnt(tele_activator,"targetname").angles);
			}
			if(!isDefined(old) || !old)
			{
				level.activ takeAllWeapons();
			}
			if(isDefined(weap) && isDefined(ammo))
			{
				level.activ giveWeapon(weap);
				if(ammo == "max")
					level.activ giveMaxAmmo( weap );
				else
					level.activ setWeaponAmmoClip( weap, ammo );
				level.activ switchToWeapon( weap );
			}
		}
		iprintlnBold(Player.name + " Entered in " + roomname); //shows message on screen
		if(!rush)	//checks if var 'rush' is 0 if it's 0 then cod4 exec next line
			WaitForDeath(player); //function which waits for player to die
		level.playerinroom = 0; //set var to 0 (for turning)
	}
	else //if required endroom entities are not defined then exec lines from "{" to before "}"
	{
		logPrint("Check EndRooms entities!");	//prints msg on log file 
		return;
	}
}
}
DefinedEntities(trig,tele_jumper)
{
if(!isDefined(trig) || !isDefined(tele_jumper)) //checks if var 'trig' or var 'tele_jumper' is not defined
	return 0; //returns false if not defined
return 1; returns true if both vars are defined
}
WaitForDeath(player) 
{
player waittill("death"); //waits for player to die.
}

I've given two example in above code second one is for old and first one is for snipe.

Enjoy!

Thanks to ninja for spamming me to post it.....

0

Share this post


Link to post
Share on other sites
Fearz' pid='366' dateline='1390057618']

Why are you using HTML for cod4? -_-

Nub. ^ ^ I've used

[ /code]. Not my fault if this "PRO" forum use it for html.
0

Share this post


Link to post
Share on other sites

edited title so people can actually see the title as "tutorial" isn't needed because it's quite obvious it's a tutorial if it's in the tutorial section.

0

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  
Followers 0