When player kills himself he goes deaf !

Have questions about CoD2 mapping that aren't covered in the tutorials section? Post here!

Moderator: Core Staff

Post Reply
User avatar
<LT>YosemiteSam[NL]
Core Staff
Core Staff
Posts: 2155
Joined: December 7th, 2004, 2:07 am
Location: Netherlands
Contact:

When player kills himself he goes deaf !

Post by <LT>YosemiteSam[NL] » July 28th, 2010, 9:48 am

I added a mod in my map and the following problem occurs;
When a player dies cause of his own fault (kills himself by jumping down from too high up for instance) the sound "monsterkill" plays (what I don't want) and it plays at almost 3 times the normal game volume !? The monsterkill also plays when someone is on a monsterkill and then it sounds normal, so it's not the csv file.
Anyone have an idea on how to fix this ?
Here is the relevant code;

added two lines in the DM script ;

Code: Select all

dummy()
{
	waittillframeend;

	if(isdefined(self))
		level notify("connecting", self);
}

Callback_PlayerConnect()
{
	thread dummy();
/////////////////////////////////////////////////////////////
self.pers["kill_spree"] = 0;
/////////////////////////////////////////////////////////////
	self.statusicon = "hud_status_connecting";
	self waittill("begin");
	self.statusicon = "";

	level notify("connected", self);

	if(!level.splitscreen)
		iprintln(&"MP_CONNECTED", self);

	lpselfnum = self getEntityNumber();
	lpselfguid = self getGuid();
	logPrint("J;" + lpselfguid + ";" + lpselfnum + ";" + self.name + "\n");

Code: Select all

Callback_PlayerKilled(eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, psOffsetTime, deathAnimDuration)
{
	self endon("spawned");
	self notify("killed_player");

	if(self.sessionteam == "spectator")
		return;

	// If the player was killed by a head shot, let players know it was a head shot kill
	if(sHitLoc == "head" && sMeansOfDeath != "MOD_MELEE")
		sMeansOfDeath = "MOD_HEAD_SHOT";

/////////////////////////////////////////////////////

	thread maps\mp\_headshot::Messages(sMeansOfDeath, attacker);

/////////////////////////////////////////////////////

	// send out an obituary message to all clients about the kill
	obituary(self, attacker, sWeapon, sMeansOfDeath);

	self maps\mp\gametypes\_weapons::dropWeapon();
	self maps\mp\gametypes\_weapons::dropOffhand();

	self.sessionstate = "dead";
	self.statusicon = "hud_status_dead";

	if(!isdefined(self.switching_teams))
		self.deaths++;





The _headshot script;

Code: Select all

Messages(sMeansOfDeath, attacker)
{

		killcount = undefined;
		self.pers["kill_spree"] = 0;
//if(getCvar("spree") == "")
//		setCvar("spree", "0");


	if(sMeansOfDeath == "MOD_HEAD_SHOT")
	{
		distance = distance(Attacker.origin , self.origin); //Inches
		meters = distance * 0.0254;		          //Meters
		feet = distance / 12;			         //Feet

		if(!isDefined("shm_metric") || getcvar("shm_metric") == "")
		setcvar("shm_metric", "meters");

		if(getCVar("shm_metric") != "feet")
		{
		attacker playlocalSound("headshot");//voice message to attacker

		self playlocalSound("headshot"); //voice message to dead person

		}
	}


		attacker.pers["kill_spree"]++;//this is ok
		killcount = attacker.pers["kill_spree"];



	        if(killcount == 3)
		
			{
			//iprintln(killcount);
			iprintln("^5" + attacker.name + "^7 is on a ^1killing spree!");
			//playSoundOnPlayers("killingspree");
			self iprintlnBold("^1You ^7are killed by ^1" + attacker.name + "^7 who is on a ^1Killingspree!");
			self playlocalSound("killingspree");
			attacker playlocalSound("killingspree");
			}
			
		if(killcount == 4)
		
			{
			//iprintln(killcount);
			iprintln("^1" + attacker.name + "^7 is ^1Dominating!");
			//playSoundOnPlayers("dominating");
			self iprintlnBold("^1You ^7are killed by ^1" + attacker.name + "^7 who is ^1Dominating!");
			self playlocalSound("dominating");
			attacker playlocalSound("dominating");
			}

		if(killcount == 5)
		
			{
			//iprintln(killcount);
			iprintln("^1" + attacker.name + "^7 is ^1Unstoppable!");
			attacker iprintlnBold("^1Unstoppable!");
			//playSoundOnPlayers("unstoppable");
			self iprintlnBold("^1You ^7are killed by ^1" + attacker.name + "^7 who is ^1Unstoppable!");
			self playlocalSound("unstoppable");
			attacker playlocalSound("unstoppable");
			}
		
		if(killcount == 6)
		
			{
			//iprintln(killcount);
			iprintln("^1" + attacker.name + "^7 is ^1Godlike!");
			attacker iprintlnBold("^1You ^7are ^1Godlike!");
			//playSoundOnPlayers("godlike");
			self iprintlnBold("^1You ^7are killed by ^1" + attacker.name + "^7 who is ^1Godlike!");
			self playlocalSound("godlike");
			attacker playlocalSound("godlike");
			}
		
		if(killcount == 7)
		
			{
			//iprintln(killcount);
			iprintln("^1" + attacker.name + "^7 is on a ^1Monsterkill!");
			attacker iprintlnBold("^1Monsterkill!");
			//playSoundOnPlayers("monsterkill");
			self iprintlnBold("^1You ^7are killed by ^1" + attacker.name + "^7 who is on a ^1Monsterkill!");
			self playlocalSound("monsterkill");
			attacker playlocalSound("monsterkill");
			}
		
		if(killcount == 8)
		
			{
			//iprintln(killcount);
			iprintln("^1" + attacker.name + "^7 is on a ^1Monsterkill!");
			attacker iprintlnBold("^1Monsterkill!");
			//playSoundOnPlayers("monsterkill");
			self iprintlnBold("^1You ^7are killed by ^1" + attacker.name + "^7 who is on a ^1Monsterkill!");
			self playlocalSound("monsterkill");
			attacker playlocalSound("monsterkill");
			}
		
		if(killcount == 9)
		
			{
			//iprintln(killcount);
			iprintln("^1" + attacker.name + "^7 is on a ^1Monsterkill!");
			attacker iprintlnBold("^1Monsterkill!");
			//playSoundOnPlayers("monsterkill");
			self iprintlnBold("^1You ^7are killed by ^1" + attacker.name + "^7 who is on a ^1Monsterkill!");
			self playlocalSound("monsterkill");
			attacker playlocalSound("monsterkill");
			}

		if(killcount == 10)
		
			{
			//iprintln(killcount);
			iprintln("^1" + attacker.name + "^7 is on a ^1Monsterkill!");
			attacker iprintlnBold("^1Monsterkill!");
			//playSoundOnPlayers("monsterkill");
			self iprintlnBold("^1You ^7are killed by ^1" + attacker.name + "^7 who is on a ^1Monsterkill!");
			self playlocalSound("monsterkill");
			attacker playlocalSound("monsterkill");
			}

		if(killcount == 11)
		
			{
			//iprintln(killcount);
			iprintln("^1" + attacker.name + "^7 is still on a ^1Monsterkill!");
			attacker iprintlnBold("^1Monsterkill!");
			//playSoundOnPlayers("monsterkill");
			self iprintlnBold("^1You ^7are killed by ^1" + attacker.name + "^7 who is still on a ^1Monsterkill!");
			self playlocalSound("monsterkill");
			attacker playlocalSound("monsterkill");
			}

		if(killcount == 12)
		
			{
			//iprintln(killcount);
			iprintln("^1" + attacker.name + "^7 is still on a ^1Monsterkill!");
			attacker iprintlnBold("^1Monsterkill!");
			//playSoundOnPlayers("monsterkill");
			self iprintlnBold("^1You ^7are killed by ^1" + attacker.name + "^7 who is still on a ^1Monsterkill!");
			self playlocalSound("monsterkill");
			attacker playlocalSound("monsterkill");
			}
		
		if(killcount == 13)
		
			{
			//iprintln(killcount);
			iprintln("^1" + attacker.name + "^7 is still on a ^1Monsterkill!");
			attacker iprintlnBold("^1Monsterkill!");
			//playSoundOnPlayers("monsterkill");
			self iprintlnBold("^1You ^7are killed by ^1" + attacker.name + "^7 who is still on a ^1Monsterkill!");
			self playlocalSound("monsterkill");
			attacker playlocalSound("monsterkill");
			}
	
		if(killcount == 14)
		
			{
			//iprintln(killcount);
			iprintln("^1" + attacker.name + "^7 is still on a ^1Monsterkill!");
			attacker iprintlnBold("^1Monsterkill!");
			//playSoundOnPlayers("monsterkill");
			self iprintlnBold("^1You ^7are killed by ^1" + attacker.name + "^7 who is still on a ^1Monsterkill!");
			self playlocalSound("monsterkill");
			attacker playlocalSound("monsterkill");
			}
	
		if(killcount == 15)
		
			{
			//iprintln(killcount);
			iprintln("^1" + attacker.name + "^7 is still on a ^1Monsterkill!");
			attacker iprintlnBold("^1Monsterkill!");
			//playSoundOnPlayers("monsterkill");
			self iprintlnBold("^1You ^7are killed by ^1" + attacker.name + "^7 who is still on a ^1Monsterkill!");
			self playlocalSound("monsterkill");
			attacker playlocalSound("monsterkill");
			}

}


playSoundOnPlayers(sound, team)
{
	players = getentarray("player", "classname");

	if(level.splitscreen)
	{	
		if(isdefined(players[0]))
			players[0] playLocalSound(sound);
	}
	else
	{
		if(isdefined(team))
		{
			for(i = 0; i < players.size; i++)
			{
				if((isdefined(players[i].pers["team"])) && (players[i].pers["team"] == team))
					players[i] playLocalSound(sound);
			}
		}
		else
		{
			for(i = 0; i < players.size; i++)
				players[i] playLocalSound(sound);
		}
	}
}

User avatar
waywaaaard
Core Staff
Core Staff
Posts: 2214
Joined: February 6th, 2006, 3:18 pm
Location: Germany/Bayern

Re: When player kills himself he goes deaf !

Post by waywaaaard » July 28th, 2010, 10:49 am

I guess you have a killtrigger in the water or sth?

add to your function this

if(attacker == self) // killed himself
return;

So we don't do a sound if a player killed himself
THAT HANDS WERE NOT TRACED!
visit my blog: Link
Soviet wrote:Yeah, watch out, Peds will hit you with his +5 D-Battleaxe of homosexuality :roll:

User avatar
<LT>YosemiteSam[NL]
Core Staff
Core Staff
Posts: 2155
Joined: December 7th, 2004, 2:07 am
Location: Netherlands
Contact:

Re: When player kills himself he goes deaf !

Post by <LT>YosemiteSam[NL] » July 28th, 2010, 11:43 am

I have a hurt trigger in the water/poison but that doesn't cause the problem. I have it in other maps aswell.

Ok i'll try that m8, thx.

User avatar
<LT>YosemiteSam[NL]
Core Staff
Core Staff
Posts: 2155
Joined: December 7th, 2004, 2:07 am
Location: Netherlands
Contact:

Re: When player kills himself he goes deaf !

Post by <LT>YosemiteSam[NL] » July 28th, 2010, 10:20 pm

I put the lines in but I'm not sure I added them corectely.
But here is the error the console gives;
It only gives en error while testing the map in the codcompiler (devmap mode) cause ingame it only plays the sound and doesn't give an error.
You do not have the required permissions to view the files attached to this post.

User avatar
waywaaaard
Core Staff
Core Staff
Posts: 2214
Joined: February 6th, 2006, 3:18 pm
Location: Germany/Bayern

Re: When player kills himself he goes deaf !

Post by waywaaaard » July 29th, 2010, 10:02 am

Where did you add the those two lines? Show me your code please.
THAT HANDS WERE NOT TRACED!
visit my blog: Link
Soviet wrote:Yeah, watch out, Peds will hit you with his +5 D-Battleaxe of homosexuality :roll:

User avatar
<LT>YosemiteSam[NL]
Core Staff
Core Staff
Posts: 2155
Joined: December 7th, 2004, 2:07 am
Location: Netherlands
Contact:

Re: When player kills himself he goes deaf !

Post by <LT>YosemiteSam[NL] » July 29th, 2010, 10:14 am

I put it here but that's not good probably

Code: Select all

if(sMeansOfDeath == "MOD_HEAD_SHOT")
	{
		distance = distance(Attacker.origin , self.origin); //Inches
		meters = distance * 0.0254;		          //Meters
		feet = distance / 12;			         //Feet

		if(!isDefined("shm_metric") || getcvar("shm_metric") == "")
		setcvar("shm_metric", "meters");

		if(getCVar("shm_metric") != "feet")
		{
		attacker playlocalSound("headshot");//voice message to attacker

		self playlocalSound("headshot"); //voice message to dead person

		}
/////////////////////////////////////////////////////////////////
if(attacker == self) // killed himself
return;
/////////////////////////////////////////////////////////////////////////////////
	}


		attacker.pers["kill_spree"]++;//this is ok
		killcount = attacker.pers["kill_spree"];



	        if(killcount == 3)
		
			{
			//iprintln(killcount);
			iprintln("^5" + attacker.name + "^7 is on a ^1killing spree!");
			//playSoundOnPlayers("killingspree");
			self iprintlnBold("^1You ^7are killed by ^1" + attacker.name + "^7 who is on a ^1Killingspree!");
			self playlocalSound("killingspree");
			attacker playlocalSound("killingspree");
			}
			

User avatar
waywaaaard
Core Staff
Core Staff
Posts: 2214
Joined: February 6th, 2006, 3:18 pm
Location: Germany/Bayern

Re: When player kills himself he goes deaf !

Post by waywaaaard » July 29th, 2010, 10:33 am

should be at the top

Code: Select all

if(attacker == self) // killed himself
	return;


if(sMeansOfDeath == "MOD_HEAD_SHOT")
   {
      distance = distance(Attacker.origin , self.origin); //Inches
      meters = distance * 0.0254;                //Meters
      feet = distance / 12;                  //Feet

      if(!isDefined("shm_metric") || getcvar("shm_metric") == "")
      setcvar("shm_metric", "meters");

      if(getCVar("shm_metric") != "feet")
      {
      attacker playlocalSound("headshot");//voice message to attacker

      self playlocalSound("headshot"); //voice message to dead person

      }

   }


      attacker.pers["kill_spree"]++;//this is ok
      killcount = attacker.pers["kill_spree"];



           if(killcount == 3)
      
         {
         //iprintln(killcount);
         iprintln("^5" + attacker.name + "^7 is on a ^1killing spree!");
         //playSoundOnPlayers("killingspree");
         self iprintlnBold("^1You ^7are killed by ^1" + attacker.name + "^7 who is on a ^1Killingspree!");
         self playlocalSound("killingspree");
         attacker playlocalSound("killingspree");
         }
...
THAT HANDS WERE NOT TRACED!
visit my blog: Link
Soviet wrote:Yeah, watch out, Peds will hit you with his +5 D-Battleaxe of homosexuality :roll:

User avatar
<LT>YosemiteSam[NL]
Core Staff
Core Staff
Posts: 2155
Joined: December 7th, 2004, 2:07 am
Location: Netherlands
Contact:

Re: When player kills himself he goes deaf !

Post by <LT>YosemiteSam[NL] » July 29th, 2010, 11:56 am

aha..ok m8 thx.

User avatar
<LT>YosemiteSam[NL]
Core Staff
Core Staff
Posts: 2155
Joined: December 7th, 2004, 2:07 am
Location: Netherlands
Contact:

Re: When player kills himself he goes deaf !

Post by <LT>YosemiteSam[NL] » August 1st, 2010, 8:56 pm

With that line in my code the sound still played but I solved the problem :mrgreen:
This is the headshot script I added and changed the lines inbetween the forward slashe;

Code: Select all

Messages(sMeansOfDeath, attacker)
{

		//killcount = undefined;
		//self.pers["kill_spree"] = 0;

	if(sMeansOfDeath == "MOD_HEAD_SHOT")
	{
		distance = distance(Attacker.origin , self.origin); //Inches
		meters = distance * 0.0254;		          //Meters
		feet = distance / 12;			         //Feet

		if(!isDefined("shm_metric") || getcvar("shm_metric") == "")
		setcvar("shm_metric", "meters");

		if(getCVar("shm_metric") != "feet")
		{
		attacker playlocalSound("headshot");//voice message to attacker

		self playlocalSound("headshot"); //voice message to dead person

		}
	}


		//////attacker.pers["kill_spree"]++;//this is ok
		//////killcount = attacker.pers["kill_spree"];

///////////////////////////////////////////////////
if(!isDefined(attacker.pers["kill_spree"]))
  
   attacker.pers["kill_spree"] = 0;
   attacker.pers["kill_spree"]++;
   
   self.pers["kill_spree"] = 0;
   
   killcount = attacker.pers["kill_spree"];
////////////////////////////////////////////////////
               
                if(killcount == 3)
		
			{
			//iprintln(killcount);
			////iprintln("^5" + attacker.name + "^7 is on a ^1killing spree!");
			//playSoundOnPlayers("killingspree");
			////self iprintlnBold("^1You ^7are killed by ^1" + attacker.name + "^7 who is on a ^1Killingspree!");
			self playlocalSound("killingspree");
			attacker playlocalSound("killingspree");
			}
I still get an error but only when I use the compiler. In game it´s ok.

Post Reply

Who is online

Users browsing this forum: Baidu [Spider] and 3 guests