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

Members Online

»
0 Active | 82 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: 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 09: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 09: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 11: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 03:31 pm
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 03:56 pm
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 04:04 pm
Thank you so much :)
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

»