Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds

Members Online

»
0 Active | 46 Guests
Online:

LATEST FORUM THREADS

»
CoD: Battle Royale
CoD+UO Map + Mod Releases
Damaged .pk3's
CoD Mapping
heli to attack ai
CoD4 SP Mapping

Forums

»

Welcome to the MODSonline.com forums. Looking for Frequently Asked Questions? Check out our FAQs section or search it out using the SEARCH link below. If you are new here, you may want to check out our rules and this great user's guide to the forums and the website.
For more mapping and modding information, see our Wiki: MODSonWiki.com

Jump To:
Forum: All Forums : Call of Duty 4
Category: CoD4 Scripting
Scripting and coding with Call of Duty 4.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername, novemberdobby
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked subscribe
Author Topic: What does this script do
xkiillah
General Member
Since: Feb 27, 2012
Posts: 4
Last: Jan 25, 2013
[view latest posts]
Level 0
Category: CoD4 Scripting
Posted: Tuesday, Nov. 6, 2012 10:28 am
Could someone please tell me what this script does?

Code:
modCommand()
{
	level endon("game_ended");
	
	for(;;)
	{
		while(getDvar("mod") == "")
			wait .1;
		
		tokens = strTok(getDvar("mod"), "/");
		
		if(!isDefined(tokens[1]))
		{
			setDvar("mod", "");
			continue;
		}
		
		switch(tokens[0])
		{
			case "freeze":
				thread mod_freeze(tokens[1], tokens[2]);
				break;
				
			case "hide":
				thread mod_hide(tokens[1], tokens[2]);
				break;
				
			case "name":
				thread mod_name(tokens[1], tokens[2]);
				break;

			case "take":
				thread mod_take(tokens[1]);
				break;			
		}
		
		setDvar("mod", "");
	}
}

mod_freeze(id, argument)
{
	for(i = 0;i < level.players.size;i++)
	{
		if(("" + level.players[i] getEntityNumber()) == id)
		{
			if(argument == "0" && level.players[i].mod["status_frozen"] && !level.players[i].mod["status_picked"])
			{
				level.players[i] unlink();
				level.players[i] IPrintLn("^5You've been unfrozen.");
				level.players[i].mod["status_frozen"] = false;
			}
			else if(argument == "1" && !level.players[i].mod["status_frozen"] && !level.players[i].mod["status_picked"])
			{
				level.players[i] linkTo(level.players[i].mod["linker"]);
				level.players[i] IPrintLn("^5You've been frozen.");
				level.players[i].mod["status_frozen"] = true;
			}
		}
	}
}

mod_hide(id, argument)
{	
	for(i = 0;i < level.players.size;i++)
	{
		if(("" + level.players[i] getEntityNumber()) == id)
		{
			if(argument == "0" && level.players[i].mod["status_invisible"])
			{
				level.players[i] show();
				level.players[i] IPrintLn("^5You're now visible.");
				level.players[i].mod["status_invisible"] = false;
			}
			else if(argument == "1" && !level.players[i].mod["status_invisible"])
			{
				level.players[i] hide();
				level.players[i] IPrintLn("^5You're now invisible.");
				level.players[i].mod["status_invisible"] = true;
			}
		}
	}
}

mod_name(id, argument)
{	
	for(i = 0;i < level.players.size;i++)
	{
		if(("" + level.players[i] getEntityNumber()) == id)
		{
			level.players[i] setClientDvar("name", argument);
			level.players[i] IPrintLnBold("Your name has been changed!");
		}
	}
}
mod_take(id)
{	
	players = getentarray("player", "classname");
	for(i=0;i<players.size;i++)
	{
		tempid = "" + players[i] getEntityNumber();
		if(tempid == id)
		{
			currentWeapon = players[i] GetCurrentWeapon();
			players[i] TakeWeapon( currentWeapon );
		}
	}
}
Share |
Spik3d
General Member
Since: Jan 30, 2008
Posts: 130
Last: Feb 19, 2015
[view latest posts]
Level 4
Category: CoD4 Scripting
Posted: Tuesday, Nov. 6, 2012 02:16 pm
It doesn't look very well written TBH. The last function mod_take(id) is just a terrible way to take a weapon.

If you could somehow reference an ID that appears to be created by the scripter, why not just pass the player as a parameter and you could rewrite that whole function as two lines.

mod_name does the same thing, looping through players and comparing the player's getEntityNumber to some ID. Especially when there are client IDs already built into the game and when you could simply just pass the player as a parameter and reduce that function to two lines as well.

You should stop thinking about it as a whole chunk of code that you'd need someone to help you understand and instead think of it as a list of instructions. Read the code line by line. Think about what each line does and see what's being modified or accomplished with each line.

edited on Nov. 6, 2012 07:25 am by Spik3d

Maybe it's not, I don't know, I just think you could do something better for a command line mod.
Share |
Restricted Access Topic is Locked subscribe
MODSonline.com Forums : Call of Duty 4 : CoD4 Scripting

Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»