I cba to read backwards to find your question you seek... but I will guide you through the code and see if I can help...
Ok, taking the code line/section at a time...
Code: Select all
1.
WeaponRespawner(targetname, defaultrespawndelay)
{
Ok, first off, the
FUNCTION is called "WeaponRespawner".
Inside the brackets the function ask for two
VARIABLES; "targetname" and "defaultrespawndelay" (I will explain each variable when I get to them in the next section.)
Code: Select all
2.
weapons = getentarray(targetname, "targetname");
This will find all
ENTITIES with the targetname you assign when you call the function (See 1.)
This will check to find out if any entities exist, if true, continue. (Size is not a measurement, but a count).
Code: Select all
4.
for(i=0; i < weapons.size; i++)
{
This creates a looping thread which will be called the same amount of times as the amount of weapons there are.
Code: Select all
5.
if(!isdefined(weapons[i].script_timescale))
weapons[i].script_timescale = defaultrespawndelay;
This will check the weapon (entity) if the variable '.script_timescale' exists. If it does not exist, then a default time you provided (See 1.) will be used.
Code: Select all
6.
weapons[i] thread weapon_think(weapons[i].script_timescale);
This will send the entity into a new function (See 7.) to check for when it gets picked up, the variable which was assigned earlier (See 5.) is also sent.
Clsoe all open brackets.
New function for checking when a weapon is picked up.
Code: Select all
8.
classname = self.classname;
model = self.model;
count = self.count;
org = self.origin;
angles = self.angles;
targetname = self.targetname;
The function then records all variables for later recall.
The following is collected, classname (determines which
type of entity it is), model (the model of the entity), count (not sure what this for), origin (the coordinates of the entity), angles (the angles of the entity), targetname (the name which has been assigned to the entity).
Wait until the trigger is used (weapon is picked up),
Wait the delaytime before continuing the function.
Code: Select all
11.
weapon = spawn(classname, org);
Spawn a NEW entity, with the same classname and origin.
Code: Select all
12.
weapon.angles = angles;
weapon.count = count;
weapon setmodel(model);
weapon.script_timescale = delaytime;
weapon.targetname = targetname;
Assign the new entity with same values of the entity recorded earlier.
Code: Select all
13.
weapon thread weapon_think(delaytime);
}
Restart this thread. Once this is called, the current thread ends and the new one begins.
Hopefully something in their answers you question.