BANNED
|
09-06-2011
, 21:34
Re: [TF2] Couple of urgent questions
|
#5
|
Sound hooks, eh? Not exactly sure what those are.
I just got off work and I'm dead tired, so I'll post the coding of the plugin that I've done so far, and if you could, could you do an example of the sound hook change in my coding and post the example for me?
I'm dead tired and just about to head to bed because I have to go back in to work in about 12 hours and I need sleeeeep.
NOTE: The defined sounds in OnPluginStart are just example sound lines. I haven't changed the defines to use the Bill voice clips that I'll be using. And the defined Gman "Rise and Shine" voice clips were part of a test I ran to see if the hooking worked properly. I also probably won't be using 5 sounds per event. That depends on how many voice clips I think I can use per event, that sound good.
I also haven't added in the Soldier class checks, or the Bill's Hat check, due to not knowing how to check which hat a player has equipped, and because I didn't want to add in the Soldier checks until I found out how to check a player's hat.
PHP Code:
/* ----- Global Includes ----- */ #include <sourcemod> #include <sdktools> #include <tf2_stocks> #include <sdkhooks>
/* ----- Enable Strict Semicolon Mode ----- */ #pragma semicolon 1
/* ----- Voice Strings ----- */ new String:VOICE_PLAYERSPAWNED[5][64]; new String:VOICE_PLAYERDIED[5][64]; new String:VOICE_TOUCHED_LOCKER[5][64]; new String:VOICE_DESTROYED_OBJECT[5][64]; new String:VOICE_ROCKETJUMP[5][64]; new String:VOICE_ROCKETJUMP_LANDED[5][64]; new String:VOICE_ACHIEVEMENT_EARNED[5][64]; new String:VOICE_HITBYARROW[5][64]; new String:VOICE_HHHSPAWNED[5][64]; new String:VOICE_HHHKILLED[5][64];
/* ----- Plugin Information ----- */ public Plugin:myinfo = { name = "Talk Like Bill", author = "[GoR] Rage Boy", description = "Spout off at the mouth like Bill from L4D", version = "0.1", url = "" }
/* ----- Plugin has started ----- */ public OnPluginStart() { //Hook Events HookEvent("player_spawn", Event_PlayerSpawn); HookEvent("player_death", Event_PlayerDeath); HookEvent("post_inventory_application", Event_LockerTouch); HookEvent("rocket_jump", Event_RocketJump); HookEvent("rocket_jump_landed", Event_RocketJumpLand); HookEvent("object_destroyed", Event_ObjectDestroyed); HookEvent("achievement_earned", Event_AchievementEarned); HookEvent("arrow_impact", Event_HitByArrow); HookEvent("pumpkin_lord_summoned", Event_HorsemannSpawned); HookEvent("pumpkin_lord_killed", Event_HorsemannKilled); //Define sounds to play on spawning VOICE_PLAYERSPAWNED[0] = "vo/gman_misc/gman_riseshine.wav"; VOICE_PLAYERSPAWNED[1] = "vo/gman_misc/gman_riseshine.wav"; VOICE_PLAYERSPAWNED[2] = "vo/gman_misc/gman_riseshine.wav"; VOICE_PLAYERSPAWNED[3] = "vo/gman_misc/gman_riseshine.wav"; VOICE_PLAYERSPAWNED[4] = "vo/gman_misc/gman_riseshine.wav"; //Define sounds to play on dying VOICE_PLAYERDIED[0] = "vo/pyro_laughevil02.wav"; VOICE_PLAYERDIED[1] = "vo/pyro_autoonfire02.wav"; VOICE_PLAYERDIED[2] = "vo/pyro_laughevil04.wav"; VOICE_PLAYERDIED[3] = "vo/pyro_goodjob01.wav"; VOICE_PLAYERDIED[4] = "vo/pyro_laughevil03.wav"; //Define sounds to play on touching a resupply locker VOICE_TOUCHED_LOCKER[0] = "vo/pyro_laughevil02.wav"; VOICE_TOUCHED_LOCKER[1] = "vo/pyro_autoonfire02.wav"; VOICE_TOUCHED_LOCKER[2] = "vo/pyro_laughevil04.wav"; VOICE_TOUCHED_LOCKER[3] = "vo/pyro_goodjob01.wav"; VOICE_TOUCHED_LOCKER[4] = "vo/pyro_laughevil03.wav"; //Define sounds to play on destroying an object VOICE_DESTROYED_OBJECT[0] = "vo/pyro_laughevil02.wav"; VOICE_DESTROYED_OBJECT[1] = "vo/pyro_autoonfire02.wav"; VOICE_DESTROYED_OBJECT[2] = "vo/pyro_laughevil04.wav"; VOICE_DESTROYED_OBJECT[3] = "vo/pyro_goodjob01.wav"; VOICE_DESTROYED_OBJECT[4] = "vo/pyro_laughevil03.wav"; //Define sounds to play on rocket jumping VOICE_ROCKETJUMP[0] = "vo/pyro_laughevil02.wav"; VOICE_ROCKETJUMP[1] = "vo/pyro_autoonfire02.wav"; VOICE_ROCKETJUMP[2] = "vo/pyro_laughevil04.wav"; VOICE_ROCKETJUMP[3] = "vo/pyro_goodjob01.wav"; VOICE_ROCKETJUMP[4] = "vo/pyro_laughevil03.wav"; //Define sounds to play on landing after rocket jumping VOICE_ROCKETJUMP_LANDED[0] = "vo/pyro_laughevil02.wav"; VOICE_ROCKETJUMP_LANDED[1] = "vo/pyro_autoonfire02.wav"; VOICE_ROCKETJUMP_LANDED[2] = "vo/pyro_laughevil04.wav"; VOICE_ROCKETJUMP_LANDED[3] = "vo/pyro_goodjob01.wav"; VOICE_ROCKETJUMP_LANDED[4] = "vo/pyro_laughevil03.wav"; //Define sounds to play on earning an achievement VOICE_ACHIEVEMENT_EARNED[0] = "vo/pyro_laughevil02.wav"; VOICE_ACHIEVEMENT_EARNED[1] = "vo/pyro_autoonfire02.wav"; VOICE_ACHIEVEMENT_EARNED[2] = "vo/pyro_laughevil04.wav"; VOICE_ACHIEVEMENT_EARNED[3] = "vo/pyro_goodjob01.wav"; VOICE_ACHIEVEMENT_EARNED[4] = "vo/pyro_laughevil03.wav"; //Define sounds to play on being hit by a Huntsman arrow VOICE_HITBYARROW[0] = "vo/pyro_laughevil02.wav"; VOICE_HITBYARROW[1] = "vo/pyro_autoonfire02.wav"; VOICE_HITBYARROW[2] = "vo/pyro_laughevil04.wav"; VOICE_HITBYARROW[3] = "vo/pyro_goodjob01.wav"; VOICE_HITBYARROW[4] = "vo/pyro_laughevil03.wav"; //Define sounds to play when the Horsemann spawns VOICE_HHHSPAWNED[0] = "vo/pyro_laughevil02.wav"; VOICE_HHHSPAWNED[1] = "vo/pyro_autoonfire02.wav"; VOICE_HHHSPAWNED[2] = "vo/pyro_laughevil04.wav"; VOICE_HHHSPAWNED[3] = "vo/pyro_goodjob01.wav"; VOICE_HHHSPAWNED[4] = "vo/pyro_laughevil03.wav"; //Define sounds to play when the Horsemann is killed VOICE_HHHKILLED[0] = "vo/pyro_laughevil02.wav"; VOICE_HHHKILLED[1] = "vo/pyro_autoonfire02.wav"; VOICE_HHHKILLED[2] = "vo/pyro_laughevil04.wav"; VOICE_HHHKILLED[3] = "vo/pyro_goodjob01.wav"; VOICE_HHHKILLED[4] = "vo/pyro_laughevil03.wav"; }
/* ----- Map has started ----- */ public OnMapStart() { for( new i = 0; i < 5; i++) { PrecacheSound(VOICE_PLAYERSPAWNED[i], true); PrecacheSound(VOICE_PLAYERDIED[i], true); PrecacheSound(VOICE_TOUCHED_LOCKER[i], true); PrecacheSound(VOICE_ROCKETJUMP[i], true); PrecacheSound(VOICE_ROCKETJUMP_LANDED[i], true); PrecacheSound(VOICE_DESTROYED_OBJECT[i], true); PrecacheSound(VOICE_ACHIEVEMENT_EARNED[i], true); PrecacheSound(VOICE_HITBYARROW[i], true); PrecacheSound(VOICE_HHHSPAWNED[i], true); PrecacheSound(VOICE_HHHKILLED[i], true); } }
/* ----- Event: Player has spawned ----- */ public Action:Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast) { //Define what "client" is, since this is an event, and "client" isn't naturally defined new client = GetClientOfUserId(GetEventInt(event, "userid")); //Choose one of the defined VOICE_PLAYERSPAWNED clips at random, then play it EmitSoundToAll(VOICE_PLAYERSPAWNED[GetRandomInt(0, 4)], client, _, _, _, 1.0); }
/* ----- Event: Player has died ----- */ public Action:Event_PlayerDeath(Handle:event, String:strName[], bool:bDontBroadcast) { //Define what "client" is, since this is an event, and "client" isn't naturally defined new client = GetClientOfUserId(GetEventInt(event, "userid")); //Choose one of the defined VOICE_PLAYERDIED clips at random, then play it EmitSoundToAll(VOICE_PLAYERDIED[GetRandomInt(0, 4)], client, _, _, _, 1.0); }
/* ----- Event: Player has touched a resupply locker, or changed their equipped items ----- */ public Action:Event_LockerTouch(Handle:event, const String:name[], bool:dontBroadcast) { //Define what "client" is, since this is an event, and "client" isn't naturally defined new client = GetClientOfUserId(GetEventInt(event, "userid")); //Choose one of the defined VOICE_TOUCHED_LOCKER clips at random, then play it EmitSoundToAll(VOICE_TOUCHED_LOCKER[GetRandomInt(0, 4)], client, _, _, _, 1.0); }
/* ----- Event: Player has rocket-jumped ----- */ public Action:Event_RocketJump(Handle:event, String:strName[], bool:dontBroadcast) { //Define what "client" is, since this is an event, and "client" isn't naturally defined new client = GetClientOfUserId(GetEventInt(event, "userid")); //Choose one of the defined VOICE_ROCKETJUMP clips at random, then play it EmitSoundToAll(VOICE_ROCKETJUMP[GetRandomInt(0, 4)], client, _, _, _, 1.0); }
/* ----- Event: Player has successfully landed and survived a rocket-jump ----- */ public Action:Event_RocketJumpLand(Handle:event, String:strName[], bool:dontBroadcast) { //Define what "client" is, since this is an event, and "client" isn't naturally defined new client = GetClientOfUserId(GetEventInt(event, "userid")); //Choose one of the defined VOICE_ROCKETJUMP_LANDED clips at random, then play it EmitSoundToAll(VOICE_ROCKETJUMP_LANDED[GetRandomInt(0, 4)], client, _, _, _, 1.0); }
/* ----- Event: Player has destroyed an object ----- */ public Action:Event_ObjectDestroyed(Handle:event, String:strName[], bool:bDontBroadcast) { //Define what "client" is, since this is an event, and "client" isn't naturally defined new client = GetClientOfUserId(GetEventInt(event, "userid")); //Choose one of the defined VOICE_DESTROYED_OBJECT clips at random, then play it EmitSoundToAll(VOICE_DESTROYED_OBJECT[GetRandomInt(0, 4)], client, _, _, _, 1.0); }
/* ----- Event: Player has earned an achievement ----- */ public Action:Event_AchievementEarned(Handle:event, const String:name[], bool:dontBroadcast) { //Define what "client" is, since this is an event, and "client" isn't naturally defined new client = GetClientOfUserId(GetEventInt(event, "userid")); //Choose one of the defined VOICE_ACHIEVEMENT_EARNED clips at random, then play it EmitSoundToAll(VOICE_ACHIEVEMENT_EARNED[GetRandomInt(0, 4)], client, _, _, _, 1.0); }
/* ----- Event: Player has been hit by a Huntsman arrow ----- */ public Action:Event_HitByArrow(Handle:event, const String:name[], bool:dontBroadcast) { //Define what "client" is, since this is an event, and "client" isn't naturally defined new client = GetClientOfUserId(GetEventInt(event, "userid")); //Choose one of the defined VOICE_HITBYARROW clips at random, then play it EmitSoundToAll(VOICE_HITBYARROW[GetRandomInt(0, 4)], client, _, _, _, 1.0); }
/* ----- Event: Player has been hit by a Huntsman arrow ----- */ public Action:Event_HorsemannSpawned(Handle:event, const String:name[], bool:dontBroadcast) { //Define what "client" is, since this is an event, and "client" isn't naturally defined new client = GetClientOfUserId(GetEventInt(event, "userid")); //Choose one of the defined VOICE_HHHSPAWNED clips at random, then play it EmitSoundToAll(VOICE_HHHSPAWNED[GetRandomInt(0, 4)], client, _, _, _, 1.0); }
/* ----- Event: Player has been hit by a Huntsman arrow ----- */ public Action:Event_HorsemannKilled(Handle:event, const String:name[], bool:dontBroadcast) { //Define what "client" is, since this is an event, and "client" isn't naturally defined new client = GetClientOfUserId(GetEventInt(event, "userid")); //Choose one of the defined VOICE_HHHKILLED clips at random, then play it EmitSoundToAll(VOICE_HHHKILLED[GetRandomInt(0, 4)], client, _, _, _, 1.0); }
/* ----- Stock: Valid Client Check ----- */ stock bool:IsValidClient(client, bool:nobots = true) { if (client <= 0 || client > MaxClients || !IsClientConnected(client) || (nobots && IsFakeClient(client))) { return false; } return IsClientInGame(client); }
Quote:
Originally Posted by asherkin
Loop through all tf_wearable entities, check that m_hOwner == the client, then check m_iItemDefintionIndex matches those hat's item def indexes.
|
I understood the item definition index part....nothing else. Care to type up a quick example of this in action? My brain isn't functioning at full power right now due to sleepiness.
Last edited by GoRRageBoy; 09-06-2011 at 21:40.
|
|