Gibbing bug
Posted: Thu Apr 06, 2017 6:30 pm
When in DM script gibbing someone by the death the game crashes!
- official home of Superfighters Deluxe!
https://www.mythologicinteractiveforums.com/
https://www.mythologicinteractiveforums.com/viewtopic.php?f=20&t=1755
Code: Select all
private HashSet<int> handledDeaths = new HashSet<int>();
public void Death(TriggerArgs args){
IPlayer ply = (IPlayer)args.Sender;
if (handledDeaths.Add(ply.UniqueID)) {
IUser user = ply.GetUser();
if (user != null && UserStillHere(user)){
spawnQueue.Add(new PlyData(ply, user, ply.GetTeam(), FromNow(RESPAWN_DELAY)));
Mod.Kills ++;
//Mod.Message(user.GetProfile().Name + " died!");
} else {
Game.PlayEffect("PWT", ply.GetWorldPosition(), "PLAYER LEFT");
Game.TriggerExplosion(ply.GetWorldPosition());
ply.Gib();
}
CheckGameOver();
}
}Gurt wrote:It turns out that gibbing, removing or killing the same player in its OnPlayerDeathEvent is a poor idea ever since the changes to this event in Alpha 1.2.0 since it will quickly call OnPlayerDeathEvent for each time you call gib, remove or kill - eventually hitting a stack overflow exception and SFD stops working.
This will be fixed after Alpha 1.2.1. so that scripts will work correctly again.
If you want to get the DM script to start working in this version without waiting for the next just replace the whole public void Death() function with the following:Code: Select all
private HashSet<int> handledDeaths = new HashSet<int>(); public void Death(TriggerArgs args){ IPlayer ply = (IPlayer)args.Sender; if (handledDeaths.Add(ply.UniqueID)) { IUser user = ply.GetUser(); if (user != null && UserStillHere(user)){ spawnQueue.Add(new PlyData(ply, user, ply.GetTeam(), FromNow(RESPAWN_DELAY))); Mod.Kills ++; //Mod.Message(user.GetProfile().Name + " died!"); } else { Game.PlayEffect("PWT", ply.GetWorldPosition(), "PLAYER LEFT"); Game.TriggerExplosion(ply.GetWorldPosition()); ply.Gib(); } CheckGameOver(); } }