Raised This Month: $51 Target: $400
 12% 

[Solved] Detecting the first shot?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
eric0279
AlliedModders Donor
Join Date: May 2007
Old 08-04-2014 , 23:19   [Solved] Detecting the first shot?
Reply With Quote #1

Hello,

it's possible for Detecting the first shot for the witch?

Sincerely,

Last edited by eric0279; 08-13-2014 at 18:16.
eric0279 is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 08-05-2014 , 00:39   Re: [L4D2] Detecting the first shot?
Reply With Quote #2

Hook the witch_harasser_set event and check its userid field (remember you need to use GetClientOfUserid to get a client index).
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
eric0279
AlliedModders Donor
Join Date: May 2007
Old 08-05-2014 , 02:58   Re: [L4D2] Detecting the first shot?
Reply With Quote #3

Thanks Powerlord
eric0279 is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 08-05-2014 , 04:46   Re: [L4D2] Detecting the first shot?
Reply With Quote #4

Quote:
Originally Posted by Powerlord View Post
Hook the witch_harasser_set event and check its userid field (remember you need to use GetClientOfUserid to get a client index).
I thought that's the event fired every time the tf2 announcer opens her mouth.
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram is offline
eric0279
AlliedModders Donor
Join Date: May 2007
Old 08-05-2014 , 11:16   Re: [Solved] Detecting the first shot?
Reply With Quote #5

Hello,

just have a tag missmatch (for WitchTargetBuffer[targetwitch] = targetuser;) but work :
PHP Code:
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

new const TEAM_SURVIVOR 2;

new 
Handle:WitchTargetBuffer[128];

public 
Plugin:myinfo 
{
    
name "Witch Damage Announce",
    
author "Sir",
    
description "Print Witch Damage to chat",
    
version "1.1c",
    
url "https://github.com/SirPlease/SirCoding"
}

public 
OnPluginStart()
{
    
HookEvent("witch_harasser_set"WitchTargetBufferSet);            
}

public 
Action:WitchTargetBufferSet(Handle:eventString:event_name[], bool:dontBroadcast)
{
    new 
targetuser GetClientOfUserId(GetEventInt(event"userid"));
    new 
targetwitch GetClientOfUserId(GetEventInt(event"userid"));
    
    if(
targetuser != && targetwitch != 0)
    {
        if(
GetClientTeam(targetuser) == TEAM_SURVIVOR && !IsFakeClient(targetuser))
        {
            
WitchTargetBuffer[targetwitch] = targetuser;
            
CPrintToChatAll("%N has triggered the witch"targetuser);
        }
    }


how to integrate this into a function?

This is the l4d_witch_damage_announce.sp Sir (1.1c, uploaded source script) script and I wanted to include in the code PrintWitchDamage () to get this result:

Damage Dealt to Witch:

PrintToChatAll("\x01%d [\x04%i%%\x01] \x03%N", damage, percent_damage, client);

and thus put targetuser between "<>" to indicate that it is the player who started the witch.

Sample:

Quote:
Damage Dealt to Witch:

562 HP [57% ] Yakou
202 HP [20% ] Sir
181 HP [18% ] < GetDown >
55 HP [5% ] Zak
or

Quote:
Damage Dealt to Witch:

562 HP [57% ] < Yakou >
202 HP [20% ] Sir
181 HP [18% ] GetDown
55 HP [5% ] Zak
thanks for you help
Attached Files
File Type: sp Get Plugin or Get Source (l4d_witch_damage_announce.sp - 172 views - 10.7 KB)

Last edited by eric0279; 08-05-2014 at 11:19.
eric0279 is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 08-05-2014 , 11:46   Re: [L4D2] Detecting the first shot?
Reply With Quote #6

A few problems I can see:
  • WitchBuffer shouldn't have a Handle tag.
  • A witch's entity index can be anywhere between MaxClients+1 and GetMaxEntities() (which is 8192 in all Valve source games)
  • Witches aren't clients, so they aren't a user id but rather an entity index.
  • It's witchid for the witch's index, not userid (which is the player).

The plugin you're modifying also has some issues, as it seems to assume only one witch will be attacked at a time (have they never played The Sugar Mill?) Because of this, you may want to store who startled the witch in a single variable and not an array.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
eric0279
AlliedModders Donor
Join Date: May 2007
Old 08-05-2014 , 14:23   Re: [L4D2] Detecting the first shot?
Reply With Quote #7

ok ok thank you, I'll watch it though it's complicated without real knowledge...

It's a plugin for promod server... i don't understand Sugar mill ^^


Thank you for your advice.
eric0279 is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 08-05-2014 , 15:23   Re: [L4D2] Detecting the first shot?
Reply With Quote #8

Quote:
Originally Posted by eric0279 View Post
i don't understand Sugar mill ^^
The Sugar Mill is one of the maps in the Hard Rain campaign. Most of the enemies in this level are witches.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 08-05-2014 , 15:46   Re: [L4D2] Detecting the first shot?
Reply With Quote #9

Max ents is 2048 in most games?
After that you get ed alloc no free edicts...
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 08-06-2014 , 01:00   Re: [L4D2] Detecting the first shot?
Reply With Quote #10

Have you try SDKHook_ontakedamage?
It may work in your case.
__________________
If i happen to insulted you unintentionally,
it was me and Google Translate who did it.
GsiX 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 05:52.


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