Commit c119806d authored by Rob Nelson's avatar Rob Nelson
Browse files

I have no idea what I'm doing.

parents
Pipeline #75 skipped
import os
import platform
import sys
from buildtools import cmd, log, os_utils
SOURCEMOD_DIR = os.environ.get('SOURCEMOD18', os.path.join('..', 'sourcemod', 'sourcemod', 'build', 'package', 'addons', 'sourcemod'))
PROJECT_DIR = os.path.abspath(os.getcwd())
PLUGINS_DIR = os.path.join(PROJECT_DIR, 'plugins')
SPCOMP = 'spcomp.exe'
if platform.system() == 'Linux':
SPCOMP = 'spcomp'
SPCOMP_FLAGS = [
'-v0', # No banner
'-i=' + os.path.join(PROJECT_DIR, 'scripting', 'include'),
]
def spcomp(filename):
os_utils.ensureDirExists(PLUGINS_DIR, noisy=True)
basename, _ = os.path.splitext(os.path.basename(filename))
smxname = basename + '.smx'
smxpath = os.path.join(PLUGINS_DIR, smxname)
log.info('SPCOMP ' + smxname)
cmd([os.path.join(SOURCEMOD_DIR, 'scripting', SPCOMP)] + SPCOMP_FLAGS + ['-o=' + smxpath, filename], critical=True, show_output=True, echo=False)
log.info('SOURCEMOD18='+SOURCEMOD_DIR)
with os_utils.Chdir(os.path.join(PROJECT_DIR, 'scripting')):
spcomp('fixcashoverflow.sp')
"Games"
{
"tf"
{
"Offsets"
{
"CCurrencyPack::GetPackSize"
{
"windows" "229"
"linux" "232"
}
}
}
}
\ No newline at end of file
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#undef REQUIRE_PLUGIN
#include <tf2>
public Plugin myinfo =
{
name = "[TF2] MvM Cash Overflow Fix",
author = "N3X15",
description = "Fixes net buffer overflow caused by too much money.",
version = "0.0.1",
url = "http://nexisonline.net"
};
//new g_iCachedCash[MAXPLAYERS+1];
Handle hGetPackSize=INVALID_HANDLE;
public OnPluginStart()
{
Handle gamedata = LoadGameConfigFile("fixcashoverflow.games");
if(gamedata == INVALID_HANDLE)
SetFailState("GAMEDATA MISSING. Did you put fixcashoverflow.games.txt into sourcemod/gamedata/?");
HookGetPackSize(gamedata);
CloseHandle(gamedata);
}
public void OnEntityCreated(int entity, const char[] classname) {
// Stolen from Friendly Mode.
if (StrContains(classname, "item_currencypack_", false) != -1) {
SDKHook(entity, SDKHook_StartTouch, OnMoneyTouch);
SDKHook(entity, SDKHook_Touch, OnMoneyTouch);
}
}
stock bool:IsValidClient(int client, bool:nobots = true) {
if (client <= 0 || client > MaxClients || !IsClientConnected(client) || (nobots && IsFakeClient(client))) {
return false;
}
return IsClientInGame(client);
}
public void HookGetPackSize(Handle gamedata) {
StartPrepSDKCall(SDKCall_Entity);
PrepSDKCall_SetFromConf(gamedata, SDKConf_Virtual, "CCurrencyPack::GetPackSize");
PrepSDKCall_SetReturnInfo(SDKType_PlainOldData, SDKPass_Plain);
hGetPackSize = EndPrepSDKCall();
}
public int GetPackSize(int entity) {
return SDKCall(hGetPackSize,entity)
}
/*
public OnClientConnected(client)
{
g_iCachedCash[client] = 0;
}
*/
public Action OnMoneyTouch(int ent, int client) {
if (!IsValidClient(client)) {
return Plugin_Continue;
}
int dollars = GetPackSize(ent);
int currentbank = GetEntProp(client, Prop_Send, "m_nCurrency");
int totalbank = dollars + currentbank;
LogMessage("Received OnMoneyTouch: %d picked up! (%d total)", dollars, totalbank);
if(totalbank < 0 || totalbank > 30000) {
return Plugin_Stop;
}
return Plugin_Continue;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment