Dear forum users! In compliance with the new European GDPR regulations, we'd just like to inform you that if you have an account, your email address is stored in our database. We do not share your information with third parties, and your email address and password are encrypted for security reasons.
New to the forum? Say hello in this topic! Also make sure to read the rules.
New to the forum? Say hello in this topic! Also make sure to read the rules.
delete corpses & gibs after few seconds
Forum rules
By using the forum you agree to the following rules.
By using the forum you agree to the following rules.
- The_JOKER
- Fighter
- Posts: 38
- Joined: Mon Jul 18, 2016 2:35 am
- Title: I'm Korean JOKER :)
- SFD Account: JOKER_Korea
- SFD Alias: JOKER
- Started SFD: April 2016
- Location: South Korea
- Gender:
- Age: 23
- Contact:
delete corpses & gibs after few seconds
since corpses and gibs are making the map buggy,
is it able to delete after few seconds with script?
is it able to delete after few seconds with script?
0 x
- JakSparro98
- Superfighter
- Posts: 530
- Joined: Fri Jul 15, 2016 7:56 pm
- Started SFD: PreAlpha 1.0.5
- Location: Rome, Italy
- Gender:
- Age: 25
Let me guess, the previous script you requested to me doesn't remove corpses? I knew that gibbed parts aren't removed, I can include some script to your current respawn system to fix this.
0 x
- The_JOKER
- Fighter
- Posts: 38
- Joined: Mon Jul 18, 2016 2:35 am
- Title: I'm Korean JOKER :)
- SFD Account: JOKER_Korea
- SFD Alias: JOKER
- Started SFD: April 2016
- Location: South Korea
- Gender:
- Age: 23
- Contact:
no, It does remove player's corpses, but I want to delete Bot's Corpses and Gibs after few secondsJakSparro98 wrote: ↑Thu Aug 17, 2017 1:48 pmLet me guess, the previous script you requested to me doesn't remove corpses? I knew that gibbed parts aren't removed, I can include some script to your current respawn system to fix this.
I'm making D-Day map and u know, there are toooo many corpses.
give me without respawn script unless they conflict together.
0 x
- JakSparro98
- Superfighter
- Posts: 530
- Joined: Fri Jul 15, 2016 7:56 pm
- Started SFD: PreAlpha 1.0.5
- Location: Rome, Italy
- Gender:
- Age: 25
You only need to add this piece of code at bottom of the script page:
Code: Select all
public void CleanCorpses(TriggerArgs arg)
{
foreach(IPlayer pl in Game.GetPlayers())
{
if (pl.IsDead && pl.IsBot)
pl.Remove();
}
string[] IDs={"giblet00","giblet01","giblet02","giblet03","giblet04"};
foreach(IObject ToRemove in Game.GetObjectsByName(IDs))
ToRemove.Remove();
}
Place a TimerTrigger with method CleanCorpses, finally a time interval you like; make sure the timer is looped.
0 x
- The_JOKER
- Fighter
- Posts: 38
- Joined: Mon Jul 18, 2016 2:35 am
- Title: I'm Korean JOKER :)
- SFD Account: JOKER_Korea
- SFD Alias: JOKER
- Started SFD: April 2016
- Location: South Korea
- Gender:
- Age: 23
- Contact:
It's Not exactly what I expected, but the problem is solved. thanks a lotJakSparro98 wrote: ↑Thu Aug 17, 2017 3:19 pmYou only need to add this piece of code at bottom of the script page:This will dispose all the gibs and bots corpses only.Code: Select all
public void CleanCorpses(TriggerArgs arg) { foreach(IPlayer pl in Game.GetPlayers()) { if (pl.IsDead && pl.IsBot) pl.Remove(); } string[] IDs={"giblet00","giblet01","giblet02","giblet03","giblet04"}; foreach(IObject ToRemove in Game.GetObjectsByName(IDs)) ToRemove.Remove(); }
Place a TimerTrigger with method CleanCorpses, finally a time interval you like; make sure the timer is looped.
0 x
- JakSparro98
- Superfighter
- Posts: 530
- Joined: Fri Jul 15, 2016 7:56 pm
- Started SFD: PreAlpha 1.0.5
- Location: Rome, Italy
- Gender:
- Age: 25
Maybe you expected that corpses and gibs are destroyed in x second from the moment they are created? If you like this other way of disposing objects I can change that, you decide.
0 x
- The_JOKER
- Fighter
- Posts: 38
- Joined: Mon Jul 18, 2016 2:35 am
- Title: I'm Korean JOKER :)
- SFD Account: JOKER_Korea
- SFD Alias: JOKER
- Started SFD: April 2016
- Location: South Korea
- Gender:
- Age: 23
- Contact:
yes pleaseJakSparro98 wrote: ↑Fri Aug 18, 2017 1:04 pmMaybe you expected that corpses and gibs are destroyed in x second from the moment they are created? If you like this other way of disposing objects I can change that, you decide.
1 x
- JakSparro98
- Superfighter
- Posts: 530
- Joined: Fri Jul 15, 2016 7:56 pm
- Started SFD: PreAlpha 1.0.5
- Location: Rome, Italy
- Gender:
- Age: 25
Ok, so, replace the last piece of code I gave to you to clean bot corpses and giblets with this:
Code: Select all
class CleanItem
{
public static List<CleanItem> CleanList = new List<CleanItem>();
public IObject item;
public float Time=0;
public CleanItem(IObject ItemToRemove, float _Time)
{
Time=_Time;
item=ItemToRemove;
CleanList.Add(this);
}
public void Remove()
{
CleanList.Remove(this);
item.Remove();
}
}
const int CleanInterval=3; //in seconds
public void CleanCorpses(TriggerArgs arg)
{CleanItem itm;
foreach(IPlayer pl in Game.GetPlayers())
if (pl.IsDead && pl.IsBot && CleanItem.CleanList.Find(tmp => tmp.item.Equals(pl))==null)
itm= new CleanItem(pl,Game.TotalElapsedGameTime);
string[] IDs={"giblet00","giblet01","giblet02","giblet03","giblet04"};
foreach(IObject ToRemove in Game.GetObjectsByName(IDs))
if(CleanItem.CleanList.Find(tmp => tmp.item.Equals(ToRemove))==null)
itm= new CleanItem(ToRemove,Game.TotalElapsedGameTime);
for(int i=0; i<CleanItem.CleanList.Count;i++)
if(IsElapsed(CleanItem.CleanList[i].Time,CleanInterval*1000))
CleanItem.CleanList[i].Remove();
}
You can modify the time to clean with CleanInterval.
0 x
- The_JOKER
- Fighter
- Posts: 38
- Joined: Mon Jul 18, 2016 2:35 am
- Title: I'm Korean JOKER :)
- SFD Account: JOKER_Korea
- SFD Alias: JOKER
- Started SFD: April 2016
- Location: South Korea
- Gender:
- Age: 23
- Contact:
Working good, ThanksJakSparro98 wrote: ↑Fri Aug 18, 2017 3:58 pmThen keep the timer that activates the method but make it to repeat after 0 seconds interval (istantly).
You can modify the time to clean with CleanInterval.
0 x
- JakSparro98
- Superfighter
- Posts: 530
- Joined: Fri Jul 15, 2016 7:56 pm
- Started SFD: PreAlpha 1.0.5
- Location: Rome, Italy
- Gender:
- Age: 25
If you want to only clear gibs you need to copy the script code I posted previously.
I split the script in two threads because I was no idea how Joker wanted the script to work, the complete script was supposed to respawn two teams, and is this:
Code: Select all
const int RespawnSeconds = 15;
const int CleanInterval=3; //seconds to clean gibs
static List < DeadPlayer > DPlayersList = new List < DeadPlayer > ();
static Vector2 Team1SpawnPoint = Vector2.Zero;
static Vector2 Team2SpawnPoint = Vector2.Zero;
Events.PlayerDeathCallback m_playerDeathEvent = null;
Events.UpdateCallback m_updateEvent = null;
class DeadPlayer {
IProfile P_profile;
public IUser P_user;
IPlayer P_body;
public float P_DeathTime = 0f;
PlayerTeam P_team;
public DeadPlayer(IPlayer player) {
P_profile = player.GetProfile();
P_user = player.GetUser();
P_DeathTime = Game.TotalElapsedGameTime;
P_body = player;
P_team = player.GetTeam();
}
public void Respawn() {
IPlayer pl = Game.CreatePlayer(Vector2.Zero);
switch(this.P_team)
{
case PlayerTeam.Team1:
pl.SetWorldPosition(Team1SpawnPoint);
break;
case PlayerTeam.Team2:
pl.SetWorldPosition(Team2SpawnPoint);
break;
}
pl.SetUser(this.P_user);
pl.SetProfile(this.P_profile);
pl.SetTeam(this.P_team);
this.P_body.Remove();
DPlayersList.Remove(this);
}
}
public void OnStartup() {
m_playerDeathEvent = Events.PlayerDeathCallback.Start(OnPlayerDeath);
m_updateEvent = Events.UpdateCallback.Start(OnUpdate, 0);
}
public void OnPlayerDeath(IPlayer player) {
if (!player.IsBot && DPlayersList.FirstOrDefault(s => s.P_user.UserID == player.GetUser().UserID) == null) {
DeadPlayer pl = new DeadPlayer(player);
DPlayersList.Add(pl);
}
}
public void OnUpdate(float elapsed) {
for (int i = 0; i < DPlayersList.Count; i++)
if (IsElapsed(DPlayersList[i].P_DeathTime, RespawnSeconds * 1000))
DPlayersList[i].Respawn();
}
public void SetSpawnPoint(TriggerArgs arg) {
switch(((IObject) arg.Caller).CustomID)
{
case "Team1SpawnPoint":
Team1SpawnPoint = ((IObject) arg.Caller).GetWorldPosition();
break;
case "Team2SpawnPoint":
Team2SpawnPoint = ((IObject) arg.Caller).GetWorldPosition();
break;
}
}
public static bool IsElapsed(float TimeStarted, float TimeToElapse) {
if ((float)(Game.TotalElapsedGameTime - TimeStarted) >= TimeToElapse)
return true;
else
return false;
}
class CleanItem
{
public static List<CleanItem> CleanList = new List<CleanItem>();
public IObject item;
public float Time=0;
public CleanItem(IObject ItemToRemove, float _Time)
{
Time=_Time;
item=ItemToRemove;
CleanList.Add(this);
}
public void Remove()
{
CleanList.Remove(this);
item.Remove();
}
}
public void CleanCorpses(TriggerArgs arg)
{CleanItem itm;
foreach(IPlayer pl in Game.GetPlayers())
if (pl.IsDead && pl.IsBot && CleanItem.CleanList.Find(tmp => tmp.item.Equals(pl))==null)
itm= new CleanItem(pl,Game.TotalElapsedGameTime);
string[] IDs={"giblet00","giblet01","giblet02","giblet03","giblet04"};
foreach(IObject ToRemove in Game.GetObjectsByName(IDs))
if(CleanItem.CleanList.Find(tmp => tmp.item.Equals(ToRemove))==null)
itm= new CleanItem(ToRemove,Game.TotalElapsedGameTime);
for(int i=0; i<CleanItem.CleanList.Count;i++)
if(IsElapsed(CleanItem.CleanList[i].Time,CleanInterval*1000))
CleanItem.CleanList[i].Remove();
}
0 x