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

Members Online

»
0 Active | 79 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: Usefull scripts
BraX
General Member
Since: Apr 29, 2008
Posts: 413
Last: May 26, 2012
[view latest posts]
Level 5
Im a fan of MODSonair
Category: CoD4 Scripting
Posted: Thursday, May. 12, 2011 12:26 pm
NOTICE!
These scripts are only adding functionality into game. They do not add things such as mines, artillery, kaboom etc...
I've copied some usefull functions from my mods here to help newbies making new mods.

Returns array of all players on the server.
Code:
getAllPlayers()
{
	return getEntArray( "player", "classname" );
}


Play local sound on all players.
Code:
playSoundOnAllPlayers( soundAlias )
{
	players = getAllPlayers();
	for( i = 0; i < players.size; i++ )
	{
		players[i] playLocalSound( soundAlias );
	}
}


Removes all text messages from screen.
Code:
cleanScreen()
{
	for( i = 0; i < 6; i++ )
	{
		iPrintlnBold( " " );
		iPrintln( " " );
	}
}


Delete object after time.
Code:
deleteAfterTime( time )
{
	wait time;
	if( isDefined( self ) )
		self delete();
}


Return BOOL (true of false) when player is really alive and playing. CoD's isAlive() function seems to be bugged.
Code:
isReallyAlive()
{
	if( self.sessionstate == "playing" )
		return true;
	else
		return false;
}

isPlaying()
{
	return isReallyAlive();
}


Toggle third person camera.
Code:
thirdPerson()
{
	if( !isDefined( self.tp ) )
	{
		self.tp = true;
		self setClientDvar( "cg_thirdPerson", 1 );
	}
	else
	{
		self.tp = undefined;
		self setClientDvar( "cg_thirdPerson", 0 );
	}
}


Waits for enough players to start game.
Code:
// Use: waitForPlayers( 3 ); Code after this function call will be executed when there is required number of alive players.
waitForPlayers( requiredPlayersCount )
{
	quit = false;
	while( !quit )
	{
		wait 0.5;
		count = 0;
		players = getAllPlayers();
		for( i = 0; i < players.size; i++ )
		{
			if( players[i] isPlaying() )
				count++;
		}

		if( count >= requiredPlayersCount )
			break;
	}
}


Return player with that nick name or its part.
Code:
getPlayerByName( nickname ) 
{
	players = getAllPlayers();
	for ( i = 0; i < players.size; i++ )
	{
		if ( isSubStr( toLower(players[i].name), toLower(nickname) ) ) 
		{
			return players[i];
		}
	}
}


Return player with that slot number.
Code:
getPlayerByNum( pNum ) 
{
	players = getAllPlayers();
	for ( i = 0; i < players.size; i++ )
	{
		if ( players[i] getEntityNumber() == pNum ) 
			return players[i];
	}
}


Return true when victim was killed through world geometry.
Code:
isWallBang( attacker, victim )
{
	start = attacker getEye();
	end = victim getEye();
	if( bulletTracePassed( start, end, false, attacker ) )
		return false;
	return true;
}


Feel free to use these functions in your own mod.
Just remember to put me in credits.
Share |
zeroy
General Member
Since: Nov 26, 2007
Posts: 1060
Last: Mar 12, 2014
[view latest posts]
Level 8
Category: CoD4 Scripting
Posted: Thursday, May. 12, 2011 04:23 pm
thanks Brax, always useful those scripts :)

I would also encourage modders to actually look through file like /raw/maps/mp/_utility.gsc and others stock scripts, they are full of those little useful functions.


Share |
IzNoGoD
General Member
Since: Nov 29, 2008
Posts: 694
Last: Nov 10, 2012
[view latest posts]
Level 6
Category: CoD4 Scripting
Posted: Friday, May. 13, 2011 07:32 pm
is bullettracepassed() scripted like this?
Code:

bullettracepassed(start,end,hitplayers,ignore_ent)
{
trace=bullettrace(start,end,hitplayers,ignore_ent);
if(trace["fraction"]==1) return true;
else return false;
}

?
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

»