Raised This Month: $32 Target: $400
 8% 

Don't count bots as kills


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Tank_in_Pink
Member
Join Date: Feb 2016
Old 04-01-2018 , 05:53   Don't count bots as kills
Reply With Quote #1

Hey guys,


I'm searching for a plugin which prevents players from getting a kill in the scoreboard if they kill a bot.
Of course the bot should die if he is shot but players shouldn't get a kill for it.
If the bot is controlled by a player or not doesn't matter in my case since you can't controll bots on my server.
Would be awesome if this wouldn't count as kill for plugins like Stamm, RankMe or similar plugins aswell.

I searched for quite some time but couldn't find anything.

If there is a plugin like this please link it, if not it would be awesome if somebody could try making it since im not that experienced in SP.


Thanks already,
hazetank
Tank_in_Pink is offline
cravenge
Veteran Member
Join Date: Nov 2015
Location: Chocolate Factory
Old 04-01-2018 , 07:01   Re: Don't count bots as kills
Reply With Quote #2

PHP Code:
public void OnPluginStart()
{
    
HookEvent("player_death"OnPlayerDeathPreEventHookMode_Pre);
}

public 
Action OnPlayerDeathPre(Event event, const char[] namebool dontBroadcast)
{
    if (
event.GetBool("victimisbot"))
    {
        return 
Plugin_Handled;
    }
    
    return 
Plugin_Continue;


Last edited by cravenge; 04-01-2018 at 09:49. Reason: Didn't notice the last bit of your statement...
cravenge is offline
Tank_in_Pink
Member
Join Date: Feb 2016
Old 04-02-2018 , 09:02   Re: Don't count bots as kills
Reply With Quote #3

Quote:
Originally Posted by cravenge View Post
PHP Code:
public void OnPluginStart()
{
    
HookEvent("player_death"OnPlayerDeathPreEventHookMode_Pre);
}

public 
Action OnPlayerDeathPre(Event event, const char[] namebool dontBroadcast)
{
    if (
event.GetBool("victimisbot"))
    {
        return 
Plugin_Handled;
    }
    
    return 
Plugin_Continue;

I compiled it and put it in my plugins folder but doesn't work, I still get kills for killing bots :(

Some help would be awesome!
Tank_in_Pink is offline
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 04-02-2018 , 16:26   Re: Don't count bots as kills
Reply With Quote #4

When I am looking around, I only see the "victimisbot" boolean mentioned in L4D2 related plugins.

If this isn't for L4D2, I suggest trying something like (based on the code above):

PHP Code:
public Action OnPlayerDeathPre(Event event, const char[] namebool dontBroadcast)
{
    
int victimId event.GetInt("userid");

    if (
IsFakeClient(victimId))
    {
        return 
Plugin_Handled;
    }
    
    return 
Plugin_Continue;

I cannot guarantee that it will work for you, it's simply based on a quick look at the events and their parameters listed on Generic Source Events, as well as Counter-Strike: Global Offensive Events.

Another time, it would also be useful if you were providing all relevant details, including what game, and so on...
__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread].
DarkDeviL is offline
Tank_in_Pink
Member
Join Date: Feb 2016
Old 04-02-2018 , 17:04   Re: Don't count bots as kills
Reply With Quote #5

Quote:
Originally Posted by arne1288 View Post
When I am looking around, I only see the "victimisbot" boolean mentioned in L4D2 related plugins.

If this isn't for L4D2, I suggest trying something like (based on the code above):

PHP Code:
public Action OnPlayerDeathPre(Event event, const char[] namebool dontBroadcast)
{
    
int victimId event.GetInt("userid");

    if (
IsFakeClient(victimId))
    {
        return 
Plugin_Handled;
    }
    
    return 
Plugin_Continue;

I cannot guarantee that it will work for you, it's simply based on a quick look at the events and their parameters listed on Generic Source Events, as well as Counter-Strike: Global Offensive Events.

Another time, it would also be useful if you were providing all relevant details, including what game, and so on...
Thanks for your response!

Sorry I forgot to mention the plugin is for my CSGO server.

I tried your plugin but bot kills are still counted. But there are messages about the plugin printed into the servers console so it looks like you are on the right track!

Those are the messages printed to the servers console after killing some bots:
Code:
L 04/02/2018 - 20:55:13: [SM] Exception reported: Client 9 is not connected
L 04/02/2018 - 20:55:13: [SM] Blaming: thehunt_killfix.smx
L 04/02/2018 - 20:55:13: [SM] Call stack trace:
L 04/02/2018 - 20:55:13: [SM]   [0] IsFakeClient
L 04/02/2018 - 20:55:13: [SM]   [1] Line 21, /home/groups/sourcemod/upload_tmp/phpupjCbd.sp::OnPlayerDeathPre
L 04/02/2018 - 20:55:30: [SM] Exception reported: Client 7 is not connected
L 04/02/2018 - 20:55:30: [SM] Blaming: thehunt_killfix.smx
L 04/02/2018 - 20:55:30: [SM] Call stack trace:
L 04/02/2018 - 20:55:30: [SM]   [0] IsFakeClient
L 04/02/2018 - 20:55:30: [SM]   [1] Line 21, /home/groups/sourcemod/upload_tmp/phpupjCbd.sp::OnPlayerDeathPre
L 04/02/2018 - 20:56:29: [SM] Exception reported: Client 10 is not connected
L 04/02/2018 - 20:56:42: [SM] Blaming: thehunt_killfix.smx
L 04/02/2018 - 20:56:42: [SM] Call stack trace:
L 04/02/2018 - 20:56:42: [SM]   [0] IsFakeClient
L 04/02/2018 - 20:56:42: [SM]   [1] Line 21, /home/groups/sourcemod/upload_tmp/phpupjCbd.sp::OnPlayerDeathPre
L 04/02/2018 - 20:56:42: [SM] Exception reported: Script execution timed out
Also it looks like the server got a bit laggy after installing the plugin.

Would be awesome if you could take at it again :3

I'm really sorry for posting about this twice - won't happen again.

EDIT: Just restarted the server and it really looks like the server started lagging with this plugin. But i also recognized that if I kill a bot sometimes there's no death message at the top right of the screen and no message printed to the server's console but the kill is counted anyways. As I said this only happens sometimes, kinda weird.

Thanks already,
hazetank

Last edited by Tank_in_Pink; 04-02-2018 at 17:14.
Tank_in_Pink is offline
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 04-02-2018 , 17:10   Re: Don't count bots as kills
Reply With Quote #6

Looks like I forgot something in the rush, try:

Replace

PHP Code:
if (IsFakeClient(victimId)) 
with

PHP Code:
if (IsClientInGame(victimId) && IsFakeClient(victimId)) 
__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread].
DarkDeviL is offline
Tank_in_Pink
Member
Join Date: Feb 2016
Old 04-03-2018 , 04:15   Re: Don't count bots as kills
Reply With Quote #7

Quote:
Originally Posted by arne1288 View Post
Looks like I forgot something in the rush, try:

Replace

PHP Code:
if (IsFakeClient(victimId)) 
with

PHP Code:
if (IsClientInGame(victimId) && IsFakeClient(victimId)) 
Just tried it, I still get kills for killing bots but the server stopped lagging and there are no messages printed to the server anymore.

Wouldn't it be possible to decrement the players kills by 1 after killing a bot?
Tank_in_Pink is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 04-03-2018 , 12:34   Re: Don't count bots as kills
Reply With Quote #8

Quote:
Originally Posted by arne1288 View Post
Looks like I forgot something in the rush, try:

Replace

PHP Code:
if (IsFakeClient(victimId)) 
with

PHP Code:
if (IsClientInGame(victimId) && IsFakeClient(victimId)) 
I think the mistake was not converting the userId to client index though.
Mitchell is offline
Tank_in_Pink
Member
Join Date: Feb 2016
Old 04-03-2018 , 14:56   Re: Don't count bots as kills
Reply With Quote #9

Quote:
Originally Posted by Mitchell View Post
I think the mistake was not converting the userId to client index though.
Do you know how to fix it?
It would be so great to get this plugin running :3
Tank_in_Pink is offline
Visual77
Veteran Member
Join Date: Jan 2009
Old 04-03-2018 , 15:09   Re: Don't count bots as kills
Reply With Quote #10

Find the right data/netprop and decrement its value in the player_death event hook.
If you block the player_death event, some of your plugins might stop working.
Visual77 is offline
Reply


Thread Tools
Display Modes

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 02:08.


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