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_PlayerDeath, EventHookMode_Post);
}
public void OnMapStart()
{
int iIndex = FindEntityByClassname(MaxClients+1, "tf_player_manager");
if (iIndex == -1) {
SetFailState("Unable to find tf_player_manager entity");
}
SDKHook(iIndex, SDKHook_ThinkPost, Hook_OnThinkPost);
}
public int Hook_OnThinkPost(int iEnt) {
static int iTotalScoreOffset = -1;
if (iTotalScoreOffset == -1) {
iTotalScoreOffset = FindSendPropInfo("CTFPlayerResource", "m_iTotalScore");
}
int iTotalScore[MAXPLAYERS+1];
GetEntDataArray(iEnt, iTotalScoreOffset, iTotalScore, MaxClients+1);
for (int i = 1; i <= MaxClients; i++) {
if (IsClientInGame(i) && g_iSetScore[i] > -1) {
iTotalScore[i] = g_iSetScore[i];
}
}
SetEntDataArray(iEnt, iTotalScoreOffset, iTotalScore, MaxClients+1);
}
public Action Event_PlayerDeath(Handle event, const char[] name, bool dontBroadcast)
{
for(int client = 0; client <= MaxClients; client++)
{
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.