Page 1 of 1

Gibbing bug

Posted: Thu Apr 06, 2017 6:30 pm
by KostiaN
When in DM script gibbing someone by the death the game crashes!

Re: Gibbing bug

Posted: Thu Apr 06, 2017 8:36 pm
by Gurt
 ! Message from: Gurt
If the bug is related to custom map-making then include a download link to the map illustrating the problem.
The map should be bare-bone - only include what's necessary in the map to illustrate the problem.

Re: Gibbing bug

Posted: Thu Apr 06, 2017 11:14 pm
by TheYourocktube
He is referring to the Deathmatch script created by # and yourself. The script needs some updating (so does the Team version). I believe the problem is with the gib part of it. Battle, DM, and TDM all auto gibs players. Link below.

http://sfdmaps.at.ua/_ld/1/194_DM.txt

Re: Gibbing bug

Posted: Fri Apr 07, 2017 8:41 pm
by Gurt
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 again 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();
	}
}
Added in 30 minutes 13 seconds:
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();
	}
}