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

Members Online

»
1 Active | 18 Guests
Online:

LATEST FORUM THREADS

»
Rainbow HELP....
CoD4 MP Mapping
help pls
CoD2 Scripting

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, supersword, playername, novemberdobby
Latest Posts
Subscribed Posts
Search
Restricted Access Restricted Access subscribe
Author Topic: Disabling Weapons for a particular team...
POOTIS
General Member
Since: Dec 17, 2010
Posts: 5
Last: Jan 2, 2011
[view latest posts]
Level 0
Category: CoD4 Scripting
Posted: Friday, Dec. 17, 2010 02:43 pm
I'm trying to disable weapons for allies only in a particular area (an admin room) to stop camping. (This is for a zombie mod btw). I don't want to just use a weap clip because that is kinda lame. I've got two triggers one at the top of the ladder to the room, the one at the top disables weapons and the bottom one enables them.

Here is my current script:

Code:
//**** WEAPON DISABLING & ENABLING ****

weap_disabling()
{

	weap_disable = getent( "weap_disable", "targetname" );
	
	if(!isdefined(weap_disable))
	 {
	   self SetTeamForTrigger( game["allies"] );

	 }

    weap_disable waittill( "trigger", player );
	player disableweapons();
	player iPrintlnBold( "^1Weapons Disabled to stop Bad, BAD Camping!" );
	weap_disable maps\mp\_utility::triggerOff();
	wait 1;
	weap_disable maps\mp\_utility::triggerOn();

}
weap_enabling()
{	
	weap_enable = getent( "weap_enable", "targetname" );
	
	if(!isdefined(weap_enable))
	 {
	   self SetTeamForTrigger( game["allies"] );
	   
	 }
	
	weap_enable waittill( "trigger", player );
	player enableweapons();
	weap_enable maps\mp\_utility::triggerOff();
	wait 1;
	weap_enable maps\mp\_utility::triggerOn();

}
//**** END OF WEAPON DISABLING & ENABLING ****



Thanks for any help in advance :)

edited on Dec. 17, 2010 04:44 pm by POOTIS
Share |
Pedro699
General Member
Since: Jun 19, 2006
Posts: 781
Last: Dec 18, 2010
[view latest posts]
Level 7
Category: CoD4 Scripting
Posted: Saturday, Dec. 18, 2010 02:45 am
Does the script not work?

Looks fine in principle, although you will need to stick both of the functions in a while loop to cover multiple activations of the trigger.

And you don't need to turn the trigger on / off as this may allow additional players to slip past the trigger.
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, Dec. 18, 2010 04:45 am
Use a single trigger, covering the room or space. This script will stop the player using weapons in that trigger:

Code:

init()
{
	// handle disabled weapon check variable
	level thread onPlayerConnect();
	level thread setupTrigger();
}

onPlayerConnect()
{
	while(1)
	{
		level waittill( "connected", player );
		player thread onDeath();
		player.weaponsDisabled = false;
	}
}

onDeath()
{
	self endon( "disconnect" );
	
	while(1)
	{
		self waittill( "death" );
		self.weaponsDisabled = false;
	}
}

setupTrigger()
{
	weapon_disable = getEnt( "weap_disable", "targetname" );
	
	while(1)
	{
		weapon_disable waittill( "trigger", player );
	
		if( player.pers["team"] == "allies" && !player.weaponsDisabled )
		{
			player.weaponsDisabled = true;
			player thread disableWeapons( weapon_disable );
		}
	}
}

disableWeapons( trigger )
{
	self endon( "disconnect" );
	self endon( "death" );
	self endon( "joined_spectator" );
	self endon( "left_weapon_trigger" );
	
	self iPrintLnBold( "Weapons disabled" );
	self disableWeapons();
	
	while(1)
	{
		if( !self isTouching( trigger ) )
		{
			self iPrintLnBold( "Weapons enabled" );
			self enableWeapons();
			self.weaponsDisabled = true;
			self notify( "left_weapon_trigger" );
		}
		
		wait 0.05;
	}
}
Share |
POOTIS
General Member
Since: Dec 17, 2010
Posts: 5
Last: Jan 2, 2011
[view latest posts]
Level 0
Category: CoD4 Scripting
Posted: Monday, Dec. 20, 2010 08:31 am
Thank you for the script xylozi :)

EDIT: for some reason it is failing to work ingame, it just spams the player with 'weapons disabled' a lot of times and then displays 'weapons enabled' at the end of this spam. Weapons aren't actually disabled as well :P

edited on Dec. 20, 2010 10:31 am by POOTIS
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: Monday, Dec. 20, 2010 08:56 am
Tested and fixed the code, this works perfectly now:

Code:

init()
{
	// handle disabled weapon check variable
	level thread onPlayerConnect();
	level thread setupTrigger();
}

onPlayerConnect()
{
	while(1)
	{
		level waittill( "connected", player );
		player thread onDeath();
		player.weaponsDisabled = false;
	}
}

onDeath()
{
	self endon( "disconnect" );
	
	while(1)
	{
		self waittill( "death" );
		self.weaponsDisabled = false;
	}
}

setupTrigger()
{
	weapon_disable = getEnt( "weap_disable", "targetname" );
	
	while(1)
	{
		weapon_disable waittill( "trigger", player );
	
		if( player.pers["team"] == "allies" && !player.weaponsDisabled )
		{
			player.weaponsDisabled = true;
			player thread disablePlayerWeapons( weapon_disable );
		}
	}
}

disablePlayerWeapons( trigger )
{
	self endon( "disconnect" );
	self endon( "death" );
	self endon( "joined_spectator" );
	self endon( "left_weapon_trigger" );
	
	self iPrintLnBold( "Weapons disabled" );
	self disableWeapons();
	
	while(1)
	{
		if( !self isTouching( trigger ) )
		{
			self iPrintLnBold( "Weapons enabled" );
			self enableWeapons();
			self.weaponsDisabled = false;
			self notify( "left_weapon_trigger" );
		}
		
		wait 0.05;
	}
}
Share |
POOTIS
General Member
Since: Dec 17, 2010
Posts: 5
Last: Jan 2, 2011
[view latest posts]
Level 0
Category: CoD4 Scripting
Posted: Monday, Dec. 20, 2010 09:04 am
Thank you so much :)
Share |
Restricted Access Restricted Access subscribe
MODSonline.com Forums : Call of Duty 4 : CoD4 Scripting

Latest Syndicated News

»
Why console gaming is dying
Quote:Consider this: Dedicated gaming sales — including living-room consoles...
Devs: Games are being dumb...
Click 'read more' to view the contents of this post.
Loadout
Gun Crafting to the Max. edited on Sep. 25, 2012 06:57 pm by Morp...
Introducing the Source Fil...
Surprised this wasn't made a long time ago. Sounds like a nice little feature.
Introducing the Source Fil...
The Source Filmmaker (SFM) is the movie-making tool built and used by us he...

Partners & Friends

»