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

Members Online

»
0 Active | 73 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 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
Previous Page
subscribe
Author Topic: trigger primary weapon hide
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 05:27 pm
Pedro699 writes...
Quote:
Your code it not completely reliable Demon as it relies on the primary weapon being in the primary slot


In COD2, you can only carry a primary weapon in the "primary" slot. You cant have a pistol in there as it isnt defined as a primary weapon in _weapons.gsc. In that respect, my code is completely reliable.

I would point out that the remit the OP gave was concered only with the primary weapon.

Pedro699 writes...
Quote:
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


Yes - COD2 has functions for finding a primary weapon. I used it in my code.
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:51 pm
Quote:
DemonSeed writes...
In COD2, you can only carry a primary weapon in the "primary" slot. You cant have a pistol in there as it isnt defined as a primary weapon in _weapons.gsc. In that respect, my code is completely reliable.


Not true!

This is only true for the spawn case. Consider when the map has started and the player swaps out their pistol for a primary weapon laying on the ground - this second (primary) weapon will be located in the primaryb weapon slot - not primary and would therefore not be dropped.

This may depend on the definition of a primary weapon. To me, a primary weapon is one that is not a pistol - perhaps the poster can clarify?

As an aside dropping the weapon is not suitable solution as it will drop within the trigger and when the player picks it up it will be dropped again (due to the player being in the trigger). The remit was that the weapon is given back to the player on leaving the trigger.


edited on Oct. 16, 2009 01:51 pm by Pedro699
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 06:20 pm
Im dropping out of this as I dont take part in forum pee-peeing contests. I was trying to help - not prove who has the best solution to a posted problem, and I certainly dont need to prove anything to anyone.
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:52 pm
Pedro699 writes...
Quote:
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


It works

Thanks you very much!

But now i have still 1 problem and 1 question

-first, I get alot of spam in the left corner of my screen while standing in the trigger. It says Webley_mp (when having a webley) Does somebody know how to solve this?

-Second, When I'm standing in the trigger with 2 primary weapons i can't use any of them, they both disapear.
For example; i have a mp44 and a m1garand in my 2 slots.
When i enter the trigger with these 2 weapons, they both will disapear and i wont be able too use any of them.
Can this be solved?

Thanks all!
Share |
Pedro699
General Member
Since: Jun 19, 2006
Posts: 781
Last: Dec 18, 2010
[view latest posts]
Level 7
Category: CoD2 Scripting
Posted: Saturday, Oct. 17, 2009 01:04 pm
Ah, I see there is still a debug line in there:

Code:
iprintln(weapons[i]);


Just remove that line and that will get rid of the spamming text.

The second part of your question is where the confusion lies. What do you class as a primary weapon?

Remember that you could easily swap your weapons for ones on the floor and you could have situations where the player has 2 pistols or two 'primary' weapons (ones that aren't pistols), as you describe.

How would you choose between the two primary weapons the player has to pick the one to remove? If you allow the player with 2 primaries to still use one of them, but other players can only use their pistol does this not give an unfair advantage to the first player? (I'm not sure what the goal of this script is)
Share |
Sevenz
General Member
Since: Apr 24, 2006
Posts: 2390
Last: May 10, 2013
[view latest posts]
Level 8
Category: CoD2 Scripting
Posted: Saturday, Oct. 17, 2009 02:27 pm
or use dev-only blocks:

Code:
/#

iprintln(weapons[i]);
#/


it will execute the code between /# and #/ only if you run a map in developer mode
Share |
lin3000
General Member
Since: Jan 5, 2008
Posts: 19
Last: Dec 4, 2009
[view latest posts]
Level 1
Category: CoD2 Scripting
Posted: Saturday, Oct. 17, 2009 03:31 pm
Thanks i solved the problem

Now i have a new problem.
If i die while standing in the trigger i get an error
(see screenshot)

[img="error"]

How do i solve this?

edited on Oct. 17, 2009 11:31 am by lin3000
Share |
Pedro699
General Member
Since: Jun 19, 2006
Posts: 781
Last: Dec 18, 2010
[view latest posts]
Level 7
Category: CoD2 Scripting
Posted: Saturday, Oct. 17, 2009 11:22 pm
change:

Code:
self giveBackPrimaries();


to

Code:

if(isAlive(self))
   self giveBackPrimaries();
else
   self.weaponList = [];


Good tip there Sevenz


edited on Oct. 18, 2009 06:40 am by Pedro699
Share |
lin3000
General Member
Since: Jan 5, 2008
Posts: 19
Last: Dec 4, 2009
[view latest posts]
Level 1
Category: CoD2 Scripting
Posted: Sunday, Oct. 18, 2009 08:39 am
Thank you very much it worked ;)

Share |
Pedro699
General Member
Since: Jun 19, 2006
Posts: 781
Last: Dec 18, 2010
[view latest posts]
Level 7
Category: CoD2 Scripting
Posted: Sunday, Oct. 18, 2009 10:41 am
Made a small mistake there - it should be

Code:

if(isAlive(self))
   self giveBackPrimaries();
else
   self.weaponList = [];


Otherwise when a player dies in the trigger it will not work right the next time (or they will get their previous weapon back from the time they died)
Share |
Restricted Access Topic is Locked
Page
Previous 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

»