Currently, I'm making a cheats menu for Admin and VIP accesses only but I'm not sure if it works correctly. Below is the source code:
PHP Code:
#pragma semicolon 1
#pragma newdecls required
#include <sourcemod>
#include <clientprefs>
#include <sdkhooks>
#include <sdktools>
char listedCheats[3][64];
int iInvincible[MAXPLAYERS+1], recordedSetting[MAXPLAYERS+1][2];
Handle savedSettings[3];
public Plugin myinfo =
{
name = "[Any] Admin/VIP Cheats Menu",
author = "cravenge",
description = "Provides Menu With Cheats For Admins and VIPs.",
version = "1.0",
url = ""
};
public void OnPluginStart()
{
savedSettings[0] = RegClientCookie("cm_speed_hack", "Last Speed Hack Setting", CookieAccess_Protected);
savedSettings[1] = RegClientCookie("cm_gravity_hack", "Last Gravity Hack Setting", CookieAccess_Protected);
savedSettings[2] = RegClientCookie("cm_invincibility", "Last Invincibility Setting", CookieAccess_Protected);
CreateConVar("cheats_menu_version", "1.0", "Admin/VIP Cheats Menu Version", FCVAR_NOTIFY);
HookEvent("player_spawn", OnPlayerSpawn);
RegConsoleCmd("sm_cheatsmenu", DisplayCheatsMenu, "Displays Menu With Cheats");
}
public Action DisplayCheatsMenu(int client, int args)
{
if (!IsValidClient(client) || !IsAdminOrVIP(client))
{
PrintToChat(client, "\x04[CM]\x01 Invalid Access!");
return Plugin_Handled;
}
ShowCheatsMenu(client);
return Plugin_Handled;
}
void ShowCheatsMenu(int client)
{
Menu cheatsMenu = CreateMenu(CheatsMenuHandler);
cheatsMenu.SetTitle("Admin/VIP Cheats Menu:");
Format(listedCheats[0], 64, "Speed Hack: [%d]", GetEntProp(client, Prop_Send, "m_flLaggedMovementValue"));
cheatsMenu.AddItem("0", listedCheats[0]);
Format(listedCheats[1], 64, "Gravity Hack: [%d]", GetEntityGravity(client));
cheatsMenu.AddItem("1", listedCheats[1]);
Format(listedCheats[2], 64, "Invincibility: [%s]", (iInvincible[client] == 1) ? "Enabled" : "Disabled");
cheatsMenu.AddItem("2", listedCheats[2]);
SetMenuExitButton(cheatsMenu, true);
cheatsMenu.Display(client, MENU_TIME_FOREVER);
}
public int CheatsMenuHandler(Menu menu, MenuAction action, int param1, int param2)
{
switch (action)
{
case MenuAction_Select:
{
switch (param2)
{
case 0:
{
switch (GetEntProp(param1, Prop_Send, "m_flLaggedMovementValue"))
{
case 1.0:
{
SetEntProp(param1, Prop_Send, "m_flLaggedMovementValue", 1.2);
recordedSetting[param1][0] = 1;
}
case 1.2:
{
SetEntProp(param1, Prop_Send, "m_flLaggedMovementValue", 1.5);
recordedSetting[param1][0] = 2;
}
case 1.5:
{
SetEntProp(param1, Prop_Send, "m_flLaggedMovementValue", 2.0);
recordedSetting[param1][0] = 3;
}
case 2.0:
{
SetEntProp(param1, Prop_Send, "m_flLaggedMovementValue", 2.5);
recordedSetting[param1][0] = 4;
}
case 2.5:
{
SetEntProp(param1, Prop_Send, "m_flLaggedMovementValue", 3.0);
recordedSetting[param1][0] = 5;
}
case 3.0:
{
SetEntProp(param1, Prop_Send, "m_flLaggedMovementValue", 1.0);
recordedSetting[param1][0] = 0;
}
}
char sSHSetting[2];
IntToString(recordedSetting[param1][0], sSHSetting, 8);
SetClientCookie(param1, savedSettings[0], sSHSetting);
ShowCheatsMenu(param1);
}
case 1:
{
switch (GetEntityGravity(param1))
{
case 1.0:
{
SetEntityGravity(param1, 0.8);
recordedSetting[param1][1] = 1;
}
case 0.8:
{
SetEntityGravity(param1, 0.6);
recordedSetting[param1][1] = 2;
}
case 0.6:
{
SetEntityGravity(param1, 0.5);
recordedSetting[param1][1] = 3;
}
case 0.5:
{
SetEntityGravity(param1, 0.2);
recordedSetting[param1][1] = 4;
}
case 0.2:
{
SetEntityGravity(param1, 0.1);
recordedSetting[param1][1] = 5;
}
case 1.0:
{
SetEntityGravity(param1, 1.0);
recordedSetting[param1][1] = 0;
}
}
char sGHSetting[2];
IntToString(recordedSetting[param1][1], sGHSetting, 8);
SetClientCookie(param1, savedSettings[1], sGHSetting);
DisplayCheatsMenu(param1);
}
case 2:
{
switch (iInvincible[param1])
{
case 0:
{
iInvincible[param1] = 1;
SetEntProp(param1, Prop_Data, "m_takedamage", 0, 1);
SDKHook(param1, SDKHook_OnTakeDamage, InvincibilityFix);
}
case 1;
{
SDKUnhook(param1, SDKHook_OnTakeDamage, InvincibilityFix);
SetEntProp(param1, Prop_Data, "m_takedamage", 2, 1);
iInvincible[param1] = 0;
}
}
char sInvincibilitySetting[2];
IntToString(iInvincible[param1], sInvincibilitySetting, 2);
SetClientCookie(param1, savedSettings[2], sInvincibilitySetting);
DisplayCheatsMenu(param1);
}
}
}
case MenuAction_Cancel:
{
}
case MenuAction_End:
{
delete menu;
}
}
}
public Action InvincibilityFix(int victim, int &attacker, int &inflictor, float &damage, int &damagetype, int &weapon, float damageForce[3], float damagePosition[3])
{
if (!IsValidClient(victim))
{
return Plugin_Continue;
}
return Plugin_Handled;
}
public Action OnPlayerSpawn(Event event, const char[] name, bool dontBroadcast)
{
int spawned = GetClientOfUserId(event.GetInt("userid"));
if (spawned <= 0 || spawned > MaxClients || !IsClientInGame(spawned) || GetClientTeam(spawned) < 2)
{
return;
}
char sSHSetting[2], sGHSetting[2], sInvincibilitySetting[2];
GetClientCookie(spawned, savedSettings[0], sSHSetting, sizeof(sSHSetting));
GetClientCookie(spawned, savedSettings[1], sGHSetting, sizeof(sGHSetting));
GetClientCookie(spawned, savedSettings[2], sInvincibilitySetting, sizeof(sInvincibilitySetting));
if (strlen(sSHSetting) && strlen(sGHSetting) && strlen(sInvincibilitySetting))
{
recordedSetting[spawned][0] = StringToInt(sSHSetting);
switch (recordedSetting[spawned][0])
{
case 0: SetEntProp(spawned, Prop_Send, "m_flLaggedMovementValue", 1.0);
case 1: SetEntProp(spawned, Prop_Send, "m_flLaggedMovementValue", 1.2);
case 2: SetEntProp(spawned, Prop_Send, "m_flLaggedMovementValue", 1.5);
case 3: SetEntProp(spawned, Prop_Send, "m_flLaggedMovementValue", 2.0);
case 4: SetEntProp(spawned, Prop_Send, "m_flLaggedMovementValue", 2.5);
case 5: SetEntProp(spawned, Prop_Send, "m_flLaggedMovementValue", 3.0);
}
recordedSetting[spawned][1] = StringToInt(sGHSetting);
switch (recordedSetting[spawned][1])
{
case 0: SetEntityGravity(spawned, 1.0);
case 1: SetEntityGravity(spawned, 0.8);
case 2: SetEntityGravity(spawned, 0.6);
case 3: SetEntityGravity(spawned, 0.5);
case 4: SetEntityGravity(spawned, 0.2);
case 5: SetEntityGravity(spawned, 0.1);
}
iInvincible[spawned] = StringToInt(sInvincibilitySetting);
switch (iInvincible[spawned])
{
case 0:
{
iInvincible[spawned] = 1;
SetEntProp(spawned, Prop_Data, "m_takedamage", 0, 1);
SDKHook(spawned, SDKHook_OnTakeDamage, InvincibilityFix);
}
case 1;
{
SDKUnhook(spawned, SDKHook_OnTakeDamage, InvincibilityFix);
SetEntProp(spawned, Prop_Data, "m_takedamage", 2, 1);
iInvincible[spawned] = 0;
}
}
}
}
stock bool IsValidClient(int client)
{
return (client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) > 1 && IsPlayerAlive(client));
}
stock bool IsAdminOrVIP(int client)
{
return ((GetUserFlagBits(client) & ADMFLAG_GENERIC) || (GetUserFlagBits(client) & ADMFLAG_ROOT) || (GetUserFlagBits(client) & ADMFLAG_CUSTOM1) || (GetUserFlagBits(client) & ADMFLAG_CUSTOM2) || (GetUserFlagBits(client) & ADMFLAG_CUSTOM3) || (GetUserFlagBits(client) & ADMFLAG_CUSTOM4) || (GetUserFlagBits(client) & ADMFLAG_CUSTOM5) || (GetUserFlagBits(client) & ADMFLAG_CUSTOM6));
}