Raised This Month: $ Target: $400
 0% 

Person killed by certain weapon plays a sound


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Banjo Boy
Member
Join Date: Apr 2008
Old 08-06-2008 , 23:56   Person killed by certain weapon plays a sound
Reply With Quote #1

I want to make it so if you are killed by a player who kills you with a weapon_hook that a sound playing to everyone called "banjoboy/pwnd.mp3"
is played and that it notifies in chat that he was killed by a hook. If this seems like too much work, please don't waist your time I'm sure you have better things to do, but if you do help me I will give you my thanks

Have A Good Day,

Banjo Boy.
__________________
Banjo Boy is offline
DiscoBBQ
Veteran Member
Join Date: Jan 2005
Location: Clemson, South Carolina
Old 08-07-2008 , 00:17   Re: Person killed by certain weapon plays a sound
Reply With Quote #2

First step would be precaching the sound.

Code:
 
//Forward that is called everytime a new map is initialized:
public OnMapStart()
{
 
 //Precaches the sound:
 PrecacheSound("banjoboy/pwnd.mp3", true);
 
 //Forces download of the sound:
 AddFileToDownloadsTable("sound/banjoboy/pwnd.mp3");
}

The next step would be to trigger the sound when they are killed by a weapon_hook (I'm not sure what game this is for? Never heard of weapon_hook)

Code:
//Another forward called one time, when the plugin is initialized:
public OnPluginStart()
{
 
 //Hook death event with the function "EventDeath":
 HookEvent("player_death", EventDeath);
}
 
//Function that is hooked with the event "player_death":
public Action:EventDeath(Handle:Event, const String:Name[], bool:Broadcast)
{
 
 //Declare:
 decl Client, Attacker;
 
 //Initialize id's:
 Client = GetClientOfUserId(GetEventInt(Event, "userid"));
 Attacker = GetClientOfUserId(GetEventInt(Event, "attacker"));
 
 //Not world damage (falling, door crush, etc):
 if(Attacker != 0)
 {
 
  //Declare:
  decl String:WeaponName[32];
 
  //Get the weapon name:
  GetClientWeapon(Attacker, WeaponName, 32);
 
  //If it is equal to "weapon_hook":
  if(StrEqual(WeaponName, "weapon_hook", false))
  {
 
   //Play the sound:
   EmitSoundToClient(Client, "banjoboy/pwnd.mp3");
  }
 }
}
__________________
"Every man is guilty of all the good he did not do"
DiscoBBQ is offline
Banjo Boy
Member
Join Date: Apr 2008
Old 08-07-2008 , 01:11   Re: Person killed by certain weapon plays a sound
Reply With Quote #3

Thanks alot Pinfairie! Your'e the man! BTW, the games Pirates Vikings and Knights II. I love that HL2 Mod with a passion. If you want to check it out heres the website: www.pvkii.com

Thanks alot for making this for me! Much appreciated!

Banjo Boy
__________________
Banjo Boy is offline
Banjo Boy
Member
Join Date: Apr 2008
Old 08-07-2008 , 01:20   Re: Person killed by certain weapon plays a sound
Reply With Quote #4

I got errors:

Your plugin failed to compile! Read the errors below:
SourcePawn Compiler 1.0.2.2138
Copyright (c) 1997-2006, ITB CompuPhase, (C)2004-2008 AlliedModders, LLC

/home/groups/sourcemod/upload_tmp/textQhDU1M.sp(9) : error 017: undefined symbol "AddFileToDownloadsTable"
/home/groups/sourcemod/upload_tmp/textQhDU1M.sp(45) : error 017: undefined symbol "EmitSoundToClient"
/home/groups/sourcemod/upload_tmp/textQhDU1M.sp(27) : warning 204: symbol is assigned a value that is never used: "Client"

2 Errors.


EDIT: Whats the name of that girl thats your avatar.
__________________

Last edited by Banjo Boy; 08-07-2008 at 01:32.
Banjo Boy is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 08-07-2008 , 04:40   Re: Person killed by certain weapon plays a sound
Reply With Quote #5

You need to include SDK Tools too (#include <sdktools> at the top). For the warning you should move Client = GetClientOfUserId(GetEventInt(Event, "userid")); into the if(StrEqual(WeaponName, "weapon_hook", false)).
__________________
Advertisements | REST in Pawn - HTTP client for JSON REST APIs
Please do not PM me with questions. Post in the plugin thread.
DJ Tsunami is offline
DiscoBBQ
Veteran Member
Join Date: Jan 2005
Location: Clemson, South Carolina
Old 08-07-2008 , 10:50   Re: Person killed by certain weapon plays a sound
Reply With Quote #6

Quote:
Originally Posted by Banjo Boy View Post
EDIT: Whats the name of that girl thats your avatar.
Misa Campo
__________________
"Every man is guilty of all the good he did not do"
DiscoBBQ is offline
Banjo Boy
Member
Join Date: Apr 2008
Old 08-07-2008 , 12:02   Re: Person killed by certain weapon plays a sound
Reply With Quote #7

Quote:
Originally Posted by DJ Tsunami View Post
You need to include SDK Tools too (#include <sdktools> at the top). For the warning you should move Client = GetClientOfUserId(GetEventInt(Event, "userid")); into the if(StrEqual(WeaponName, "weapon_hook", false)).

And how do you do that?

Nevermind I think I figured it out.

Thanks guys!
__________________

Last edited by Banjo Boy; 08-07-2008 at 12:05.
Banjo Boy is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 08-07-2008 , 12:05   Re: Person killed by certain weapon plays a sound
Reply With Quote #8

The first one with your keyboard, the second one with your mouse.
__________________
Advertisements | REST in Pawn - HTTP client for JSON REST APIs
Please do not PM me with questions. Post in the plugin thread.
DJ Tsunami is offline
DiscoBBQ
Veteran Member
Join Date: Jan 2005
Location: Clemson, South Carolina
Old 08-07-2008 , 13:18   Re: Person killed by certain weapon plays a sound
Reply With Quote #9

The client dosnt need to be initialized after the attacker has been checked to fix the warning. The warning appeared because it was only used in the unrecognized command due to the lack of sdktools. Though it would slightly improve efficiency for the cases of world damage.
__________________
"Every man is guilty of all the good he did not do"
DiscoBBQ is offline
Banjo Boy
Member
Join Date: Apr 2008
Old 08-07-2008 , 17:55   Re: Person killed by certain weapon plays a sound
Reply With Quote #10

Quote:
Originally Posted by DJ Tsunami View Post
The first one with your keyboard, the second one with your mouse.
Great. Well the sound gets downloaded, but the sound does not play when a person gets killed by a weapon_hook. I compiled both as different plugins, and I added #include <sdktools> on the top of both seperate plugins. Anyone know the problem? Thanks, Banjo Boy.

EDIT: Does the server need to be restarted in order for the second plugin to work?
__________________
Banjo Boy is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:11.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode