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

Preventing Strange Cosmetics Levelling


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Noodl
Member
Join Date: Jun 2015
Old 07-04-2017 , 08:01   Preventing Strange Cosmetics Levelling
Reply With Quote #1

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
Noodl is offline
404UserNotFound
BANNED
Join Date: Dec 2011
Old 07-07-2017 , 23:46   Re: Preventing Strange Cosmetics Levelling
Reply With Quote #2

Use TF2Items I think? It's been a while since I've fucked with doing things based on an item's quality.

PHP Code:
/**
 * Gets the item's quality value, wich determines what color will be used for
 * the item name. Valid values are from 0 to 9. But if set to 0 and attributes
 * are also changed, this value will be overridden to 9
 *
 * @param hItem        Handle to the TF2Items object that we'll be operating with.
 * @return            New entity quality.
 */
native int TF2Items_GetQuality(Handle hItem); 
Quality IDs are out there everywhere. TF2Items has many getter natives for various things such as item level, ID, attributes, etc.

You could also try looking for the various kill eater attributes and removing them if detected on a client's weapons/granting them a non-Strange counterpart of the currently equipped weapon. Seems like there'd be a few ways to do this now that I think about it.

Last edited by 404UserNotFound; 07-07-2017 at 23:48.
404UserNotFound 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 19:21.


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