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

Members Online

»
0 Active | 98 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
Page
Previous Page Next Page
subscribe
Author Topic: Weapons to specified ppl (GUID)
LiQ.HeaDShOt
General Member
Since: Jun 1, 2010
Posts: 51
Last: Feb 21, 2011
[view latest posts]
Level 3
Category: CoD4 Scripting
Posted: Wednesday, Aug. 4, 2010 02:20 pm
Xylozi writes...
Quote:
To add a second weapon would require a little re-scripting, so if you just listed all the weapons you want given, I can add it to the script.


hmm..
well its:

rpd_mp
m14_mp
m4_mp

and later i would like to add some other weapons..
if it is a little complex, plz rescript it and comment the script so I can guide myself through the comments xD

Thanks again :D
Share |
LiQ.HeaDShOt
General Member
Since: Jun 1, 2010
Posts: 51
Last: Feb 21, 2011
[view latest posts]
Level 3
Category: CoD4 Scripting
Posted: Sunday, Aug. 8, 2010 11:34 pm
Hey Xylozi..
Can you give me the script that allows the players get several weapons? plz.

Thanks for helping me :D
Great Work m8
Share |
LiQ.HeaDShOt
General Member
Since: Jun 1, 2010
Posts: 51
Last: Feb 21, 2011
[view latest posts]
Level 3
Category: CoD4 Scripting
Posted: Wednesday, Aug. 11, 2010 07:53 pm
Hey every1 again.
Since nobody helped me with the rescripting, i tried to rescript it myself!
I changed the comments for what i want the script to do (at least the idea is there [lol]) and added/deleted some unwanted lines.

Code:

setupWeapons()
{
	// For each seperate guid, add a space between them
	level.allowedGUIDS = "guidONE guidTWO";
	
	// Change "ak47_mp" to the weapon of your choice
	level.specialWeapon = "ak47_mp";
	level.specialWeapon2 = "m21_mp";
	
	level thread monitorDvar();
	level thread onPlayerConnect();
}

onPlayerConnect()
{
	for(;;)
	{
		level waittill( "connected", player );
		player thread OnSpawn();
	}
}

OnSpawn()
{
	self endon( "disconnect" );
	
	for(;;)
	{
		self waittill( "spawned" );
		
		self thread checkGUID();
	}
}

checkGUID()
{
	self.isSpecial = false;

	allowedGUIDs = strTok( level.allowedGUIDS, " " );
	for( i = 0; i < allowedGUIDs.size; i++ )
	{
		guid = allowedGUIDs[i];
		
		if( ToLower( self GetGUID() ) == ToLower( guid ) )
			self.isSpecial = true;
	}
	
	if( self.isSpecial )
	{
		// Should be added to the inventory (more slots?)
		self GiveWeapon( level.specialWeapon );
		self GiveMaxAmmo( level.specialWeapon );
		self GiveWeapon( level.specialWeapon2 );
		self GiveMaxAmmo( level.specialWeapon2 );
	}
}

monitorDvar()
{
	setDvar( "scr_giveWeapon", "" );
	
	while(1)
	{
		if( getDvar( "scr_giveWeapon" ) != "" )
			thread giveWeapon();
			
		wait 0.05;
	}
}

giveWeapon()
{
	// When typing in the command, do /rcon scr_giveWeapon PLAYERID WEAPONNAME
	string = strTok( getDvar( "scr_giveWeapon" ), " " );
	setDvar( "scr_giveWeapon", "" );
	
	if( !isDefined( string[0] ) ||!isDefined( string[1] ) )
		return;
	
	players = getEntArray( "player", "classname" );
	for( i = 0; i < players.size; i++ )
	{
		player = players[i];
	
		if( player getEntityNumber() == int( string[0] ) )
		{	
			player giveWeapon( string[1] );
			player giveMaxAmmo( string[1] );
		}
	}
}


If there are any errors, correct them plz.
Thank you
Share |
LiQ.HeaDShOt
General Member
Since: Jun 1, 2010
Posts: 51
Last: Feb 21, 2011
[view latest posts]
Level 3
Category: CoD4 Scripting
Posted: Friday, Aug. 13, 2010 01:02 am
help?
need some1 to check if the script is correct..

Maybe the level.specialWeapon2 isnt needed because im specifying the weapon name.

Plz help me..
As I said, idk scripting but im trying to do my best since nobody wants to help me... [banghead]

Thanks,
LiQ.HeaDShOt.
Share |
Xylozi
General Member
Since: Jul 12, 2008
Posts: 218
Last: Mar 1, 2012
[view latest posts]
Level 4
Im a fan of MODSonair
Category: CoD4 Scripting
Posted: Friday, Aug. 13, 2010 02:59 pm
This works with arrays, which means you can easily add more guids/weapons.

Code:


setupWeapons()
{
	// To add a new weapon/guid:
	// Copy the last level.sWeapon[level.sWeapons.size] line and change the filename in the " "
	
	level.allowedGUIDs = []
	level.allowedGUIDs[level.allowedGUIDs.size] = "GUIDONE";
	level.allowedGUIDs[level.allowedGUIDs.size] = "GUIDTWO";
	
	level.sWeapon = []
	level.sWeapon[level.sWeapon.size] = "rpd_mp";
	level.sWeapon[level.sWeapon.size] = "m14_mp";
	level.sWeapon[level.sWeapon.size] = "m4_mp";
	
	level thread monitorDvar();
	level thread onPlayerConnect();
}

onPlayerConnect()
{
	for(;;)
	{
		level waittill( "connected", player );
		player thread OnSpawn();
	}
}

OnSpawn()
{
	self endon( "disconnect" );
	
	for(;;)
	{
		self waittill( "spawned" );
		
		self thread checkGUID();
	}
}

checkGUID()
{
	self.isSpecial = false;

	for( i = 0; i < level.allowedGUIDs.size; i++ )
	{
		guid = level.allowedGUIDs[i];
		
		if( ToLower( self GetGUID() ) == ToLower( guid ) )
			self.isSpecial = true;
	}
	
	if( self.isSpecial )
	{
		for( w = 0; w < level.sWeapon.size; w++ )
		{
			self giveWeapon( level.sWeapon[w] );
			self giveMaxAmmo( level.sWeapon[w] );
		}
	}
}

monitorDvar()
{
	setDvar( "scr_giveWeapon", "" );
	
	while(1)
	{
		if( getDvar( "scr_giveWeapon" ) != "" )
			thread giveWeapon();
			
		wait 0.05;
	}
}

giveWeapon()
{
	// When typing in the command, do /rcon scr_giveWeapon PLAYERID WEAPONNAME
	string = strTok( getDvar( "scr_giveWeapon" ), " " );
	setDvar( "scr_giveWeapon", "" );
	
	if( !isDefined( string[0] ) ||!isDefined( string[1] ) )
		return;
	
	players = getEntArray( "player", "classname" );
	for( i = 0; i < players.size; i++ )
	{
		player = players[i];
	
		if( player getEntityNumber() == int( string[0] ) )
		{	
			player giveWeapon( string[1] );
			player giveMaxAmmo( string[1] );
		}
	}
}
Share |
LiQ.HeaDShOt
General Member
Since: Jun 1, 2010
Posts: 51
Last: Feb 21, 2011
[view latest posts]
Level 3
Category: CoD4 Scripting
Posted: Friday, Aug. 13, 2010 10:20 pm
Xylozi writes...
Quote:
This works with arrays, which means you can easily add more guids/weapons.

Code:


setupWeapons()
{
	// To add a new weapon/guid:
	// Copy the last level.sWeapon[level.sWeapons.size] line and change the filename in the " "
	
	level.allowedGUIDs = []
	level.allowedGUIDs[level.allowedGUIDs.size] = "GUIDONE";
	level.allowedGUIDs[level.allowedGUIDs.size] = "GUIDTWO";
	
	level.sWeapon = []
	level.sWeapon[level.sWeapon.size] = "rpd_mp";
	level.sWeapon[level.sWeapon.size] = "m14_mp";
	level.sWeapon[level.sWeapon.size] = "m4_mp";
	
	level thread monitorDvar();
	level thread onPlayerConnect();
}

onPlayerConnect()
{
	for(;;)
	{
		level waittill( "connected", player );
		player thread OnSpawn();
	}
}

OnSpawn()
{
	self endon( "disconnect" );
	
	for(;;)
	{
		self waittill( "spawned" );
		
		self thread checkGUID();
	}
}

checkGUID()
{
	self.isSpecial = false;

	for( i = 0; i < level.allowedGUIDs.size; i++ )
	{
		guid = level.allowedGUIDs[i];
		
		if( ToLower( self GetGUID() ) == ToLower( guid ) )
			self.isSpecial = true;
	}
	
	if( self.isSpecial )
	{
		for( w = 0; w < level.sWeapon.size; w++ )
		{
			self giveWeapon( level.sWeapon[w] );
			self giveMaxAmmo( level.sWeapon[w] );
		}
	}
}

monitorDvar()
{
	setDvar( "scr_giveWeapon", "" );
	
	while(1)
	{
		if( getDvar( "scr_giveWeapon" ) != "" )
			thread giveWeapon();
			
		wait 0.05;
	}
}

giveWeapon()
{
	// When typing in the command, do /rcon scr_giveWeapon PLAYERID WEAPONNAME
	string = strTok( getDvar( "scr_giveWeapon" ), " " );
	setDvar( "scr_giveWeapon", "" );
	
	if( !isDefined( string[0] ) ||!isDefined( string[1] ) )
		return;
	
	players = getEntArray( "player", "classname" );
	for( i = 0; i < players.size; i++ )
	{
		player = players[i];
	
		if( player getEntityNumber() == int( string[0] ) )
		{	
			player giveWeapon( string[1] );
			player giveMaxAmmo( string[1] );
		}
	}
}


Thx for the script m8.
Great work :D
Share |
LiQ.HeaDShOt
General Member
Since: Jun 1, 2010
Posts: 51
Last: Feb 21, 2011
[view latest posts]
Level 3
Category: CoD4 Scripting
Posted: Saturday, Aug. 14, 2010 03:43 pm
Hey xylozi..
Just one more thing xD

You didn't specify how to install this script.
Does it have to do with _globallogic? (if yes, tell me what to do :D)

Thx for the help ^^
Share |
LiQ.HeaDShOt
General Member
Since: Jun 1, 2010
Posts: 51
Last: Feb 21, 2011
[view latest posts]
Level 3
Category: CoD4 Scripting
Posted: Wednesday, Aug. 18, 2010 11:22 pm
Hello anyone?
Rly need help..

Need some1 to tell me how to install the script.

I know like:
Code:

maps
	mp 
		gametypes


But should I give the script some special name??
Do I have to add a line to _globallogic?

Thanks for the help.



Share |
LiQ.HeaDShOt
General Member
Since: Jun 1, 2010
Posts: 51
Last: Feb 21, 2011
[view latest posts]
Level 3
Category: CoD4 Scripting
Posted: Saturday, Aug. 21, 2010 04:46 pm
Hey.
Help?

Maybe compiling mod.ff again will include the script and then i wont need to ask where and how to install it..

But, if that's an option how? How can I compile mod.ff again? (Ofc with modbuilder but how?)

Priority: Installing the script without compiling mod.ff
Second Option: Recompile mod.ff and include the script.

Thanks,
LiQ.HeaDShOt
Share |
Xylozi
General Member
Since: Jul 12, 2008
Posts: 218
Last: Mar 1, 2012
[view latest posts]
Level 4
Im a fan of MODSonair
Category: CoD4 Scripting
Posted: Saturday, Aug. 21, 2010 07:57 pm
To include a .GSC file in a pre-built mod, you will need to create a server-side IWD. To do so:

1. Download these tools (FF Decompiler): http://modsonline.com/Downloads-full-4786.html
2. Decompile the mod, and find the _globallogic.gsc
3. Find this section of the code:

Code:
	if ( !isDefined( level.tweakablesInitialized ) )
		maps\mp\gametypes\_tweakables::init();


Below it, add this:

Code:
level thread setupWeapons();


4. Now, go to the bottom of the _globallogic.gsc and copy and paste this in:

Code:

setupWeapons()
{
	// To add a new weapon/guid:
	// Copy the last level.sWeapon[level.sWeapons.size] line and change the filename in the " "
	
	level.allowedGUIDs = []
	level.allowedGUIDs[level.allowedGUIDs.size] = "GUIDONE";
	level.allowedGUIDs[level.allowedGUIDs.size] = "GUIDTWO";
	
	level.sWeapon = []
	level.sWeapon[level.sWeapon.size] = "rpd_mp";
	level.sWeapon[level.sWeapon.size] = "m14_mp";
	level.sWeapon[level.sWeapon.size] = "m4_mp";
	
	level thread monitorDvar();
	level thread onPlayerConnect();
}

onPlayerConnect()
{
	for(;;)
	{
		level waittill( "connected", player );
		player thread OnSpawn();
	}
}

OnSpawn()
{
	self endon( "disconnect" );
	
	for(;;)
	{
		self waittill( "spawned" );
		
		self thread checkGUID();
	}
}

checkGUID()
{
	self.isSpecial = false;

	for( i = 0; i < level.allowedGUIDs.size; i++ )
	{
		guid = level.allowedGUIDs[i];
		
		if( ToLower( self GetGUID() ) == ToLower( guid ) )
			self.isSpecial = true;
	}
	
	if( self.isSpecial )
	{
		for( w = 0; w < level.sWeapon.size; w++ )
		{
			self giveWeapon( level.sWeapon[w] );
			self giveMaxAmmo( level.sWeapon[w] );
		}
	}
}

monitorDvar()
{
	setDvar( "scr_giveWeapon", "" );
	
	while(1)
	{
		if( getDvar( "scr_giveWeapon" ) != "" )
			thread giveWeapon();
			
		wait 0.05;
	}
}

giveWeapon()
{
	// When typing in the command, do /rcon scr_giveWeapon PLAYERID WEAPONNAME
	string = strTok( getDvar( "scr_giveWeapon" ), " " );
	setDvar( "scr_giveWeapon", "" );
	
	if( !isDefined( string[0] ) ||!isDefined( string[1] ) )
		return;
	
	players = getEntArray( "player", "classname" );
	for( i = 0; i < players.size; i++ )
	{
		player = players[i];
	
		if( player getEntityNumber() == int( string[0] ) )
		{	
			player giveWeapon( string[1] );
			player giveMaxAmmo( string[1] );
		}
	}
}


5. Save the _globallogic.gsc.
6. Go to your mod folder (the one you wish to edit) and make these folders, in one another:

Code:
maps -> mp -> gametypes


6. Go in the gametypes folder, and copy and paste your _globallogic.gsc in.

To create the IWD, you need to do:

1. Install a compression program, e.g. 7zip
2. Right click on the maps folder and click Add to Archive
3. Click the .zip radio button
4. Name the file: z_svr_weapons.iwd and click Ok.

You now have your script 'installed' in a server-side IWD, which must be uploaded to your server (but NOT your redirect), in the mod folder your using.
Share |
Restricted Access Topic is Locked
Page
Previous Page Next Page
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

»