Making weapons respawn in mp map ?
Moderator: Core Staff
-
- Core Staff
- Posts: 2155
- Joined: December 7th, 2004, 2:07 am
- Location: Netherlands
- Contact:
Making weapons respawn in mp map ?
Does someone know how to make weapons respawn in a mp_map ?
And can you make it so that when you pick the weapon up the weapon you drop will fall onto the floor instead of replacing the one you pick up?
And can you make it so that when you pick the weapon up the weapon you drop will fall onto the floor instead of replacing the one you pick up?
-
- Core Staff
- Posts: 14220
- Joined: October 21st, 2004, 7:17 pm
- Location: Holland
- Contact:
From all the MP maps I have seen is that whenever you pick up a weapon which has been placed there by the creator of the map it will disappear.
That's just one point from me, I'm no mapper. There must be one here who knows more than me.
That's just one point from me, I'm no mapper. There must be one here who knows more than me.
matt101harris wrote:big cock was the first thing that came to my head lol
-
- Core Staff
- Posts: 2155
- Joined: December 7th, 2004, 2:07 am
- Location: Netherlands
- Contact:
-
- CJ Worshipper
- Posts: 383
- Joined: December 16th, 2005, 6:38 pm
-
- Core Staff
- Posts: 14220
- Joined: October 21st, 2004, 7:17 pm
- Location: Holland
- Contact:
-
- CJ Worshipper
- Posts: 383
- Joined: December 16th, 2005, 6:38 pm
I am not 100% sure, but I do not think that is possible. It might be, but you are going to have to dig pretty deep.
Coding is Poetry. Mapping is Art.
"Cause im the sexiest mapper ever...except for nm, that sexy man" - Soviet
-=[CoDJumper.com Movies]=-
[Ambush] || [Backlot] || [Bloc] || [Bog] || [Broadcast] || [Chinatown] || [Countdown]
[Crash] || [Creek] || [Crossfire] || [District] || [Downpour] || [Killhouse] || [Overgrown]
[Pipeline] || [Shipment & Wetwork] || [Showdown] || [Strike] || [Vacant]
"Cause im the sexiest mapper ever...except for nm, that sexy man" - Soviet
-=[CoDJumper.com Movies]=-
[Ambush] || [Backlot] || [Bloc] || [Bog] || [Broadcast] || [Chinatown] || [Countdown]
[Crash] || [Creek] || [Crossfire] || [District] || [Downpour] || [Killhouse] || [Overgrown]
[Pipeline] || [Shipment & Wetwork] || [Showdown] || [Strike] || [Vacant]
-
- Core Staff
- Posts: 2155
- Joined: December 7th, 2004, 2:07 am
- Location: Netherlands
- Contact:
Ok, when it takes too much time and effort I won't wurry about it anymore
However, when you pick up the spawnable weapon, the weapon in your hand takes the place of that weapon. Does that weapon dissapear in a while or does it stay there till the end of the map ?
And if it stays there is it possible to let it dissapear after let's say 1 minute ?
For the spawnable weapon I have this script;
I think the answer to my question is in there somewhere but I can't figure out where ?
However, when you pick up the spawnable weapon, the weapon in your hand takes the place of that weapon. Does that weapon dissapear in a while or does it stay there till the end of the map ?
And if it stays there is it possible to let it dissapear after let's say 1 minute ?
For the spawnable weapon I have this script;
Code: Select all
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);
}
-
- Core Staff
- Posts: 13313
- Joined: April 13th, 2005, 8:22 pm
- Location: UK, London
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...
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.)
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).
This creates a looping thread which will be called the same amount of times as the amount of weapons there are.
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.
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.
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.
Spawn a NEW entity, with the same classname and origin.
Assign the new entity with same values of the entity recorded earlier.
Restart this thread. Once this is called, the current thread ends and the new one begins.
Hopefully something in their answers you question.
Ok, taking the code line/section at a time...
Code: Select all
1.
WeaponRespawner(targetname, defaultrespawndelay)
{
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");
Code: Select all
3.
if(weapons.size > 0)
{
Code: Select all
4.
for(i=0; i < weapons.size; i++)
{
Code: Select all
5.
if(!isdefined(weapons[i].script_timescale))
weapons[i].script_timescale = defaultrespawndelay;
Code: Select all
6.
weapons[i] thread weapon_think(weapons[i].script_timescale);
Code: Select all
}
}
}
Code: Select all
7.
weapon_think(delaytime)
{
Code: Select all
8.
classname = self.classname;
model = self.model;
count = self.count;
org = self.origin;
angles = self.angles;
targetname = self.targetname;
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).
Code: Select all
9.
self waittill("trigger");
Code: Select all
10.
wait delaytime;
Code: Select all
11.
weapon = spawn(classname, org);
Code: Select all
12.
weapon.angles = angles;
weapon.count = count;
weapon setmodel(model);
weapon.script_timescale = delaytime;
weapon.targetname = targetname;
Code: Select all
13.
weapon thread weapon_think(delaytime);
}
Hopefully something in their answers you question.
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010
-
- Core Staff
- Posts: 2155
- Joined: December 7th, 2004, 2:07 am
- Location: Netherlands
- Contact:
-
- Core Staff
- Posts: 13313
- Joined: April 13th, 2005, 8:22 pm
- Location: UK, London
-
- Core Staff
- Posts: 2155
- Joined: December 7th, 2004, 2:07 am
- Location: Netherlands
- Contact:
ok;
1 - Player picks up spawnable weapon. (Panzershreck in this case)
2 - The weapon he was holding at the moment of pick up replaces the spawnable weapon.
This part works like a charm but I want also the following thing to happen,
3 - The weapon the player was holding now lies on the spot where the panzershreck will spawn again.
4 - I want that weapon to dissapear before the panzershreck respawns.
I think the command for that should go between 10 and 11, should be something like this;
1 - Player picks up spawnable weapon. (Panzershreck in this case)
2 - The weapon he was holding at the moment of pick up replaces the spawnable weapon.
This part works like a charm but I want also the following thing to happen,
3 - The weapon the player was holding now lies on the spot where the panzershreck will spawn again.
4 - I want that weapon to dissapear before the panzershreck respawns.
I think the command for that should go between 10 and 11, should be something like this;
Code: Select all
10.
wait delaytime;
Code: Select all
Remove weapon ???? which command
Code: Select all
11.
weapon = spawn(classname, org);
-
- Core Staff
- Posts: 13313
- Joined: April 13th, 2005, 8:22 pm
- Location: UK, London
delete(); is the command you seek.
Just before the weapon respawns, IF the weapon is still in the same place (same origin), then "entity delete();"
if delete doesn't work, try destroy(); I often get these 2 muddled
Just before the weapon respawns, IF the weapon is still in the same place (same origin), then "entity delete();"
if delete doesn't work, try destroy(); I often get these 2 muddled
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010
Who is online
Users browsing this forum: No registered users and 39 guests