Raised This Month: $ Target: $400
 0% 

[CS:GO] Preventing suicide by "kill" or world damage from setting kills negative


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ImACow
AlliedModders Donor
Join Date: Feb 2015
Old 02-16-2015 , 21:51   [CS:GO] Preventing suicide by "kill" or world damage from setting kills negative
Reply With Quote #1

I'm hooking player_death (pre)
I have this code on. I'm still getting negative values somehow. what I'm I missing ?

The point of the code is to prevent suicides by "kill" or "world" to show negative values on the scoreboard

PHP Code:
public Action:event_PlayerDeathPre(Handle:event,const String:name[], bool:dontBroadcast){

  new 
var_userid GetEventInt(event"userid"); //get userid from event this one died
  
new client GetClientOfUserId(var_userid); //get client index this one died
  
new var_attacker GetEventInt(event"attacker"); //get userid who killed
    
new client_attacker GetClientOfUserId(var_attacker); //get client index

    
if(IsValidClient(client)){
      
        if(
client == client_attacker || client_attacker == 0){ //world or himself
            //PrintToChatAll("suicide");
            
new kills GetEntProp(clientProp_Data"m_iFrags");
            
kills kills +1;
            
SetEntProp(clientProp_Data"m_iFrags",kills);
        }
    }

  return 
Plugin_Continue


PHP Code:
public IsValidClient(client)
{
    if(
client == 0)
        return 
false;

    if(!
IsClientInGame(client))
        return 
false;
   
    if(
IsFakeClient(client))
        return 
false;

    return 
true;


Last edited by ImACow; 02-17-2015 at 04:37.
ImACow is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 02-17-2015 , 00:12   Re: [CS:GO] Preventing suicide by "kill" or world damage from setting kills negative
Reply With Quote #2

IsValidClient, supose it check if your not 0 which mean if you die by world it won't trigger your code
Mathias. is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 02-17-2015 , 03:11   Re: [CS:GO] Preventing suicide by "kill" or world damage from setting kills negative
Reply With Quote #3

To confirm. The problem is the scoreboard shows negative kills or the actual score is negative?
__________________
Neuro Toxin is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 02-17-2015 , 04:36   Re: [CS:GO] Preventing suicide by "kill" or world damage from setting kills negative
Reply With Quote #4

he don't want have his player suffering from losing a kill when they die from themself or by the world, which make sense, I mean why the fuck would it remove you a kill? points okay maybe but kills are kills.
Mathias. is offline
ImACow
AlliedModders Donor
Join Date: Feb 2015
Old 02-17-2015 , 04:38   Re: [CS:GO] Preventing suicide by "kill" or world damage from setting kills negative
Reply With Quote #5

Quote:
Originally Posted by Black-Rabbit View Post
IsValidClient, supose it check if your not 0 which mean if you die by world it won't trigger your code
PHP Code:
public IsValidClient(client)
{
    if(
client == 0)
        return 
false;

    if(!
IsClientInGame(client))
        return 
false;
   
    if(
IsFakeClient(client))
        return 
false;

    return 
true;

ImACow is offline
ImACow
AlliedModders Donor
Join Date: Feb 2015
Old 02-17-2015 , 04:39   Re: [CS:GO] Preventing suicide by "kill" or world damage from setting kills negative
Reply With Quote #6

Quote:
Originally Posted by Black-Rabbit View Post
he don't want have his player suffering from losing a kill when they die from themself or by the world, which make sense, I mean why the fuck would it remove you a kill? points okay maybe but kills are kills.
Exactly, its annoying seeing players at -30 kills when they killed 15 players past 8 rounds

Last edited by ImACow; 02-17-2015 at 04:40.
ImACow is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 02-17-2015 , 14:24   Re: [CS:GO] Preventing suicide by "kill" or world damage from setting kills negative
Reply With Quote #7

I don't, I got similar code, I'm setting the kills the same way, it should work as it is. Killing a teamate also give a negative value, just not sure if you use friendly fire, the only thing I can see that can g ive you negative values.

Last edited by Mathias.; 02-17-2015 at 14:25.
Mathias. is offline
ImACow
AlliedModders Donor
Join Date: Feb 2015
Old 02-17-2015 , 14:33   Re: [CS:GO] Preventing suicide by "kill" or world damage from setting kills negative
Reply With Quote #8

ff is disabled, I'm just confused why its still going negative.
ImACow is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 02-17-2015 , 14:40   Re: [CS:GO] Preventing suicide by "kill" or world damage from setting kills negative
Reply With Quote #9

when it goes negative? are you sure when play sucide? give more information at when it happen.
Mathias. is offline
ici
Member
Join Date: Jan 2014
Old 02-17-2015 , 16:57   Re: [CS:GO] Preventing suicide by "kill" or world damage from setting kills negative
Reply With Quote #10

PHP Code:
#pragma semicolon 1

#include <sourcemod>

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

public 
Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
victim GetClientOfUserId(GetEventInt(event"userid"));
    new 
attacker GetClientOfUserId(GetEventInt(event"attacker"));
    
    if ((
<= victim <= MaxClients) && IsClientInGame(victim)) {
        if ((
victim == attacker) || attacker == 0) {
            
SetEntProp(victimProp_Data"m_iFrags"GetClientFrags(victim) + 1);
        }
    }

ici 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 00:11.


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