Just deleted about 400 bot accounts and a bunch of spam. To mitigate this in the future, we've enabled reCaptcha on signup. Let me know if someone got caught in the crossfire.

Commit 427ff571 authored by Rob Nelson's avatar Rob Nelson
Browse files

Add client m_nCurrency checks.

parent c119806d
Pipeline #89 skipped
......@@ -13,7 +13,11 @@ public Plugin myinfo =
url = "http://nexisonline.net"
};
//new g_iCachedCash[MAXPLAYERS+1];
new gClientWarnFlags[MAXPLAYERS+1];
// Warnflags
#define MVMFIX_WARNFLAG_OVERFLOW (1 << 0)
#define MVMFIX_WARNFLAG_UNDERFLOW (1 << 1)
Handle hGetPackSize=INVALID_HANDLE;
......@@ -26,6 +30,13 @@ public OnPluginStart()
HookGetPackSize(gamedata);
CloseHandle(gamedata);
HookEvent("mvm_pickup_currency", OnPickupMVMCurrency, EventHookMode_Post);
}
public Action OnPickupMVMCurrency(Handle event, const char[] name, bool dontBroadcast)
{
int client = GetEventInt(event, "player");
CheckClientCurrency(client);
}
public void OnEntityCreated(int entity, const char[] classname) {
......@@ -54,27 +65,66 @@ public int GetPackSize(int entity) {
return SDKCall(hGetPackSize,entity)
}
/*
public OnClientConnected(client)
{
g_iCachedCash[client] = 0;
gClientWarnFlags[client] = 0;
CheckClientCurrency(client);
}
*/
public void WarnIfFlagSet(int client, int flag, const char[] warning, any ...)
{
if((gClientWarnFlags[client] & flag) == flag) {
return;
}
gClientWarnFlags[client] |= flag;
int len = strlen(warning) + 255;
char[] formattedWarning = new char[len];
VFormat(formattedWarning, len, warning, 4);
PrintToChat(client, formattedWarning);
}
public void CheckClientCurrency(int client) {
if(!IsValidClient(client))
return;
int currentbank = GetEntProp(client, Prop_Send, "m_nCurrency");
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;
}
if(currentbank > 30000)
{
WarnIfFlagSet(client, MVMFIX_WARNFLAG_OVERFLOW, "[MvMFix] You had $%d cash. It has been changed to $30,000 to prevent an overflow crash.", currentbank);
newbank = 30000;
}
if(newbank != -1) {
decl String:strSteamID[32];
decl String:strClientName[100];
GetClientName(client, strClientName, sizeof(strClientName));
GetClientAuthId(client, AuthId_Steam3, strSteamID, sizeof(strSteamID));
LogMessage("[MVMFix] Client %s (%s) had $%d, clamped to $%d.", strClientName, strSteamID, currentbank, newbank);
SetEntProp(client, Prop_Send, "m_nCurrency", 0);
}
}
public Action OnMoneyTouch(int ent, int client) {
if (!IsValidClient(client)) {
return Plugin_Continue;
}
CheckClientCurrency(client);
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);
LogMessage("[MVMFix] Received OnMoneyTouch: %d picked up! (%d total)", dollars, totalbank);
/*
if(totalbank < 0 || totalbank > 30000) {
WarnIfFlagSet(client, MVMFIX_WARNFLAG_OVERFLOW, "[MvMFix] You had $%d cash. You have been prevented from picking up additional cash to prevent an overflow crash.", totalbank);
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