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

Don't count bots as kills


Post New Thread Reply   
 
Thread Tools Display Modes
Tank_in_Pink
Member
Join Date: Feb 2016
Old 04-03-2018 , 19:04   Re: Don't count bots as kills
Reply With Quote #11

Quote:
Originally Posted by Visual77 View Post
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.
I'm a bit confused right now since i'm not that experienced in SP.

Would be nice if somebody could give it another try an post some new code I can try!
Tank_in_Pink is offline
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 04-03-2018 , 19:05   Re: Don't count bots as kills
Reply With Quote #12

Quote:
Originally Posted by Mitchell View Post
I think the mistake was not converting the userId to client index though.
I believe you're right. I also had the userid to client part in one of my many notepads, seems like I'm spreading things all over these days...

Quote:
Originally Posted by Tank_in_Pink View Post
Do you know how to fix it?
It would be so great to get this plugin running
Try with this one instead:

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

    if (
IsClientInGame(victim) && IsFakeClient(victim))
    {
        return 
Plugin_Handled;
    }
    
    return 
Plugin_Continue;

If that one doesn't work either, I'd probably lean towards the method you previously mentioned, by decrementing the kills of the player if the victim is a bot instead.

I simply tried to fix the code that cravenge shared above, basing my shared code above 100% on that one.
__________________
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].

Last edited by DarkDeviL; 04-03-2018 at 19:06.
DarkDeviL is offline
Visual77
Veteran Member
Join Date: Jan 2009
Old 04-04-2018 , 06:04   Re: Don't count bots as kills
Reply With Quote #13

Quote:
Originally Posted by Tank_in_Pink View Post
I'm a bit confused right now since i'm not that experienced in SP.

Would be nice if somebody could give it another try an post some new code I can try!
I don't play CSGO so I'm not sure how to optimize this plugin for that game. But adding some code to the pool so anybody can jump in and correct it. Something like this:
Borrowed from here: https://forums.alliedmods.net/showthread.php?t=258328

Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#pragma newdecls required

public void OnPluginStart()
{
	HookEvent("player_death", Event_PlayerDeath);
}

public Action Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast)
{
	int attacker = GetClientOfUserId(event.GetInt("attacker"));
	int victim = GetClientOfUserId(event.GetInt("userid"));

	if (!IsValidClient(attacker)) return;   	// Is the killer not valid?
	if (IsFakeClient(attacker)) return;		// The killer is a bot. Remove this if bots shouldn't get points either.
	if (!IsValidClient(victim)) return; 		// Is the victim not valid?
	if (!IsFakeClient(victim)) return;		// The victim is not a bot.
	if (victim == attacker) return; 		// Self inflicted death, suicide?
	if (GetClientTeam(victim) == GetClientTeam(attacker)) return; 	// Possibly a team kill?

	SetEntProp(attacker, Prop_Data, "m_iFrags", GetClientFrags(attacker) - 1);
}  

stock bool IsValidClient(int client)
{
	return client > 0 && client <= MaxClients && IsClientInGame(client);
}

Last edited by Visual77; 04-04-2018 at 06:07.
Visual77 is offline
cravenge
Veteran Member
Join Date: Nov 2015
Location: Chocolate Factory
Old 04-04-2018 , 08:03   Re: Don't count bots as kills
Reply With Quote #14

I apologize for the short snippet. I admit it was a bit rushed but Visual's code above ^ is interesting...
cravenge is offline
Tank_in_Pink
Member
Join Date: Feb 2016
Old 04-04-2018 , 08:05   Re: Don't count bots as kills
Reply With Quote #15

Quote:
Originally Posted by arne1288 View Post
I believe you're right. I also had the userid to client part in one of my many notepads, seems like I'm spreading things all over these days...



Try with this one instead:

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

    if (
IsClientInGame(victim) && IsFakeClient(victim))
    {
        return 
Plugin_Handled;
    }
    
    return 
Plugin_Continue;

If that one doesn't work either, I'd probably lean towards the method you previously mentioned, by decrementing the kills of the player if the victim is a bot instead.

I simply tried to fix the code that cravenge shared above, basing my shared code above 100% on that one.
This one still counts bots as kills but there are no death messages at the top right of the screen and no messages printed to the servers console.

Last edited by Tank_in_Pink; 04-04-2018 at 08:05.
Tank_in_Pink is offline
Tank_in_Pink
Member
Join Date: Feb 2016
Old 04-04-2018 , 08:18   Re: Don't count bots as kills
Reply With Quote #16

Quote:
Originally Posted by Visual77 View Post
I don't play CSGO so I'm not sure how to optimize this plugin for that game. But adding some code to the pool so anybody can jump in and correct it. Something like this:
Borrowed from here: https://forums.alliedmods.net/showthread.php?t=258328

Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#pragma newdecls required

public void OnPluginStart()
{
	HookEvent("player_death", Event_PlayerDeath);
}

public Action Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast)
{
	int attacker = GetClientOfUserId(event.GetInt("attacker"));
	int victim = GetClientOfUserId(event.GetInt("userid"));

	if (!IsValidClient(attacker)) return;   	// Is the killer not valid?
	if (IsFakeClient(attacker)) return;		// The killer is a bot. Remove this if bots shouldn't get points either.
	if (!IsValidClient(victim)) return; 		// Is the victim not valid?
	if (!IsFakeClient(victim)) return;		// The victim is not a bot.
	if (victim == attacker) return; 		// Self inflicted death, suicide?
	if (GetClientTeam(victim) == GetClientTeam(attacker)) return; 	// Possibly a team kill?

	SetEntProp(attacker, Prop_Data, "m_iFrags", GetClientFrags(attacker) - 1);
}  

stock bool IsValidClient(int client)
{
	return client > 0 && client <= MaxClients && IsClientInGame(client);
}
This one worked!

Thanks to all of you guys, you helped me alot :3
Tank_in_Pink is offline
Visual77
Veteran Member
Join Date: Jan 2009
Old 04-04-2018 , 08:32   Re: Don't count bots as kills
Reply With Quote #17

Quote:
Originally Posted by Tank_in_Pink View Post
This one worked!

Thanks to all of you guys, you helped me alot
Visual77 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 11:20.


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