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

Add additional checks.

parent 427ff571
......@@ -9,7 +9,7 @@ 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",
version = "0.0.2",
url = "http://nexisonline.net"
};
......@@ -31,6 +31,7 @@ public OnPluginStart()
HookGetPackSize(gamedata);
CloseHandle(gamedata);
HookEvent("mvm_pickup_currency", OnPickupMVMCurrency, EventHookMode_Post);
HookEvent("teamplay_restart_round", OnRoundRestart, EventHookMode_Post);
}
public Action OnPickupMVMCurrency(Handle event, const char[] name, bool dontBroadcast)
......@@ -39,6 +40,10 @@ public Action OnPickupMVMCurrency(Handle event, const char[] name, bool dontBroa
CheckClientCurrency(client);
}
public Action OnRoundRestart(Handle event, const char[] name, bool dontBroadcast)
{
CheckAllClientCurrency();
}
public void OnEntityCreated(int entity, const char[] classname) {
// Stolen from Friendly Mode.
if (StrContains(classname, "item_currencypack_", false) != -1) {
......@@ -84,6 +89,17 @@ public void WarnIfFlagSet(int client, int flag, const char[] warning, any ...)
VFormat(formattedWarning, len, warning, 4);
PrintToChat(client, formattedWarning);
}
public void CheckAllClientCurrency() {
for (new i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i))
{
CheckClientCurrency(i);
}
}
}
public void CheckClientCurrency(int client) {
if(!IsValidClient(client))
return;
......@@ -91,8 +107,8 @@ public void CheckClientCurrency(int client) {
int newbank=-1
if(currentbank < 0)
{
WarnIfFlagSet(client, MVMFIX_WARNFLAG_UNDERFLOW, "[MvMFix] You had $%d cash. It has been changed to $0 to prevent an underflow crash.", currentbank);
newbank = 0;
WarnIfFlagSet(client, MVMFIX_WARNFLAG_UNDERFLOW, "[MvMFix] You had $%d cash. It has been changed to $400 to prevent an underflow crash.", currentbank);
newbank = 400;
}
if(currentbank > 30000)
{
......
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