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

Members Online

»
1 Active | 10 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 MP Mapping
CoD 2 mapping and level design.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked
Page
Previous Page Next Page
subscribe
Author Topic: making placed weapons respawn in cod 2
Sweemanz
General Member
Since: Jun 18, 2006
Posts: 93
Last: Sep 20, 2006
[view latest posts]
Level 3
Category: CoD2 MP Mapping
Posted: Saturday, Jul. 1, 2006 04:57 pm
Oh ok thanks flesym now i understand it!!!!!
thanks again well se wat happens again
Share |
Sweemanz
General Member
Since: Jun 18, 2006
Posts: 93
Last: Sep 20, 2006
[view latest posts]
Level 3
Category: CoD2 MP Mapping
Posted: Saturday, Jul. 1, 2006 05:17 pm
well i did it
key:targetname
value:weapons


Got this error

******* script runtime error *******
array is not a field object: (file 'maps/mp/mp_how.gsc', line 14)
if(!isdefined(weapons.script_timescale))
*
called from:
(file 'maps/mp/mp_how.gsc', line 4)
WeaponRespawner("weapons", 5);
*
started from:
(file 'maps/mp/mp_how.gsc', line 1)
main()
*
************************************
dont know but it isnt liking wat i put in
Share |
sentchy
General Member
Since: May 6, 2006
Posts: 212
Last: Oct 31, 2006
[view latest posts]
Level 4
Category: CoD2 MP Mapping
Posted: Saturday, Jul. 1, 2006 08:15 pm
When I pasted the code into the forum the array brackets got removed for some reason. Instead of having the following two lines in the code:

Code:
if(!isdefined(weapons[i].script_timescale))
weapons[i].script_timescale = defaultrespawndelay;
...
weapons[i] thread weapon_think(weapons.script_timescale);


it got turned into the folliwing lines without the [ i ] part since the forum though that the bracket i part was for formating as italics,:

Code:

if(!isdefined(weapons.script_timescale))
  weapons.script_timescale = defaultrespawndelay;
...
weapons thread weapon_think(weapons.script_timescale);


Here is the script corrected without the eliminated array reference:

Code:

main()
{
  maps\mp\_load::main();
  WeaponRespawner("weapons", 5);
}

WeaponRespawner(targetname, defaultrespawndelay)
{
weapons = getentarray(targetname, "targetname");
if(weapons.size > 0)
{
for(i=0; i < weapons.size; i++) 
{
if(!isdefined(weapons[i].script_timescale))
weapons[i].script_timescale = defaultrespawndelay;

// kick off a thread to listen for when the item gets picked up
weapons[i] thread weapon_think(weapons.script_timescale);
}
}
}

// self = weapon reference
weapon_think(delaytime)
{
// capture important weapon data first to allow us to respawn them
classname = self.classname;
model = self.model;
count = self.count;
org = self.origin;
angles = self.angles;

targetname = self.targetname;

// Wait till the weapon gets picked up
self waittill("trigger");

// Wait the delay before respawn
wait delaytime;

// respawn the weapon
weapon = spawn(classname, org);
weapon.angles = angles;
weapon.count = count;
weapon setmodel(model); 
weapon.script_timescale = delaytime;
weapon.targetname = targetname;

// Kick off a new thread with the new weapon and kill the old one
weapon thread weapon_think(delaytime);
}


edited on Jul. 1, 2006 04:21 pm by sentchy
Share |
Sweemanz
General Member
Since: Jun 18, 2006
Posts: 93
Last: Sep 20, 2006
[view latest posts]
Level 3
Category: CoD2 MP Mapping
Posted: Sunday, Jul. 2, 2006 01:27 am
is the array necessary?

i got this error

******* script runtime error *******
array is not a field object: (file 'maps/mp/mp_how.gsc', line 18)
weapons thread weapon_think(weapons.script_timescale);
*
called from:
(file 'maps/mp/mp_how.gsc', line 4)
WeaponRespawner("weapons", 5);
*
started from:
(file 'maps/mp/mp_how.gsc', line 1)
main()
*
************************************
just a diffirent line im not sure wat is wrong hmm
i dont really know scripts other wise i could probebly figure this out jeesh it doesnt like something when i call it up from radient

edited on Jul. 1, 2006 09:28 pm by Sweemanz
Share |
sentchy
General Member
Since: May 6, 2006
Posts: 212
Last: Oct 31, 2006
[view latest posts]
Level 4
Category: CoD2 MP Mapping
Posted: Sunday, Jul. 2, 2006 02:10 am
Got to the line in error and add the [ i ] part that is missing:

Change

Code:
weapons thread weapon_think(weapons.script_timescale);


to

Code:
weapons[i] thread weapon_think(weapons[i].script_timescale);


You need the array if you want to have more than one weapon that can respawns.

The complete correct code is:

Code:
main()
{
  maps\mp\_load::main();
  WeaponRespawner("weapons", 5);
}

WeaponRespawner(targetname, defaultrespawndelay)
{
weapons = getentarray(targetname, "targetname");
if(weapons.size > 0)
{
for(i=0; i < weapons.size; i++) 
{
if(!isdefined(weapons[i].script_timescale))
weapons[i].script_timescale = defaultrespawndelay;

// kick off a thread to listen for when the item gets picked up
weapons[i] thread weapon_think(weapons[i].script_timescale);
}
}
}

// self = weapon reference
weapon_think(delaytime)
{
// capture important weapon data first to allow us to respawn them
classname = self.classname;
model = self.model;
count = self.count;
org = self.origin;
angles = self.angles;

targetname = self.targetname;

// Wait till the weapon gets picked up
self waittill("trigger");

// Wait the delay before respawn
wait delaytime;

// respawn the weapon
weapon = spawn(classname, org);
weapon.angles = angles;
weapon.count = count;
weapon setmodel(model); 
weapon.script_timescale = delaytime;
weapon.targetname = targetname;

// Kick off a new thread with the new weapon and kill the old one
weapon thread weapon_think(delaytime);
}


edited on Jul. 1, 2006 10:12 pm by sentchy
Share |
Sweemanz
General Member
Since: Jun 18, 2006
Posts: 93
Last: Sep 20, 2006
[view latest posts]
Level 3
Category: CoD2 MP Mapping
Posted: Sunday, Jul. 2, 2006 02:59 am
WOOOOOOOOOOOOT U ROCK DUDE IT WORKED FINALLY!!!!!!!!!!
WAAAAAAAAAAAHOOOOOOOOO[thumbs_up][wave][thumbs_up][crazy][biggrin][casanova][rocking][rocking][rocking]
thanks a heap dude
i owe u Three!!![jumping]
Share |
sentchy
General Member
Since: May 6, 2006
Posts: 212
Last: Oct 31, 2006
[view latest posts]
Level 4
Category: CoD2 MP Mapping
Posted: Sunday, Jul. 2, 2006 03:02 am
Great, your welcome!

Next time I am more carefully with pasting code and making sure to use the protecting "code" button.

Cheers!
Share |
FlesyM
General Member
Since: Jul 24, 2005
Posts: 399
Last: Jan 24, 2008
[view latest posts]
Level 5
Category: CoD2 MP Mapping
Posted: Sunday, Jul. 2, 2006 06:54 pm
it works real well. excellent job.
Share |
ThE_TeMpLaR
General Member
Since: May 5, 2006
Posts: 202
Last: Mar 16, 2007
[view latest posts]
Level 4
Category: CoD2 MP Mapping
Posted: Thursday, Jul. 6, 2006 07:13 am
Sentchy...you script god!!! I'll come running to ya when i need script help....[thumbs_up]
Share |
sentchy
General Member
Since: May 6, 2006
Posts: 212
Last: Oct 31, 2006
[view latest posts]
Level 4
Category: CoD2 MP Mapping
Posted: Thursday, Jul. 6, 2006 12:03 pm
Not a script god =p

I just have stopped coding for real a few years ago when I climbed the management ladder to high. Now I miss the coding and COD2 is such a fun outlet to code a little again. Even with its shortcomings the COD2 engine is so exciting to me with how easy you can create your own game. Before script engines this would have been days of coding and not an hour or so.
Share |
Restricted Access Topic is Locked
Page
Previous Page Next Page
subscribe
MODSonline.com Forums : Call of Duty 2 : CoD2 MP Mapping

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

»