| 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] |
|
|
|
|
| Sweemanz |
General Member Since: Jun 18, 2006 Posts: 93 Last: Sep 20, 2006 [view latest posts] |
|
|
|
|
| sentchy |
General Member Since: May 6, 2006 Posts: 212 Last: Oct 31, 2006 [view latest posts] |
|
|
|
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 |
 |
|
|
| Sweemanz |
General Member Since: Jun 18, 2006 Posts: 93 Last: Sep 20, 2006 [view latest posts] |
|
|
|
|
| sentchy |
General Member Since: May 6, 2006 Posts: 212 Last: Oct 31, 2006 [view latest posts] |
|
|
|
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 |
 |
|
|
| Sweemanz |
General Member Since: Jun 18, 2006 Posts: 93 Last: Sep 20, 2006 [view latest posts] |
|
|
|
Category: CoD2 MP Mapping Posted: Sunday, Jul. 2, 2006 02:59 am |
 |
|
 |
|
|
| sentchy |
General Member Since: May 6, 2006 Posts: 212 Last: Oct 31, 2006 [view latest posts] |
|
|
|
|
| FlesyM |
General Member Since: Jul 24, 2005 Posts: 399 Last: Jan 24, 2008 [view latest posts] |
|
|
|
|
| ThE_TeMpLaR |
 |
General Member Since: May 5, 2006 Posts: 202 Last: Mar 16, 2007 [view latest posts] |
|
|
|
|
| sentchy |
General Member Since: May 6, 2006 Posts: 212 Last: Oct 31, 2006 [view latest posts] |
|
|
|
|
|
|
mp_TempleCall of Duty: Mods: Multiplayer (624.12Kb)
|