Raised This Month: $ Target: $400
 0% 

Needs correction and/or suggestions


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
cravenge
Veteran Member
Join Date: Nov 2015
Location: Chocolate Factory
Old 12-11-2016 , 07:21   Needs correction and/or suggestions
Reply With Quote #1

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 clientint 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(clientProp_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(cheatsMenutrue);
    
cheatsMenu.Display(clientMENU_TIME_FOREVER);
}

public 
int CheatsMenuHandler(Menu menuMenuAction actionint param1int param2)
{
    switch (
action)
    {
        case 
MenuAction_Select:
        {
            switch (
param2)
            {
                case 
0:
                {
                    switch (
GetEntProp(param1Prop_Send"m_flLaggedMovementValue"))
                    {
                        case 
1.0:
                        {
                            
SetEntProp(param1Prop_Send"m_flLaggedMovementValue"1.2);
                            
recordedSetting[param1][0] = 1;
                        }
                        case 
1.2:
                        {
                            
SetEntProp(param1Prop_Send"m_flLaggedMovementValue"1.5);
                            
recordedSetting[param1][0] = 2;
                        }
                        case 
1.5:
                        {
                            
SetEntProp(param1Prop_Send"m_flLaggedMovementValue"2.0);
                            
recordedSetting[param1][0] = 3;
                        }
                        case 
2.0:
                        {
                            
SetEntProp(param1Prop_Send"m_flLaggedMovementValue"2.5);
                            
recordedSetting[param1][0] = 4;
                        }
                        case 
2.5:
                        {
                            
SetEntProp(param1Prop_Send"m_flLaggedMovementValue"3.0);
                            
recordedSetting[param1][0] = 5;
                        }
                        case 
3.0:
                        {
                            
SetEntProp(param1Prop_Send"m_flLaggedMovementValue"1.0);
                            
recordedSetting[param1][0] = 0;
                        }
                    }
                    
                    
char sSHSetting[2];
                    
IntToString(recordedSetting[param1][0], sSHSetting8);
                    
SetClientCookie(param1savedSettings[0], sSHSetting);
                    
                    
ShowCheatsMenu(param1);
                }
                case 
1:
                {
                    switch (
GetEntityGravity(param1))
                    {
                        case 
1.0:
                        {
                            
SetEntityGravity(param10.8);
                            
recordedSetting[param1][1] = 1;
                        }
                        case 
0.8:
                        {
                            
SetEntityGravity(param10.6);
                            
recordedSetting[param1][1] = 2;
                        }
                        case 
0.6:
                        {
                            
SetEntityGravity(param10.5);
                            
recordedSetting[param1][1] = 3;
                        }
                        case 
0.5:
                        {
                            
SetEntityGravity(param10.2);
                            
recordedSetting[param1][1] = 4;
                        }
                        case 
0.2:
                        {
                            
SetEntityGravity(param10.1);
                            
recordedSetting[param1][1] = 5;
                        }
                        case 
1.0:
                        {
                            
SetEntityGravity(param11.0);
                            
recordedSetting[param1][1] = 0;
                        }
                    }
                    
                    
char sGHSetting[2];
                    
IntToString(recordedSetting[param1][1], sGHSetting8);
                    
SetClientCookie(param1savedSettings[1], sGHSetting);
                    
                    
DisplayCheatsMenu(param1);
                }
                case 
2:
                {
                    switch (
iInvincible[param1])
                    {
                        case 
0:
                        {
                            
iInvincible[param1] = 1;
                            
SetEntProp(param1Prop_Data"m_takedamage"01);
                            
SDKHook(param1SDKHook_OnTakeDamageInvincibilityFix);
                        }
                        case 
1;
                        {
                            
SDKUnhook(param1SDKHook_OnTakeDamageInvincibilityFix);
                            
SetEntProp(param1Prop_Data"m_takedamage"21);
                            
iInvincible[param1] = 0;
                        }
                    }
                    
                    
char sInvincibilitySetting[2];
                    
IntToString(iInvincible[param1], sInvincibilitySetting2);
                    
SetClientCookie(param1savedSettings[2], sInvincibilitySetting);
                    
                    
DisplayCheatsMenu(param1);
                }
            }
        }
        case 
MenuAction_Cancel:
        {
        }
        case 
MenuAction_End:
        {
            
delete menu;
        }
    }
}

public 
Action InvincibilityFix(int victimint &attackerint &inflictorfloat &damageint &damagetypeint &weaponfloat damageForce[3], float damagePosition[3])
{
    if (!
IsValidClient(victim))
    {
        return 
Plugin_Continue;
    }
    
    return 
Plugin_Handled;
}

public 
Action OnPlayerSpawn(Event event, const char[] namebool dontBroadcast)
{
    
int spawned GetClientOfUserId(event.GetInt("userid"));
    if (
spawned <= || spawned MaxClients || !IsClientInGame(spawned) || GetClientTeam(spawned) < 2)
    {
        return;
    }
    
    
char sSHSetting[2], sGHSetting[2], sInvincibilitySetting[2];
    
    
GetClientCookie(spawnedsavedSettings[0], sSHSettingsizeof(sSHSetting));
    
GetClientCookie(spawnedsavedSettings[1], sGHSettingsizeof(sGHSetting));
    
GetClientCookie(spawnedsavedSettings[2], sInvincibilitySettingsizeof(sInvincibilitySetting));
    
    if (
strlen(sSHSetting) && strlen(sGHSetting) && strlen(sInvincibilitySetting))
    {
        
recordedSetting[spawned][0] = StringToInt(sSHSetting);
        switch (
recordedSetting[spawned][0])
        {
            case 
0SetEntProp(spawnedProp_Send"m_flLaggedMovementValue"1.0);
            case 
1SetEntProp(spawnedProp_Send"m_flLaggedMovementValue"1.2);
            case 
2SetEntProp(spawnedProp_Send"m_flLaggedMovementValue"1.5);
            case 
3SetEntProp(spawnedProp_Send"m_flLaggedMovementValue"2.0);
            case 
4SetEntProp(spawnedProp_Send"m_flLaggedMovementValue"2.5);
            case 
5SetEntProp(spawnedProp_Send"m_flLaggedMovementValue"3.0);
        }
        
        
recordedSetting[spawned][1] = StringToInt(sGHSetting);
        switch (
recordedSetting[spawned][1])
        {
            case 
0SetEntityGravity(spawned1.0);
            case 
1SetEntityGravity(spawned0.8);
            case 
2SetEntityGravity(spawned0.6);
            case 
3SetEntityGravity(spawned0.5);
            case 
4SetEntityGravity(spawned0.2);
            case 
5SetEntityGravity(spawned0.1);
        }
        
        
iInvincible[spawned] = StringToInt(sInvincibilitySetting);
        switch (
iInvincible[spawned])
        {
            case 
0:
            {
                
iInvincible[spawned] = 1;
                
SetEntProp(spawnedProp_Data"m_takedamage"01);
                
SDKHook(spawnedSDKHook_OnTakeDamageInvincibilityFix);
            }
            case 
1;
            {
                
SDKUnhook(spawnedSDKHook_OnTakeDamageInvincibilityFix);
                
SetEntProp(spawnedProp_Data"m_takedamage"21);
                
iInvincible[spawned] = 0;
            }
        }
    }
}

stock bool IsValidClient(int client)
{
    return (
client && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) > && 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));

cravenge is offline
xines
Veteran Member
Join Date: Aug 2013
Location: Denmark
Old 12-11-2016 , 10:56   Re: Needs correction and/or suggestions
Reply With Quote #2

here did some minor edits for you as a start.

PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <clientprefs>
#include <sdkhooks>
#include <sdktools>
#pragma newdecls required

char listedCheats[3][64]; 
int iInvincible[MAXPLAYERS+1], recordedSetting[MAXPLAYERS+1][2]; 
Handle savedSettings[3] = null

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 clientint 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 = new Menu(CheatsMenuHandler);
    
cheatsMenu.SetTitle("Admin/VIP Cheats Menu:"); 
    
    
Format(listedCheats[0], 64"Speed Hack: [%d]"GetEntProp(clientProp_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]); 
    
    
cheatsMenu.ExitButton true;
    
cheatsMenu.Display(clientMENU_TIME_FOREVER); 


public 
int CheatsMenuHandler(Menu menuMenuAction actionint param1int param2
{
    if(!
IsValidClient(param1)) return;

    switch (
action
    { 
        case 
MenuAction_Select
        { 
            switch (
param2
            { 
                case 
0
                { 
                    switch (
GetEntProp(param1Prop_Send"m_flLaggedMovementValue")) 
                    { 
                        case 
1.0
                        { 
                            
SetEntProp(param1Prop_Send"m_flLaggedMovementValue"1.2); 
                            
recordedSetting[param1][0] = 1
                        } 
                        case 
1.2
                        { 
                            
SetEntProp(param1Prop_Send"m_flLaggedMovementValue"1.5); 
                            
recordedSetting[param1][0] = 2
                        } 
                        case 
1.5
                        { 
                            
SetEntProp(param1Prop_Send"m_flLaggedMovementValue"2.0); 
                            
recordedSetting[param1][0] = 3
                        } 
                        case 
2.0
                        { 
                            
SetEntProp(param1Prop_Send"m_flLaggedMovementValue"2.5); 
                            
recordedSetting[param1][0] = 4
                        } 
                        case 
2.5
                        { 
                            
SetEntProp(param1Prop_Send"m_flLaggedMovementValue"3.0); 
                            
recordedSetting[param1][0] = 5
                        } 
                        case 
3.0
                        { 
                            
SetEntProp(param1Prop_Send"m_flLaggedMovementValue"1.0); 
                            
recordedSetting[param1][0] = 0
                        } 
                    } 
                    
                    
char sSHSetting[2]; 
                    
IntToString(recordedSetting[param1][0], sSHSetting8); 
                    
SetClientCookie(param1savedSettings[0], sSHSetting); 
                    
                    
ShowCheatsMenu(param1); 
                } 
                case 
1
                {
                    switch (
GetEntityGravity(param1)) 
                    { 
                        case 
1.0
                        { 
                            
SetEntityGravity(param10.8); 
                            
recordedSetting[param1][1] = 1
                        } 
                        case 
0.8
                        { 
                            
SetEntityGravity(param10.6); 
                            
recordedSetting[param1][1] = 2
                        } 
                        case 
0.6
                        { 
                            
SetEntityGravity(param10.5); 
                            
recordedSetting[param1][1] = 3
                        } 
                        case 
0.5
                        { 
                            
SetEntityGravity(param10.2); 
                            
recordedSetting[param1][1] = 4
                        } 
                        case 
0.2
                        { 
                            
SetEntityGravity(param10.1); 
                            
recordedSetting[param1][1] = 5
                        } 
                        case 
1.0
                        { 
                            
SetEntityGravity(param11.0); 
                            
recordedSetting[param1][1] = 0
                        } 
                    } 
                    
                    
char sGHSetting[2]; 
                    
IntToString(recordedSetting[param1][1], sGHSetting8); 
                    
SetClientCookie(param1savedSettings[1], sGHSetting); 
                    
                    
DisplayCheatsMenu(param1); 
                } 
                case 
2
                { 
                    switch (
iInvincible[param1]) 
                    { 
                        case 
0
                        { 
                            
iInvincible[param1] = 1
                            
SetEntProp(param1Prop_Data"m_takedamage"01); 
                            
SDKHook(param1SDKHook_OnTakeDamageInvincibilityFix); 
                        } 
                        case 
1
                        { 
                            
SDKUnhook(param1SDKHook_OnTakeDamageInvincibilityFix); 
                            
SetEntProp(param1Prop_Data"m_takedamage"21); 
                            
iInvincible[param1] = 0
                        } 
                    } 
                    
                    
char sInvincibilitySetting[2]; 
                    
IntToString(iInvincible[param1], sInvincibilitySetting2); 
                    
SetClientCookie(param1savedSettings[2], sInvincibilitySetting); 
                    
                    
DisplayCheatsMenu(param1); 
                } 
            } 
        } 
        
//case MenuAction_Cancel: 
        //{ 
        //} 
        
case MenuAction_End
        {
            
delete menu
        }
    } 


public 
Action InvincibilityFix(int victimint &attackerint &inflictorfloat &damageint &damagetypeint &weaponfloat damageForce[3], float damagePosition[3]) 

    if (!
IsValidClient(victim)) return Plugin_Continue

    return 
Plugin_Handled
}

public 
Action OnPlayerSpawn(Event event, const char[] namebool dontBroadcast

    
int spawned GetClientOfUserId(event.GetInt("userid")); 
    if (
spawned <= || spawned MaxClients || !IsClientInGame(spawned) || GetClientTeam(spawned) < 2
    {
        return 
Plugin_Continue;
    }
    
    
char sSHSetting[2], sGHSetting[2], sInvincibilitySetting[2]; 
    
    
GetClientCookie(spawnedsavedSettings[0], sSHSettingsizeof(sSHSetting)); 
    
GetClientCookie(spawnedsavedSettings[1], sGHSettingsizeof(sGHSetting)); 
    
GetClientCookie(spawnedsavedSettings[2], sInvincibilitySettingsizeof(sInvincibilitySetting)); 
    
    if (
strlen(sSHSetting) && strlen(sGHSetting) && strlen(sInvincibilitySetting)) 
    { 
        
recordedSetting[spawned][0] = StringToInt(sSHSetting); 
        switch (
recordedSetting[spawned][0]) 
        { 
            case 
0SetEntProp(spawnedProp_Send"m_flLaggedMovementValue"1.0); 
            case 
1SetEntProp(spawnedProp_Send"m_flLaggedMovementValue"1.2); 
            case 
2SetEntProp(spawnedProp_Send"m_flLaggedMovementValue"1.5); 
            case 
3SetEntProp(spawnedProp_Send"m_flLaggedMovementValue"2.0); 
            case 
4SetEntProp(spawnedProp_Send"m_flLaggedMovementValue"2.5); 
            case 
5SetEntProp(spawnedProp_Send"m_flLaggedMovementValue"3.0); 
        } 
        
        
recordedSetting[spawned][1] = StringToInt(sGHSetting); 
        switch (
recordedSetting[spawned][1]) 
        { 
            case 
0SetEntityGravity(spawned1.0); 
            case 
1SetEntityGravity(spawned0.8); 
            case 
2SetEntityGravity(spawned0.6); 
            case 
3SetEntityGravity(spawned0.5); 
            case 
4SetEntityGravity(spawned0.2); 
            case 
5SetEntityGravity(spawned0.1); 
        } 
        
        
iInvincible[spawned] = StringToInt(sInvincibilitySetting); 
        switch (
iInvincible[spawned]) 
        { 
            case 
0
            { 
                
iInvincible[spawned] = 1
                
SetEntProp(spawnedProp_Data"m_takedamage"01); 
                
SDKHook(spawnedSDKHook_OnTakeDamageInvincibilityFix); 
            } 
            case 
1
            { 
                
SDKUnhook(spawnedSDKHook_OnTakeDamageInvincibilityFix); 
                
SetEntProp(spawnedProp_Data"m_takedamage"21); 
                
iInvincible[spawned] = 0
            } 
        } 
    }
    return 
Plugin_Continue


stock bool IsValidClient(int client

    return (
client && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) > && 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)); 

__________________
xines is offline
cravenge
Veteran Member
Join Date: Nov 2015
Location: Chocolate Factory
Old 12-11-2016 , 17:35   Re: Needs correction and/or suggestions
Reply With Quote #3

Thanks, xines. Now can anyone tell me how to make translucent walls only applied to the cheaters? I have this neat code here:
PHP Code:
int physics FindEntityByClassname(-1"prop_physics");
if (
physics != -1)
{
    
SetEntityRenderMode(physicsRENDER_TRANSALPHA);
    
SetEntityRenderColor(physics255255255100);
}

int dynamic FindEntityByClassname(-1"prop_dynamic");
if (
dynamic != -1)
{
    
SetEntityRenderMode(dynamicRENDER_TRANSALPHA);
    
SetEntityRenderColor(dynamic255255255100);
}

int dynamic_override FindEntityByClassname(-1"prop_dynamic_override");
if (
dynamic_override != -1)
{
    
SetEntityRenderMode(dynamic_overrideRENDER_TRANSALPHA);
    
SetEntityRenderColor(dynamic_override255255255100);


Last edited by cravenge; 12-11-2016 at 17:35.
cravenge 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 16:02.


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