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

Members Online

»
0 Active | 7 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 2
Category: CoD2 Scripting
Scripting and coding with Call of Duty 2.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked
Page
Next Page
subscribe
Author Topic: trigger primary weapon hide
lin3000
General Member
Since: Jan 5, 2008
Posts: 19
Last: Dec 4, 2009
[view latest posts]
Level 1
Category: CoD2 Scripting
Posted: Wednesday, Oct. 14, 2009 01:18 pm
i want a trigger that hides your primary weapon so you cant use it while standing in the trigger. When you leave the trigger you will get your primary weapon back. is that possible?
does somebody have that script?

Thank you!
Share |
Sevenz
General Member
Since: Apr 24, 2006
Posts: 2390
Last: May 10, 2013
[view latest posts]
Level 8
Category: CoD2 Scripting
Posted: Wednesday, Oct. 14, 2009 05:20 pm
only primary, hide or take, sp or mp?
Share |
DemonSeed
General Member
Since: Apr 30, 2009
Posts: 1362
Last: Feb 19, 2018
[view latest posts]
Level 8
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Wednesday, Oct. 14, 2009 05:48 pm
Or disableWeapon()?
Share |
COD4GRC
General Member
Since: Aug 12, 2007
Posts: 44
Last: Jan 30, 2010
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Wednesday, Oct. 14, 2009 05:50 pm
It would probably look like this
Code:

main(){
	thread weaponSwitcher();
}

weaponSwitcher(){
	trigger = getent("weapon_switch_trigger", "targetname");
	
	while(1){
		// Wait till the trigger get triggered
		trigger waittill("trigger");
		
		// Take all weapons
		level.player takeallweapons();
		
		while(1){
			wait 1.0;
			if(!(level.player istouching(trigger))){
				break;
			}
		}
		
		level.player giveWeapon("m1garand");
		level.player switchToWeapon("m1garand");
	}
}


You'll have to test it yourself and replace the giveWeapon("m1garand") for a genius use of the level.player getCurrentWeapon(): function.

But this method is pretty expensive (as in takes some cpu), so I actually recommend a trigger for taking the weapon and a trigger for returning the weapon around the first trigger.

Understand? :P


Share |
Pedro699
General Member
Since: Jun 19, 2006
Posts: 781
Last: Dec 18, 2010
[view latest posts]
Level 7
Category: CoD2 Scripting
Posted: Wednesday, Oct. 14, 2009 07:45 pm
DemonSeed writes...
Quote:
Or disableWeapon()?


This is the way I'd go.

You specify that you don't want players to be able to use their primary weapons - are you implying that people can still use grenades and their secondary weapon? If so you'll need to go for a similar approach to COD4GRC (which is currently for single player).

If not you can use disableWeapon() - something a bit like this

Code:
checkTrig()
{
   trigger = getent("weapontrigger","targetname");
   
   while(1)
   {
      trigger waittill("trigger",player);
   
      if(!isDefined(player.handlingTrigger))
      {
         player thread handleTrig(trigger);
      }
   }
}

handleTrig(trigger)
{
   self endon("disconnect");
   
   self.handlingTrigger = true;
   
   while(isalive(self) && self istouching(trigger))
   {
      self disableWeapon(); 
      wait 0.1;
   }
   
   self.handlingTrigger = undefined;
   self enableWeapon();
}
Share |
lin3000
General Member
Since: Jan 5, 2008
Posts: 19
Last: Dec 4, 2009
[view latest posts]
Level 1
Category: CoD2 Scripting
Posted: Thursday, Oct. 15, 2009 03:37 pm
Thanks for all the reply's

I want this to use for MP

And this is what i want:
When a player enters the trigger he will not be able to use his primary weapon. So he will only be able to use his secondary weapon and nades. When the player leaves the trigger he will get his weapon back and will be able to use it outside the trigger ;)

edited on Oct. 15, 2009 11:40 am by lin3000
Share |
Sevenz
General Member
Since: Apr 24, 2006
Posts: 2390
Last: May 10, 2013
[view latest posts]
Level 8
Category: CoD2 Scripting
Posted: Thursday, Oct. 15, 2009 04:56 pm
hm maybe switchtoweapon when the player enters the trigger and whenever he tries to change back the primary weapon, or take the primaryweapon and give it back later
Share |
lin3000
General Member
Since: Jan 5, 2008
Posts: 19
Last: Dec 4, 2009
[view latest posts]
Level 1
Category: CoD2 Scripting
Posted: Friday, Oct. 16, 2009 10:51 am
Pedro699 writes...
Quote:
DemonSeed writes...
Quote:
Or disableWeapon()?


This is the way I'd go.

You specify that you don't want players to be able to use their primary weapons - are you implying that people can still use grenades and their secondary weapon? If so you'll need to go for a similar approach to COD4GRC (which is currently for single player).

If not you can use disableWeapon() - something a bit like this

Code:
checkTrig()
{
   trigger = getent("weapontrigger","targetname");
   
   while(1)
   {
      trigger waittill("trigger",player);
   
      if(!isDefined(player.handlingTrigger))
      {
         player thread handleTrig(trigger);
      }
   }
}

handleTrig(trigger)
{
   self endon("disconnect");
   
   self.handlingTrigger = true;
   
   while(isalive(self) && self istouching(trigger))
   {
      self disableWeapon(); 
      wait 0.1;
   }
   
   self.handlingTrigger = undefined;
   self enableWeapon();
}


Thanks for your script but it will disable all your weapons.
I only want to disable the primary weapon.
Can you change the script so players can only use secondary weapon and nades?
Share |
DemonSeed
General Member
Since: Apr 30, 2009
Posts: 1362
Last: Feb 19, 2018
[view latest posts]
Level 8
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Friday, Oct. 16, 2009 01:16 pm
Unfortunately, the disableWeapon() function cannt discriminate between primary or secondary. The only thing you could do is get them to drop their primary weapon:


Code:
checkTrig()
{
	trigger = getent( "weapontrigger","targetname" );
   
	for( ;; )
	{
		trigger waittill( "trigger", player );
   
		if( isPlayer( player ) )
		{
			
			while( isalive( player ) && player istouching( trigger ) )
			{
				current = self getCurrentWeapon();
				weapon1 = self getweaponslotweapon( "primary" );
				
				if( current == weapon1 )
					self dropItem( current ); 
				
				wait 1;
			}
		}
	}
}


They will not be able to pick up their primary weapon while in the trigger radius.
Share |
Pedro699
General Member
Since: Jun 19, 2006
Posts: 781
Last: Dec 18, 2010
[view latest posts]
Level 7
Category: CoD2 Scripting
Posted: Friday, Oct. 16, 2009 05:14 pm
Your code it not completely reliable Demon as it relies on the primary weapon being in the primary slot (and for that matter the player only having one primary weapon).

CoD:WaW has functions for finding out if a weapon is a primary - I don't know if CoD2 has similar functions - but you can write your own functions do this

Combinations of take / give weapon would be the best method but are more involved as they require weapon data to be stored. This is what I came up with. I tested it briefly and seems to work fine.

Code:
checkTrig()
{
   trigger = getent("weapontrigger","targetname");
   
   while(1)
   {
      trigger waittill("trigger",player);
   
      if(!isDefined(player.handlingTrigger))
      {
         player thread handleTrig(trigger);
      }
   } 
}

handleTrig(trigger)
{
   self endon("disconnect");
 
   self.handlingTrigger = true;
   
   self takePrimariesandStore();
   
   while(isalive(self) && self istouching(trigger))
   {
      self takePrimariesandStore();
      wait 0.2;
   }
   
   self giveBackPrimaries();
   
   self.handlingTrigger = undefined;
}

takePrimariesandStore()
{
   if(!isDefined(self.weaponList))
      self.weaponList = [];
      
   weapons = self getWeaponList();
   
   tempW = [];
   secondary = undefined;
   
   for(i=0; i < weapons.size; i++)
   {  
      iprintln(weapons[i]);
      if(isPrimary(weapons[i]))
      {
         tempW[tempW.size] = weapons[i];
         self takeweapon(weapons[i]);
      } 
      else 
         secondary = weapons[i];
   }
   
   if(isDefined(secondary))
      self switchtoweapon(secondary);
   
   if(tempW.size > 0)
      self.weaponList = tempW;
}

giveBackPrimaries()
{   
   if(self.weaponList.size == 0)
      return;

   weaponlist = self getWeaponList();
   
   for(i=0; (i + weaponList.size) < 2; i++)
   {
      self giveWeapon(self.weaponList[i]);
   }  
   
   self.weaponList = [];
}

getWeaponList()
{
   weaponList = [];
   
   weap = self getweaponslotweapon("primary");
   
   if(weap != "none") weaponList[weaponList.size] = weap;
   
   weap = self getweaponslotweapon("primaryb");
   
   if(weap != "none") weaponList[weaponList.size] = weap;
   
   return weaponList;
}

isPrimary(weapon)
{
   switch(weapon)
   {
      case "colt_mp":
      case "luger_mp":
      case "tt30_mp":
      case "webley_mp":
      case "none":
         return false;
      default:
         return true;   
   }
}


edited on Oct. 16, 2009 01:14 pm by Pedro699
Share |
Restricted Access Topic is Locked
Page
Next Page
subscribe
MODSonline.com Forums : Call of Duty 2 : CoD2 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

»