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

Members Online

»
0 Active | 6 Guests
Online:

LATEST FORUM THREADS

»
warfare
CoD4 Map + Mod Releases
Voting menu on maps
CoD+UO General
Hauling 911
CoDBO3 General

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: Removing weapons on spawn
DButler
General Member
Since: Apr 27, 2009
Posts: 3
Last: Sep 1, 2012
[view latest posts]
Level 0
Category: CoD4 Scripting
Posted: Thursday, Aug. 30, 2012 06:50 am
Hello all, I know very little about scripting. I am trying to make it so when players spawn in my MP map, they will only be able to use a knife. If someone could provide some script to accomplish this, and a small lesson on how to incorporate it in the the relevant files, it would be very much appreciated.
Later down the road, I want to have large buildings in a map and have the loss of weapons triggered when they enter the building.

Thanks in advance!!!
Share |
Tally
General Member
Since: Apr 21, 2005
Posts: 819
Last: Oct 26, 2012
[view latest posts]
Level 7
Category: CoD4 Scripting
Posted: Thursday, Aug. 30, 2012 12:24 pm
You can do it quite easily:

I will use the GSC file from mp_backlot as an example:

Code:
main()
{
	
	maps\mp\mp_backlot_fx::main();
	maps\createfx\mp_backlot_fx::main();
	maps\createart\mp_backlot_art::main();
	maps\mp\_load::main();	
	
	maps\mp\_compass::setupMiniMap("compass_map_mp_backlot");

	//setExpFog(500, 2200, 0.81, 0.75, 0.63, 0);
	//VisionSetNaked( "mp_backlot" );
	ambientPlay("ambient_backlot_ext");

	game["allies"] = "marines";
	game["axis"] = "opfor";
	game["attackers"] = "axis";
	game["defenders"] = "allies";
	game["allies_soldiertype"] = "desert";
	game["axis_soldiertype"] = "desert";

	setdvar( "r_specularcolorscale", "1" );

	setdvar("r_glowbloomintensity0",".25");
	setdvar("r_glowbloomintensity1",".25");
	setdvar("r_glowskybleedintensity0",".3");
	setdvar("compassmaxrange","1800");

	thread onPlayerConnect();
}

onPlayerConnect()
{
	for( ;; )
	{
		level waittill( "connecting", player );
		
			player thread onPlayerSpawned();
	}
}

onPlayerSpawned()
{
	self endon( "disconnect" );
	
	for( ;; )
	{
		self waittill( "spawned_player" );
		
		self thread removeWeapons();
	}
}

removeWeapons()
{
	self endon( "death" );
	
	// give the game enough time to place all weapons before removing them
	wait( 2 );
	
	self takeAllWeapons();

}


Even though I have shown you how to do it, I strongly advise you not to make your map into a mod. Mods do things to player's weapons. If your code overrides what they are doing, people running those mods wont use your map. You will therefore be limiting your audience.

But, ultimately, it is up to you what you decide to do.
Share |
DButler
General Member
Since: Apr 27, 2009
Posts: 3
Last: Sep 1, 2012
[view latest posts]
Level 0
Category: CoD4 Scripting
Posted: Saturday, Sep. 1, 2012 10:52 am
A few questions...

1, I placed your code in my GSC file and it works as advertised. Only I do not have a knife. No weapons at all.

2. What do you mean by "Turning my map into a mod"? Is this what I have done?

All I really want is when players play this map, all they have is a knife. The map will be a small, knife only map.

And thanks for your replies, they are very informative, and greatly appreciated.

Share |
Tally
General Member
Since: Apr 21, 2005
Posts: 819
Last: Oct 26, 2012
[view latest posts]
Level 7
Category: CoD4 Scripting
Posted: Saturday, Sep. 1, 2012 12:12 pm
DButler writes...
Quote:
A few questions...

1, I placed your code in my GSC file and it works as advertised. Only I do not have a knife. No weapons at all.

2. What do you mean by "Turning my map into a mod"? Is this what I have done?

All I really want is when players play this map, all they have is a knife. The map will be a small, knife only map.

And thanks for your replies, they are very informative, and greatly appreciated.



I just tried this and I have concluded the following: as the knife is actually in the weapon files, if you remove ALL weapons, there is nothing to define a knife.

So, how do you get around it? I would say, that a custom weapon file is needed - one which has no models for weapons, only defining the knife. But, and this is a big "but", this will make your map more into a mod than is advisable.

What do I mean "making your map into a mod":

a map is a level for players to play on; with COD4, you cannot run a custom map without a mod folder; although you need the folder, you don't actually have to use any mod files - just the folder in order to launch custom maps; So, theoretically, you could make your map and include whatever you like in it - weapon files and all; but the problem is other users will want to try your map with the various mods around. Including any kind of scripts which control weapon behaviour, or including weapon files in your map, will break some of the mods around. It would break my mod (Demon mod) for example, and it would break the Openwarfare and X4 mods.As such, admins who really want to run those mods will abandon your map. this will severely limit the admins who are willing to run your map.

Most mods actually have "knife only" features (mine doesn't). If you want to design your map with knife only you can do that. Just advise people to use a particular mod in order to enjoy your map the way you think it is best played.

Having said all that, again: if you really want to do this, I could probably create a custom weapon file which will give you the knife-only effect you are looking for.
Share |
DButler
General Member
Since: Apr 27, 2009
Posts: 3
Last: Sep 1, 2012
[view latest posts]
Level 0
Category: CoD4 Scripting
Posted: Saturday, Sep. 1, 2012 12:19 pm
Thanks again for the reply!!

I have seen where you must have a weapon in order to have the knife. So what I have done is give the players a colt45_mp. after this, the knife works fine. I guess what I need to do now is figure out how to unload the stock ammo, as well as the clip.

The server this map will be on is a modded server R&G server. It has several maps for knife only on it already. The problem is that some want to come in and just shoot it up, lol. This "Knife only" map was a request for these maps only.

Thanks again!!
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

»