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

Members Online

»
0 Active | 44 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 subscribe
Author Topic: 2 weapon problems
z0d
General Member
Since: Apr 29, 2012
Posts: 33
Last: May 8, 2013
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Saturday, Dec. 8, 2012 01:58 pm
Hello guys,

I edit CoD2 PAM (ePAM actually) and I have 2 problems:

Problem 1.) Well, I don't really know how to describe that problem without giving you an example:
so we have 2 players: player A is in axis team and player B is in allies team.
Round 1. player A has a kar98k and player B has m1, player B kills player A and picks its weapon (kar98k)
Round 2. so now, player B has m1 and kar98k. player A changes its weapon in STRAT TIME (3-4 seconds before round starts for real). So player A who changed its weapon in strat time, kills player B while player B has kar98k as its primary weapon. Player A tries to pickup dropped kar98k and it can't.

So here are some things that I know that works:
A) If player A changed his weapon at the end of 1st round (after player B killed him), he's able to pickup kar98k dropped by player B when its killed - next round (so player A didn't change its weapon in strat time)
B) I made a for loop which does: var = getweaponslotweapon("primary") and sets pers["weapon"] = var. And then it also works, excepts I don't have right weapon next round.
C) When player is killed, in player_killed function pers["weapon1"], pers["weapon2"] and pers["spawnweapon"] sets to undefined. What I did is, changed their values to "none" instead of undefined and it worked. In spawnplayer() function there is if(isdefined(self.pers["weapon1"]) && isdefined(self.pers["weapon2"])) as you may know and it worked (apparently) because it never went in -else- .

I tried several things already:
-copied "weapon_saver" in endround() function
-modifined if(isdefined(self.pers["weapon1"]) && isdefined(self.pers["weapon2"])) to look something like if((isdefined(self.pers["weapon1"]) && isdefined(self.pers["weapon2"])) && (self.pers["weapon1"] != "none" && self.pers["weapon2"]!= "none"))
-added self setspawnweapon in menuweapon() function (put it in if which changes weapon straight away - in strat time)

Problem 2.)
Okay, I'll give you another example:
we have 2 players (again). In round 1. player A has a scope and is allies, player B has a mp44 and is axis, player C has a mp44 and is axis as well.
Player A kills player C and switches his scope with mp44. Player B picks up scope dropped by player A.
Next round (no matter who won or was killed), player B who's not a real scoper of axis team now have a scope and it might happen that there are two scopes in team. I want to avoid that and heres what I've did:

Code:
real_weapon = self.pers["weapon"];<br />
	<br />
		if (level.weapons[real_weapon].classname == "sniper")<br />
			self.sniper_owner = 1;<br />
		else<br />
			self.sniper_owner = 0;<br />
<br />
		if(isdefined(self.pers["weapon1"]) && isdefined(self.pers["weapon2"]))<br />
		{<br />
			weapon1_checker = self.pers["weapon1"];<br />
			weapon2_checker = self.pers["weapon2"];<br />
<br />
			while(!isdefined(level.weapons[weapon1_checker].classname)) <br />
				wait 0.05;<br />
<br />
			if (level.weapons[weapon1_checker].classname == "sniper" && level.weapons[weapon2_checker].classname == "sniper")<br />
			{<br />
				self setWeaponSlotWeapon("primary", self.pers["weapon"]);<br />
				self setWeaponSlotAmmo("primary", 999);<br />
				self setWeaponSlotClipAmmo("primary", 999);<br />
	<br />
				self setSpawnWeapon(self.pers["weapon"]);<br />
			}<br />
			else if ((level.weapons[weapon1_checker].classname == "sniper" || level.weapons[weapon2_checker].classname == "sniper") && self.sniper_owner != 1)<br />
			{<br />
				if (level.weapons[weapon1_checker].classname == "sniper")<br />
					self setWeaponSlotWeapon("primary", self.pers["weapon"]);<br />
				else<br />
					self setWeaponSlotWeapon("primary", self.pers["weapon1"]);<br />
					<br />
				self setWeaponSlotAmmo("primary", 999);<br />
				self setWeaponSlotClipAmmo("primary", 999);<br />
		<br />
				if (level.weapons[weapon2_checker].classname == "sniper")<br />
					self setWeaponSlotWeapon("primaryb", self.pers["weapon"]);<br />
				else<br />
			 		self setWeaponSlotWeapon("primaryb", self.pers["weapon2"]);<br />
<br />
				self setWeaponSlotAmmo("primaryb", 999);<br />
				self setWeaponSlotClipAmmo("primaryb", 999);<br />
	<br />
				self setSpawnWeapon(self.pers["spawnweapon"]);<br />
			}<br />
			else if ((level.weapons[weapon1_checker].classname == "sniper" || level.weapons[weapon2_checker].classname == "sniper") && self.sniper_owner == 1)<br />
			{				<br />
				if (level.weapons[weapon1_checker].classname == "sniper")<br />
				{	<br />
					if (weapon1_checker == self.pers["weapon"])<br />
					{<br />
						self setWeaponSlotWeapon("primary", self.pers["weapon1"]);<br />
					}<br />
					else<br />
					{<br />
						self setWeaponSlotWeapon("primary", self.pers["weapon"]);<br />
					}<br />
				} <br />
				else<br />
					self setWeaponSlotWeapon("primary", self.pers["weapon1"]);<br />
<br />
				self setWeaponSlotAmmo("primary", 999);<br />
				self setWeaponSlotClipAmmo("primary", 999);<br />
				<br />
				if (level.weapons[weapon2_checker].classname == "sniper")<br />
				{<br />
					if (weapon2_checker == self.pers["weapon"])<br />
					{<br />
						self setWeaponSlotWeapon("primaryb", self.pers["weapon2"]);<br />
					}<br />
					else<br />
					{<br />
						self setWeaponSlotWeapon("primaryb", self.pers["weapon"]);<br />
					}<br />
				} <br />
				else<br />
					self setWeaponSlotWeapon("primaryb", self.pers["weapon2"]);<br />
<br />
				self setWeaponSlotAmmo("primaryb", 999);<br />
				self setWeaponSlotClipAmmo("primaryb", 999);<br />
	<br />
				self setSpawnWeapon(self.pers["spawnweapon"]);<br />
			}<br />
			else  <br />
			{<br />
				self setWeaponSlotWeapon("primary", self.pers["weapon1"]);<br />
				self setWeaponSlotAmmo("primary", 999);<br />
				self setWeaponSlotClipAmmo("primary", 999);<br />
<br />
			 	self setWeaponSlotWeapon("primaryb", self.pers["weapon2"]);<br />
				self setWeaponSlotAmmo("primaryb", 999);<br />
				self setWeaponSlotClipAmmo("primaryb", 999);<br />
<br />
				self setSpawnWeapon(self.pers["spawnweapon"]);<br />
			}<br />
		}<br />
		else<br />
		{<br />
			self setWeaponSlotWeapon("primary", self.pers["weapon"]);<br />
			self setWeaponSlotAmmo("primary", 999);<br />
			self setWeaponSlotClipAmmo("primary", 999);<br />
	<br />
			self setSpawnWeapon(self.pers["weapon"]);<br />
		}


What I get as a error is this:

Code:
undefined is not a field object: (file 'maps/pam/sd.gsc', line 760)<br />
   else if ((level.weapons[weapon1_checker].classname == "sniper" || level.weapons[weapon2_checker].classname == "sniper") && self.sniper_owner != 1)<br />
                                                                                  *<br />
called from:<br />
(file 'maps/pam/sd.gsc', line 289)<br />
   spawnPlayer();<br />
   *<br />
called from:<br />
(file 'maps/mp/gametypes/_callbacksetup.gsc', line 38)<br />
 [[level.callbackPlayerConnect]]();<br />
         *<br />
started from:<br />
(file 'maps/pam/sd.gsc', line 1744)<br />
 wait 0; // Required for Callback_PlayerDisconnect to complete before updateTeamStatus can execute<br />
 *<br />
************************************<br />
********************<br />
ERROR: script runtime error<br />
(see console for details)<br />
(file 'maps/pam/sd.gsc', line 1744)<br />
<br />
********************


level.weapons is an array and here's an example how it looks like

Code:
	level.weapons = [];<br />
	level.weapons["greasegun_mp"] = spawnstruct();<br />
	level.weapons["greasegun_mp"].server_allowcvar = "scr_allow_greasegun";<br />
	level.weapons["greasegun_mp"].client_allowcvar = "ui_allow_greasegun";<br />
	level.weapons["greasegun_mp"].allow_default = 1;<br />
	level.weapons["greasegun_mp"].classname = "smg";<br />
	level.weapons["greasegun_mp"].team = "allies";


So those are problems I have, I've been trying to find solution for a month now (no success). If there is someone who might know solution, please help me!

Cheers
Share |
Restricted Access Topic is Locked 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

»