This forum is locked and will eventually go offline. If you have feedback to share you can find us in our Discord channel "MythoLogic Interactive" https://discord.gg/nECKnbT7gk

Forum rules

Gibbing bug

Here you can find all solved gameplay problems and bugs (beginning from Pre-Alpha 1.8.8).
Forum rules
By using the forum you agree to the following rules. For this forum you also need to follow these additional rules.
Locked
KostiaN
Meatbag
Posts: 1
Joined: Thu Apr 06, 2017 6:26 pm
SFD Account: KostiaN

Gibbing bug

Post by KostiaN » Thu Apr 06, 2017 6:30 pm

When in DM script gibbing someone by the death the game crashes!
0 x

User avatar
Gurt
Lead Programmer
Lead Programmer
Posts: 1887
Joined: Sun Feb 28, 2016 3:22 pm
Title: Lead programmer
Started SFD: Made it!
Location: Sweden
Gender:
Age: 36

Post by Gurt » Thu Apr 06, 2017 8:36 pm

 ! 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.
0 x
Gurt

User avatar
TheYourocktube
Meatbag
Posts: 7
Joined: Tue Mar 22, 2016 1:07 am
Title: Male
SFD Account: Yrk
Started SFD: When There Were 2 Genders
Location: USA
Contact:

Post by TheYourocktube » Thu Apr 06, 2017 11:14 pm

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
0 x

User avatar
Gurt
Lead Programmer
Lead Programmer
Posts: 1887
Joined: Sun Feb 28, 2016 3:22 pm
Title: Lead programmer
Started SFD: Made it!
Location: Sweden
Gender:
Age: 36

Post by Gurt » Fri Apr 07, 2017 8:41 pm

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();
	}
}
0 x
Gurt

Locked