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

[TF2] Set players score to 0 when they kill someone


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SomePanns
Senior Member
Join Date: Dec 2013
Old 05-08-2017 , 10:20   [TF2] Set players score to 0 when they kill someone
Reply With Quote #1

Using this (https://forums.alliedmods.net/showpo...77&postcount=2) code, I've been trying to set a players score points to 0 every time they kill someone, but it doesn't change the score. Now as a side note, the code provided in the link compiles and works fine, so I'm not sure why it doesn't work in this way as well.

PHP Code:
#pragma semicolon 1

#include <sourcemod>
#include <tf2_stocks>
#include <sdkhooks>

int g_iSetScore[MAXPLAYERS+1] = { -1, ... };

public 
Plugin myinfo 
{
    
name "",
    
author "",
    
description "",
    
version "",
    
url ""
};

public 
void OnPluginStart()
{
    
HookEvent("player_death"Event_PlayerDeathEventHookMode_Post);
}

public 
void OnMapStart()
{
    
int iIndex FindEntityByClassname(MaxClients+1"tf_player_manager");
    if (
iIndex == -1) {
        
SetFailState("Unable to find tf_player_manager entity");
    }
    
    
SDKHook(iIndexSDKHook_ThinkPostHook_OnThinkPost);
}

public 
int Hook_OnThinkPost(int iEnt) {
    static 
int iTotalScoreOffset = -1;
    if (
iTotalScoreOffset == -1) {
        
iTotalScoreOffset FindSendPropInfo("CTFPlayerResource""m_iTotalScore");
    }
    
    
int iTotalScore[MAXPLAYERS+1];
    
GetEntDataArray(iEntiTotalScoreOffsetiTotalScoreMaxClients+1);
    
    for (
int i 1<= MaxClientsi++) {
        if (
IsClientInGame(i) && g_iSetScore[i] > -1) {
            
iTotalScore[i] = g_iSetScore[i];
        }
    }
    
    
SetEntDataArray(iEntiTotalScoreOffsetiTotalScoreMaxClients+1);
}

public 
Action Event_PlayerDeath(Handle event, const char[] namebool dontBroadcast)
{
    for(
int client 0client <= MaxClientsclient++)
    {
        
g_iSetScore[client] = 0;
    }
    
    return 
Plugin_Handled;

I've also tried it as a timer that repeats every 0.1 seconds but no success with that either.
SomePanns is offline
SomePanns
Senior Member
Join Date: Dec 2013
Old 05-11-2017 , 11:09   Re: [TF2] Set players score to 0 when they kill someone
Reply With Quote #2

I managed to solve it by creating an event for player_escort_score instead.
SomePanns 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 18:58.


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