So I'm trying to manipulate the scoreboard in a rank sort of game mode, where players can go up or down.
I had this, which worked, but players who had strange cosmetics would gain their points again every single frame, causing their stranges to accumulate points incredibly fast. I tried adding a boolean condition which would flip on the death event to allow this code to run once and fire the ent data, but that just didn't work for some reason.
HTML Code:
public void Hook_OnThinkPost(int iEnt)
{
//if (ChangeScores)
//{
static int iTotalScoreOffset = -1;
if (iTotalScoreOffset == -1)
{
iTotalScoreOffset = FindSendPropInfo("CTFPlayerResource", "m_iTotalScore");
}
if(iTotalScoreOffset == -1)
return;
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);
//ChangeScores = false;
//}
}
I then tried this method, but couldn't get the scores to be the right numbers without having a big condition tree.
HTML Code:
public void CalcScores(int iClient, int iKiller)
{
if (iClient != -1)
{
if (IsValidClient(iClient))
{
Handle aevent = CreateEvent("player_escort_score", true);
SetEventInt(aevent, "player", iClient);
SetEventInt(aevent, "points", -1);
FireEvent(aevent);
}
}
if (iKiller != -1)
{
if (IsValidClient(iKiller))
{
Handle aevent = CreateEvent("player_escort_score", true);
SetEventInt(aevent, "player", iKiller);
SetEventInt(aevent, "points", 0);
FireEvent(aevent);
}
}
}
My idea is to go with the first method that worked, but strip cosmetics.
Can someone tell me how to find if a user's cosmetics are strange, and if so, either de-equip them, or to remove the strange quality, or even better, just block them accumulating points.
I believe something along the lines of m_iEntityQuality, with some number, but how would I find the entity index for the cosmetics?
Thanks in advance if anyone read that