tetratheta

[Sven Coop] Cheats through chat

Aug 23rd, 2021 (edited)
1,936
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Original source code: https://github.com/wootguy/Cheats
  2. // Added '.hc' command which will heal and charge HEV in once
  3. // Since I am lazy, I didn't added help thing
  4.  
  5. // Modified code:
  6.  
  7. // Requests:
  8. // giveammo [amt] [type] - if type is ommitted, it gives ammo for current weapon
  9. // rate of fire modifier? clip/max ammo modifier? reload speed? damage modifier?
  10. // infinite jump
  11. // infammo
  12. // setammo
  13.  
  14. void PluginInit()
  15. {
  16.     g_Module.ScriptInfo.SetAuthor( "w00tguy" );
  17.     g_Module.ScriptInfo.SetContactInfo( "w00tguy123 - forums.svencoop.com" );
  18.    
  19.     g_Hooks.RegisterHook( Hooks::Player::ClientSay, @ClientSayCheat );
  20.     g_Hooks.RegisterHook( Hooks::Game::MapChange, @MapChange );
  21.    
  22.     initCheatAliases();
  23.    
  24.     g_Scheduler.SetInterval("constantCheats", 0);
  25. }
  26.  
  27. void print(string text) { g_Game.AlertMessage( at_console, text); }
  28. void println(string text) { print(text + "\n"); }
  29.  
  30. void printPlr(CBasePlayer@ plr, string text) { g_PlayerFuncs.ClientPrint( plr, HUD_PRINTCONSOLE, text); }
  31. void printlnPlr(CBasePlayer@ plr, string text) { printPlr(plr, text + "\n"); }
  32.  
  33. HookReturnCode MapChange()
  34. {
  35.     player_states.deleteAll();
  36.     constant_cheats.resize(0);
  37.     //cheats_for_all = false;
  38.     return HOOK_CONTINUE;
  39. }
  40.  
  41. enum cheat_type
  42. {
  43.     CHEAT_TOGGLE, // some state like godmode or noclip
  44.     CHEAT_GIVE, // a give command or impulse 101
  45.     CHEAT_ACTION, // do something to someone (e.g. revive, heal, charge)
  46. };
  47.  
  48. enum cheat_toggle_modes
  49. {
  50.     TOGGLE_OFF,
  51.     TOGGLE_ON,
  52.     TOGGLE_TOGGLE, // lol
  53. };
  54.  
  55. enum cheat_fail_reasons
  56. {
  57.     FAIL_TARGET_DEAD = -999,
  58.     FAIL_TARGET_ALIVE,
  59.     FAIL_TARGET_ADMIN,
  60. }
  61.  
  62. // params = target player, cheat arguments
  63. funcdef int CheatFunction(CBasePlayer@, array<string>@);
  64.  
  65. class Cheat
  66. {
  67.     string name; // used in text messages (e.g. "w00tguy gave you noclip")
  68.     CheatFunction@ cheatFunc; // function to execute
  69.     int type;    // cheat_type
  70.     int numArgs; // args required by the command
  71.     int lastState; // for toggled cheats
  72.     bool adminOnly; // if true, peasants can't use the cheat even when global cheats are enabled
  73.     bool ownerOnly; // if true, nobody but the server owner can use the cheat
  74.    
  75.     Cheat(string name, CheatFunction@ cheatFunc, int type, int numArgs, bool adminOnly, bool ownerOnly)
  76.     {
  77.         this.name = name;
  78.         @this.cheatFunc = cheatFunc;
  79.         this.type = type;
  80.         this.numArgs = numArgs;
  81.         this.adminOnly = adminOnly;
  82.         this.ownerOnly = ownerOnly;
  83.         lastState = TOGGLE_OFF;
  84.     }
  85. };
  86.  
  87. // --------------------------------
  88. // CHANGE CHEAT PERMISSIONS HERE!!!
  89. // --------------------------------
  90.  
  91. // The last two columns with true/false values control who can use the cheat:
  92. // 'true' in the 1st column = only admins can use the cheat when '.cheats 1' is active
  93. // 'true' in the 2nd column = only the server owner can use the cheat
  94. dictionary cheats = {
  95.     {'.noclip',     Cheat("noclip",         toggleNoclip,   CHEAT_TOGGLE,   0, false, false)},
  96.     {'.godmode',    Cheat("godmode",        toggleGodmode,  CHEAT_TOGGLE,   0, false, false)},
  97.     {'.notarget',   Cheat("notarget",       toggleNotarget, CHEAT_TOGGLE,   0, false, false)},
  98.     {'.cloak',      Cheat("cloak",          toggleCloak,    CHEAT_TOGGLE,   0, false, false)},
  99.     {'.notouch',    Cheat("notouch",        toggleNotouch,  CHEAT_TOGGLE,   0, false, false)},
  100.     {'.rambo',      Cheat("rambo",          toggleRambo,    CHEAT_TOGGLE,   0, false, false)},
  101.     {'.cheats',     Cheat("cheats",         toggleCheats,   CHEAT_TOGGLE,   0, true,  false)},
  102.     {'.impulse',    Cheat("impulse %0",     useImpulse,     CHEAT_GIVE,     1, false, false)},
  103.     {'.give',       Cheat("%0",             giveItem,       CHEAT_GIVE,     1, false, false)},
  104.     {'.givepoints', Cheat("%0 points",      givePoints,     CHEAT_GIVE,     1, false, false)},
  105.     {'.maxhealth',  Cheat("maxhealth",      setMaxHealth,   CHEAT_GIVE,     1, false, false)},
  106.     {'.maxarmor',   Cheat("maxarmor",       setMaxCharge,   CHEAT_GIVE,     1, false, false)},
  107.     {'.speed',      Cheat("%0 speed",       setMaxSpeed,    CHEAT_GIVE,     1, false, false)},
  108.     {'.damage',     Cheat("%0 damage",      setWepDamage,   CHEAT_GIVE,     1, false, false)},
  109.     {'.gravity',    Cheat("%0% gravity",    setGravity,     CHEAT_GIVE,     1, false, false)},
  110.     {'.giveall',    Cheat("everything",     giveAll,        CHEAT_GIVE,     0, false, false)},
  111.     {'.heal',       Cheat("healed",         heal,           CHEAT_ACTION,   0, false, false)},
  112.     {'.charge',     Cheat("recharged",      charge,         CHEAT_ACTION,   0, false, false)},
  113.     {'.revive',     Cheat("revived",        revive,         CHEAT_ACTION,   0, false, false)},
  114.     {'.strip',      Cheat("stripped",       strip,          CHEAT_ACTION,   0, false, false)},
  115.     {'.hc',         Cheat("heal & charged", hc,             CHEAT_ACTION,   0, false, false)}
  116. };
  117.  
  118. // ------------------
  119. // End of permissions
  120. // ------------------
  121.  
  122. CClientCommand _cheatlist(  "cheatlist",  "Show all possible cheats", @cheatCmd );
  123. CClientCommand _noclip(     "noclip",     "Fly through walls", @cheatCmd );
  124. CClientCommand _godmode(    "godmode",    "Take no damage", @cheatCmd );
  125. CClientCommand _god(        "god",        "Take no damage", @cheatCmd );
  126. CClientCommand _notarget(   "notarget",   "Monsters ignore you", @cheatCmd );
  127. CClientCommand _cloak(      "cloak",      "Monsters ignore you and you're invisible", @cheatCmd );
  128. CClientCommand _notouch(    "notouch",    "Things pass through you, triggers ignore you", @cheatCmd );
  129. CClientCommand _rambo(      "rambo",      "Disables weapon cooldowns and reloads", @cheatCmd );
  130. CClientCommand _nonsolid(   "nonsolid",   "Things pass through you, triggers ignore you", @cheatCmd );
  131. CClientCommand _cheats(     "cheats",     "Allow cheats for players", @cheatCmd );
  132. CClientCommand _impulse(    "impulse",    "Half-Life impulse cheats", @cheatCmd );
  133. CClientCommand _give(       "give",       "Give a weapon_ or ammo_ item", @cheatCmd );
  134. CClientCommand _givepoints( "givepoints", "Adjust user score", @cheatCmd );
  135. CClientCommand _giveall(    "giveall",    "Give all weapons and infinite ammo", @cheatCmd );
  136. CClientCommand _heal(       "heal",       "Retore to full health", @cheatCmd );
  137. CClientCommand _healme(     "healme",     "Retore to full health", @cheatCmd );
  138. CClientCommand _charge(     "charge",     "Fully charge HEV suit", @cheatCmd );
  139. CClientCommand _chargeme(   "chargeme",   "Fully charge HEV suit", @cheatCmd );
  140. CClientCommand _recharge(   "recharge",   "Fully charge HEV suit", @cheatCmd );
  141. CClientCommand _revive(     "revive",     "Bring back to life", @cheatCmd );
  142. CClientCommand _strip(      "strip",      "Remove all weapons and ammo", @cheatCmd );
  143. CClientCommand _maxhealth(  "maxhealth",  "Adjust maximum health", @cheatCmd );
  144. CClientCommand _maxarmor(   "maxarmor",   "Adjust maximum armor", @cheatCmd );
  145. CClientCommand _maxcharge(  "maxcharge",  "Adjust maximum armor", @cheatCmd );
  146. CClientCommand _speed(      "speed",      "Adjust maximum movement speed", @cheatCmd );
  147. CClientCommand _damage(     "damage",     "Adjust damage for current weapon", @cheatCmd );
  148. CClientCommand _gravity(    "gravity",    "Set gravity percentage", @cheatCmd );
  149. CClientCommand _grav(       "grav",       "Set gravity percentage", @cheatCmd );
  150. CClientCommand _hc(         "hc",         "Heal & Charge", @cheatCmd );
  151.  
  152. void initCheatAliases() {
  153.     cheats[".god"] = cheats[".godmode"];
  154.     cheats[".nonsolid"] = cheats[".notouch"];
  155.     cheats[".healme"] = cheats[".heal"];
  156.     cheats[".chargeme"] = cheats[".charge"];
  157.     cheats[".recharge"] = cheats[".charge"];
  158.     cheats[".reviveme"] = cheats[".revive"];
  159.     cheats[".maxcharge"] = cheats[".maxarmor"];
  160.     cheats[".grav"] = cheats[".gravity"];
  161. }
  162.  
  163. // weapons that use the engine time to calculate the next attack time
  164. dictionary rambo_special_delay_weapons = {
  165.     {'weapon_crowbar', true},
  166.     {'weapon_pipewrench', true},
  167.     {'weapon_medkit', true},
  168.     {'weapon_snark', true},
  169.     {'weapon_tripmine', true},
  170.     {'weapon_grapple', true}
  171. };
  172.  
  173. array<string> impulse_101_weapons = {
  174.     "weapon_crowbar",
  175.     "weapon_9mmhandgun",
  176.     "weapon_357",
  177.     "weapon_9mmAR",
  178.     "weapon_crossbow",
  179.     "weapon_shotgun",
  180.     "weapon_rpg",
  181.     "weapon_gauss",
  182.     "weapon_egon",
  183.     "weapon_hornetgun",
  184.     "weapon_uziakimbo",
  185.     "weapon_medkit",
  186.     "weapon_pipewrench",
  187.     "weapon_grapple",
  188.     "weapon_sniperrifle",
  189.     "weapon_m249",
  190.     "weapon_m16",
  191.     "weapon_sporelauncher",
  192.     "weapon_eagle",
  193.     "weapon_displacer"
  194. };
  195.  
  196. array<string> impulse_101_ammo = {
  197.     "ammo_sporeclip", "ammo_sporeclip", "ammo_sporeclip", "ammo_sporeclip", "ammo_sporeclip",
  198.     "ammo_357",
  199.     "ammo_556",
  200.     "ammo_762",
  201.     "ammo_rpgclip",
  202.     "ammo_gaussclip",
  203.     "ammo_9mmAR", "ammo_9mmclip",
  204.     "ammo_buckshot", "ammo_buckshot",
  205.     "ammo_ARgrenades",
  206.     "ammo_crossbow", "ammo_crossbow"
  207. };
  208.  
  209. array<string> giveAllList = {
  210.     "weapon_crowbar",
  211.     "weapon_9mmhandgun",
  212.     "weapon_357",
  213.     "weapon_9mmAR",
  214.     "weapon_crossbow",
  215.     "weapon_shotgun",
  216.     "weapon_rpg",
  217.     "weapon_gauss",
  218.     "weapon_egon",
  219.     "weapon_hornetgun",
  220.     "weapon_handgrenade",
  221.     "weapon_tripmine",
  222.     "weapon_satchel",
  223.     "weapon_snark",
  224.     "weapon_uziakimbo",
  225.     "weapon_medkit",
  226.     "weapon_pipewrench",
  227.     "weapon_grapple",
  228.     "weapon_sniperrifle",
  229.     "weapon_m249",
  230.     "weapon_m16",
  231.     "weapon_sporelauncher",
  232.     "weapon_eagle",
  233.     "weapon_displacer"
  234. };
  235.  
  236. bool cheats_for_all = false;
  237.  
  238. // for cheats that are applied every frame
  239. class ConstantCheat
  240. {
  241.     EHandle player;
  242.     int gravity;
  243.     bool noclip;
  244.     bool godmode;
  245.     bool rambo;
  246.    
  247.     ConstantCheat() {}
  248.    
  249.     ConstantCheat(EHandle player)
  250.     {
  251.         this.player = player;
  252.         gravity = 100;
  253.         noclip = false;
  254.         godmode = false;
  255.         rambo = false;
  256.     }
  257.    
  258.     bool isValid()
  259.     {
  260.         if (player)
  261.         {
  262.             CBaseEntity@ ent = player;
  263.             return ent.IsAlive() and (gravity != 100 or noclip or godmode or rambo);
  264.         }
  265.         return false;
  266.     }
  267. }
  268.  
  269. dictionary player_states; // values are 0 or 1 (cheats enabled for non-admin)
  270. array<ConstantCheat> constant_cheats;
  271.  
  272. bool isAdmin(CBasePlayer@ plr)
  273. {
  274.     return g_PlayerFuncs.AdminLevel(plr) >= ADMIN_YES;
  275. }
  276.  
  277. bool isOwner(CBasePlayer@ plr)
  278. {
  279.     return g_PlayerFuncs.AdminLevel(plr) >= ADMIN_OWNER;
  280. }
  281.  
  282. bool canCheat(CBasePlayer@ plr, bool adminOnlyCommand, bool ownerOnlyCommand)
  283. {
  284.     if (isAdmin(plr))
  285.         return !ownerOnlyCommand;
  286.        
  287.     string id = getPlayerUniqueId(plr);
  288.     bool peasantWithPrivledges = player_states.exists(id) and int(player_states[id]) != 0;
  289.    
  290.     if (cheats_for_all or peasantWithPrivledges)
  291.         return !(adminOnlyCommand or ownerOnlyCommand);
  292.        
  293.     return false;
  294. }
  295.  
  296. string getPlayerUniqueId(CBasePlayer@ plr)
  297. {
  298.     string steamId = g_EngineFuncs.GetPlayerAuthId( plr.edict() );
  299.     if (steamId == 'STEAM_ID_LAN') {
  300.         steamId = plr.pev.netname;
  301.     }
  302.     return steamId;
  303. }
  304.  
  305. // get player by name, partial name, or steamId
  306. CBasePlayer@ getPlayer(CBasePlayer@ caller, string name)
  307. {
  308.     name = name.ToLowercase();
  309.     int partialMatches = 0;
  310.     CBasePlayer@ partialMatch;
  311.     CBaseEntity@ ent = null;
  312.     do {
  313.         @ent = g_EntityFuncs.FindEntityByClassname(ent, "player");
  314.         if (ent !is null) {
  315.             CBasePlayer@ plr = cast<CBasePlayer@>(ent);
  316.             string plrName = string(plr.pev.netname).ToLowercase();
  317.             string plrId = getPlayerUniqueId(plr).ToLowercase();
  318.             if (plrName == name)
  319.                 return plr;
  320.             else if (plrId == name)
  321.                 return plr;
  322.             else if (plrName.Find(name) != uint(-1))
  323.             {
  324.                 @partialMatch = plr;
  325.                 partialMatches++;
  326.             }
  327.         }
  328.     } while (ent !is null);
  329.    
  330.     if (partialMatches == 1) {
  331.         return partialMatch;
  332.     } else if (partialMatches > 1) {
  333.         g_PlayerFuncs.SayText(caller, 'Cheat failed. There are ' + partialMatches + ' players that have "' + name + '" in their name. Be more specific.');
  334.     } else {
  335.         g_PlayerFuncs.SayText(caller, 'Cheat failed. There is no player named "' + name + '"');
  336.     }
  337.    
  338.     return null;
  339. }
  340.  
  341. // disabling cheats should also remove active ones from peasants (they can't turn them off themselves)
  342. void removepeasantCheats(CBasePlayer@ plr)
  343. {
  344.     if (!isAdmin(plr))
  345.     {
  346.         array<string> gargs = { "0" };
  347.         toggleGodmode(plr, gargs);
  348.         toggleNotarget(plr, gargs);
  349.         toggleNotouch(plr, gargs);
  350.         toggleNoclip(plr, gargs);
  351.         toggleRambo(plr, gargs);
  352.     }
  353. }
  354.  
  355. // Apply a generic cheat after validating the arguments
  356. // Also print out what happened in chat
  357. void applyCheat(Cheat@ cheat, CBasePlayer@ cheater, const CCommand@ args)
  358. {
  359.     array<string> cheatArgs;
  360.     // Cheat has enough args?
  361.     if (args.ArgC()-1 < cheat.numArgs) {
  362.         g_PlayerFuncs.SayText(cheater, "Not enough arguments supplied for cheat");
  363.         return;
  364.     }
  365.    
  366.     // player is allowed to use this cheat?
  367.     if (!canCheat(cheater, cheat.adminOnly, cheat.ownerOnly)) {
  368.         g_PlayerFuncs.SayText(cheater, "You don't have access to that command, peasant.\n");
  369.         return;
  370.     }
  371.    
  372.     // player wants to set toggle cheat on/off as opposed to just toggling it?
  373.     int playerArg = cheat.numArgs+1;
  374.     int toggleState = TOGGLE_TOGGLE;
  375.     if (cheat.type == CHEAT_TOGGLE and args.ArgC() > 1)
  376.     {
  377.         if (args[1] == '0' or args[1] == '1') {
  378.             toggleState = atoi(args[1]);
  379.             cheatArgs.insertLast(args[1]); // optional arg
  380.             playerArg++;
  381.         }
  382.     }
  383.    
  384.     // player is targetting someone else?
  385.     CBasePlayer@ target = cheater;
  386.     bool allPlayers = false;
  387.     if (args.ArgC() > playerArg) {
  388.         if (isAdmin(cheater))
  389.         {
  390.             if (args[playerArg][0] == '\\all' or args[playerArg] == '\\') {
  391.                 allPlayers = true;
  392.             }
  393.             else
  394.             {
  395.                 @target = getPlayer(cheater, args[playerArg]);
  396.                 if (target is null)
  397.                     return;
  398.             }
  399.         }
  400.         else
  401.         {
  402.             g_PlayerFuncs.SayTextAll(cheater, "Sorry, only admins can set cheats on other players\n");
  403.             return;
  404.         }
  405.     }
  406.    
  407.     if (allPlayers and toggleState == TOGGLE_TOGGLE and cheat.type == CHEAT_TOGGLE and args[0] != '.cheats')
  408.     {
  409.         if (cheat.lastState == TOGGLE_OFF)
  410.             toggleState = TOGGLE_ON;
  411.         else
  412.             toggleState = TOGGLE_OFF;
  413.         cheat.lastState = toggleState;
  414.         cheatArgs.insertLast(toggleState);
  415.     }
  416.    
  417.     for (int i = 1; i < cheat.numArgs+1; i++) {
  418.         cheatArgs.insertLast(args[i]);
  419.     }
  420.    
  421.     if (args[0] == ".cheats" and cheater == target and !allPlayers)
  422.     {
  423.         if (toggleState != TOGGLE_TOGGLE)
  424.         {
  425.             allPlayers = true;
  426.         }
  427.         else
  428.         {
  429.             if (cheats_for_all)
  430.                 g_PlayerFuncs.SayText(target, "cheats are currently enabled for everyone\n");
  431.             else
  432.                 g_PlayerFuncs.SayText(target, "cheats are currently disabled for all users except admins\n");
  433.             return;
  434.         }
  435.     }
  436.    
  437.     if (allPlayers) // apply cheat to all players
  438.     {
  439.         CBaseEntity@ ent = null;
  440.         do {
  441.             @ent = g_EntityFuncs.FindEntityByClassname(ent, "player");
  442.             if (ent !is null) {
  443.                 CBasePlayer@ plr = cast<CBasePlayer@>(ent);
  444.                 cheat.cheatFunc(plr, cheatArgs);
  445.                
  446.                 if (args[0] == ".cheats" and (toggleState == TOGGLE_OFF or cheats_for_all))
  447.                     removepeasantCheats(plr);
  448.             }
  449.         } while (ent !is null);
  450.        
  451.         if (args[0] == ".cheats")
  452.         {
  453.             if (toggleState == TOGGLE_OFF)
  454.                 cheats_for_all = false;
  455.             else if (toggleState == TOGGLE_ON)
  456.                 cheats_for_all = true;
  457.             else
  458.                 cheats_for_all = !cheats_for_all;
  459.            
  460.             if (cheats_for_all)
  461.                 g_PlayerFuncs.SayTextAll(cheater, "" + cheater.pev.netname + " enabled cheats for everyone (type .cheatlist in console for help)\n");
  462.             else
  463.                 g_PlayerFuncs.SayTextAll(cheater, "" + cheater.pev.netname + " disabled cheats for everyone\n");
  464.         }
  465.         else if (cheat.type == CHEAT_TOGGLE)
  466.         {
  467.             if (toggleState == TOGGLE_TOGGLE)
  468.                 g_PlayerFuncs.SayTextAll(cheater, "" + cheater.pev.netname + " toggled " + cheat.name + " on everyone\n");
  469.             else if (toggleState == TOGGLE_ON)
  470.                 g_PlayerFuncs.SayTextAll(cheater, "" + cheater.pev.netname + " gave everyone " + cheat.name + "\n");
  471.             else if (toggleState == TOGGLE_OFF)
  472.                 g_PlayerFuncs.SayTextAll(cheater, "" + cheater.pev.netname + " removed everyone's " + cheat.name + "\n");
  473.         }
  474.         else if (cheat.type == CHEAT_GIVE)
  475.         {
  476.             string giveName = cheat.name;
  477.             if (giveName.Find("%0") != uint(-1)) {
  478.                 giveName = giveName.Replace("%0", cheatArgs[0]);
  479.             }
  480.             g_PlayerFuncs.SayTextAll(cheater, "" + cheater.pev.netname + " gave everyone " + giveName + "\n");
  481.         }
  482.         else if (cheat.type == CHEAT_ACTION)
  483.         {
  484.             g_PlayerFuncs.SayTextAll(target, "" + cheater.pev.netname + " " + cheat.name + " everyone\n");
  485.         }
  486.     }
  487.     else // apply to specific player or self
  488.     {
  489.         //println("Apply " + args[0] + " from " + cheater.pev.netname + " to " + target.pev.netname);
  490.         int ret = cheat.cheatFunc(target, cheatArgs);
  491.        
  492.         if (cheater != target) {
  493.             // cheat applied to someone else
  494.            
  495.             if (cheat.type == CHEAT_TOGGLE)
  496.             {
  497.                 if (ret == TOGGLE_ON) {
  498.                     g_PlayerFuncs.SayText(cheater, cheat.name + " enabled on " + target.pev.netname + "\n");
  499.                    
  500.                     if (args[0] == '.cheats')
  501.                         g_PlayerFuncs.SayText(target, "" + cheater.pev.netname + " gave you " + cheat.name + " (type .cheatlist in console for help)\n");
  502.                     else
  503.                         g_PlayerFuncs.SayText(target, "" + cheater.pev.netname + " gave you " + cheat.name + "\n");
  504.                 }
  505.                 else if (ret == TOGGLE_OFF) {
  506.                     g_PlayerFuncs.SayText(cheater, cheat.name + " disabled on " + target.pev.netname + "\n");
  507.                     g_PlayerFuncs.SayText(target, "" + cheater.pev.netname + " removed your " + cheat.name + "\n");
  508.                 }
  509.                 else if (ret == FAIL_TARGET_ADMIN) {
  510.                     g_PlayerFuncs.SayText(cheater, "Cheat failed. " + target.pev.netname + " is an admin.\n");
  511.                 }
  512.                 if (args[0] == ".cheats" and ret == TOGGLE_OFF)
  513.                     removepeasantCheats(target);
  514.             }
  515.             else if (cheat.type == CHEAT_GIVE)
  516.             {
  517.                 string giveName = cheat.name;
  518.                 if (giveName.Find("%0") != uint(-1)) {
  519.                     giveName = giveName.Replace("%0", cheatArgs[0]);
  520.                 }
  521.                 g_PlayerFuncs.SayText(cheater, "Gave " + giveName + " to " + target.pev.netname + "\n");
  522.                 g_PlayerFuncs.SayText(target, "" + cheater.pev.netname + " gave you " + giveName + "\n");
  523.             }
  524.             else if (cheat.type == CHEAT_ACTION)
  525.             {
  526.                 if (ret == FAIL_TARGET_DEAD)
  527.                     g_PlayerFuncs.SayText(cheater, "Cheat failed. " + target.pev.netname + " is dead.\n");
  528.                 else if (ret == FAIL_TARGET_ALIVE)
  529.                     g_PlayerFuncs.SayText(cheater, "Cheat failed. " + target.pev.netname + " is alive.\n");
  530.                 else {
  531.                     g_PlayerFuncs.SayText(cheater, cheat.name + " " + target.pev.netname + "\n");
  532.                     g_PlayerFuncs.SayText(target, "" + cheater.pev.netname + " " + cheat.name + " you\n");
  533.                 }
  534.             }
  535.         }
  536.         else
  537.         {
  538.             if (ret == FAIL_TARGET_ADMIN)
  539.                 g_PlayerFuncs.SayText(cheater, "You can't use " + args[0] + " on yourself\n");
  540.         }
  541.     }
  542. }
  543.  
  544. int toggleNoclip(CBasePlayer@ target, array<string>@ args)
  545. {  
  546.     int toggleState = (args.length() > 0) ? atoi(args[0]) : TOGGLE_TOGGLE;
  547.     int ret;
  548.    
  549.     if (target.pev.movetype == MOVETYPE_NOCLIP and toggleState != TOGGLE_ON or toggleState == TOGGLE_OFF)
  550.     {
  551.         target.pev.movetype = MOVETYPE_WALK;
  552.         g_PlayerFuncs.PrintKeyBindingString(target, "No clip OFF");
  553.         ret = TOGGLE_OFF;
  554.     }
  555.     else
  556.     {
  557.         target.pev.movetype = MOVETYPE_NOCLIP;
  558.         g_PlayerFuncs.PrintKeyBindingString(target, "No clip ON");
  559.         ret = TOGGLE_ON;
  560.     }
  561.    
  562.     bool existingCheat = false;
  563.     for (uint i = 0; i < constant_cheats.length(); i++)
  564.     {
  565.         if (constant_cheats[i].isValid())
  566.         {
  567.             CBaseEntity@ ent = constant_cheats[i].player;
  568.             if (ent.entindex() == target.entindex())
  569.             {
  570.                 constant_cheats[i].noclip = ret == TOGGLE_ON;
  571.                 existingCheat = true;
  572.                 break;
  573.             }
  574.         }
  575.     }
  576.     if (!existingCheat and ret == TOGGLE_ON)
  577.     {
  578.         EHandle h_plr = target;
  579.         ConstantCheat cheat(h_plr);
  580.         cheat.noclip = true;
  581.         constant_cheats.insertLast(cheat);
  582.     }
  583.    
  584.     return ret;
  585. }
  586.  
  587. int toggleGodmode(CBasePlayer@ target, array<string>@ args)
  588. {  
  589.     int toggleState = (args.length() > 0) ? atoi(args[0]) : TOGGLE_TOGGLE;
  590.     int ret;
  591.     if (target.pev.flags & FL_GODMODE != 0 and toggleState != TOGGLE_ON or toggleState == TOGGLE_OFF)
  592.     {
  593.         target.pev.flags &= ~FL_GODMODE;
  594.         target.pev.takedamage = DAMAGE_YES;
  595.         g_PlayerFuncs.PrintKeyBindingString(target, "God mode OFF");
  596.         ret = TOGGLE_OFF;
  597.     }
  598.     else
  599.     {
  600.         target.pev.flags |= FL_GODMODE;
  601.         target.pev.takedamage = DAMAGE_NO;
  602.         g_PlayerFuncs.PrintKeyBindingString(target, "God mode ON");
  603.         ret = TOGGLE_ON;
  604.     }
  605.    
  606.     bool existingCheat = false;
  607.     for (uint i = 0; i < constant_cheats.length(); i++)
  608.     {
  609.         if (constant_cheats[i].isValid())
  610.         {
  611.             CBaseEntity@ ent = constant_cheats[i].player;
  612.             if (ent.entindex() == target.entindex())
  613.             {
  614.                 constant_cheats[i].godmode = ret == TOGGLE_ON;
  615.                 existingCheat = true;
  616.                 break;
  617.             }
  618.         }
  619.     }
  620.     if (!existingCheat and ret == TOGGLE_ON)
  621.     {
  622.         EHandle h_plr = target;
  623.         ConstantCheat cheat(h_plr);
  624.         cheat.godmode = true;
  625.         constant_cheats.insertLast(cheat);
  626.     }
  627.    
  628.     return ret;
  629. }
  630.  
  631. int toggleNotarget(CBasePlayer@ target, array<string>@ args)
  632. {
  633.     int toggleState = (args.length() > 0) ? atoi(args[0]) : TOGGLE_TOGGLE;
  634.     if (target.pev.flags & FL_NOTARGET != 0 and toggleState != TOGGLE_ON or toggleState == TOGGLE_OFF)
  635.     {
  636.         target.pev.flags &= ~FL_NOTARGET;
  637.         g_PlayerFuncs.PrintKeyBindingString(target, "No target OFF");
  638.         return TOGGLE_OFF;
  639.     }
  640.     else
  641.     {
  642.         target.pev.flags |= FL_NOTARGET;
  643.         g_PlayerFuncs.PrintKeyBindingString(target, "No target ON");
  644.         return TOGGLE_ON;
  645.     }
  646. }
  647.  
  648. int toggleCloak(CBasePlayer@ target, array<string>@ args)
  649. {
  650.     int toggleState = (args.length() > 0) ? atoi(args[0]) : TOGGLE_TOGGLE;
  651.     bool currentlyEnabled = target.pev.flags & FL_NOTARGET != 0 and target.pev.rendermode == kRenderTransTexture and target.pev.renderamt == 0;
  652.    
  653.     if (currentlyEnabled and toggleState != TOGGLE_ON or toggleState == TOGGLE_OFF)
  654.     {
  655.         target.pev.flags &= ~FL_NOTARGET;
  656.         target.pev.rendermode = kRenderNormal;
  657.         g_PlayerFuncs.PrintKeyBindingString(target, "Cloak OFF");
  658.         return TOGGLE_OFF;
  659.     }
  660.     else
  661.     {
  662.         target.pev.flags |= FL_NOTARGET;
  663.         target.pev.rendermode = kRenderTransTexture;
  664.         target.pev.renderamt = 0;
  665.         g_PlayerFuncs.PrintKeyBindingString(target, "Cloak ON");
  666.         return TOGGLE_ON;
  667.     }
  668. }
  669.  
  670. int toggleNotouch(CBasePlayer@ target, array<string>@ args)
  671. {
  672.     int toggleState = (args.length() > 0) ? atoi(args[0]) : TOGGLE_TOGGLE;
  673.     if (target.pev.solid == SOLID_NOT and toggleState != TOGGLE_ON or toggleState == TOGGLE_OFF)
  674.     {
  675.         target.pev.solid = SOLID_SLIDEBOX;
  676.         g_PlayerFuncs.PrintKeyBindingString(target, "Non-solid OFF");
  677.         return TOGGLE_OFF;
  678.     }
  679.     else
  680.     {
  681.         target.pev.solid = SOLID_NOT;
  682.         g_PlayerFuncs.PrintKeyBindingString(target, "Non-solid ON");
  683.         return TOGGLE_ON;
  684.     }
  685. }
  686.  
  687. int toggleRambo(CBasePlayer@ target, array<string>@ args)
  688. {  
  689.     int toggleState = (args.length() > 0) ? atoi(args[0]) : TOGGLE_TOGGLE;
  690.     int ret = TOGGLE_OFF;
  691.    
  692.     bool existingCheat = false;
  693.     for (uint i = 0; i < constant_cheats.length(); i++)
  694.     {
  695.         if (constant_cheats[i].isValid())
  696.         {
  697.             CBaseEntity@ ent = constant_cheats[i].player;
  698.             if (ent.entindex() == target.entindex())
  699.             {
  700.                 if (toggleState == TOGGLE_ON) {
  701.                     constant_cheats[i].rambo = true;
  702.                     ret = TOGGLE_ON;
  703.                 }
  704.                 if (toggleState == TOGGLE_OFF) {
  705.                     constant_cheats[i].rambo = true;
  706.                     ret = TOGGLE_OFF;
  707.                 }
  708.                 if (toggleState == TOGGLE_TOGGLE) {
  709.                     constant_cheats[i].rambo = !constant_cheats[i].rambo;
  710.                     ret = constant_cheats[i].rambo ? TOGGLE_ON : TOGGLE_OFF;
  711.                 }
  712.                 existingCheat = true;
  713.                 break;
  714.             }
  715.         }
  716.     }
  717.     if (!existingCheat and toggleState != TOGGLE_OFF)
  718.     {
  719.         EHandle h_plr = target;
  720.         ConstantCheat cheat(h_plr);
  721.         cheat.rambo = true;
  722.         constant_cheats.insertLast(cheat);
  723.         ret = TOGGLE_ON;
  724.     }
  725.    
  726.     if (ret == TOGGLE_ON)
  727.         g_PlayerFuncs.PrintKeyBindingString(target, "Rambo ON");
  728.     if (ret == TOGGLE_OFF)
  729.         g_PlayerFuncs.PrintKeyBindingString(target, "Rambo OFF");
  730.    
  731.     return ret;
  732. }
  733.  
  734. int toggleCheats(CBasePlayer@ target, array<string>@ args)
  735. {
  736.     int toggleState = (args.length() > 0) ? atoi(args[0]) : TOGGLE_TOGGLE;
  737.    
  738.     if (g_PlayerFuncs.AdminLevel(target) >= ADMIN_YES) {
  739.         return FAIL_TARGET_ADMIN; // admins can't control whether other admins can use cheats or not.
  740.     }
  741.    
  742.     string id = getPlayerUniqueId(target);
  743.     if (!player_states.exists(id))
  744.         player_states[id] = 0;
  745.    
  746.     if (int(player_states[id]) > 0 and toggleState != TOGGLE_ON or toggleState == TOGGLE_OFF)
  747.     {
  748.         player_states[id] = 0;
  749.         return TOGGLE_OFF;
  750.     }
  751.     else
  752.     {
  753.         player_states[id] = 1;
  754.         return TOGGLE_ON;
  755.     }
  756. }
  757.  
  758. // give ammo to player X times only if the ammo cap isn't reached
  759. void giveAmmoCapped(CBasePlayer@ plr, int ammoIdx, string item, int count)
  760. {
  761.     for (int i = 0; i < count; i++) {
  762.         if (plr.m_rgAmmo(ammoIdx) < plr.GetMaxAmmo(ammoIdx)) {
  763.             array<string> args = {item};
  764.             giveItem(plr, args);
  765.         }
  766.     }
  767. }
  768.  
  769. int useImpulse(CBasePlayer@ target, array<string>@ args)
  770. {
  771.     int impulse = atoi(args[0]);
  772.     if (impulse == 50) // toggle suit
  773.     {
  774.         target.SetHasSuit(!target.HasSuit());
  775.     }
  776.     else if (impulse == 101) // all weapons and ammo
  777.     {
  778.         target.SetItemPickupTimes(0);
  779.         for (uint i = 0; i < impulse_101_weapons.length(); i++) {
  780.             string checkName = impulse_101_weapons[i];
  781.             if (checkName == "weapon_uziakimbo")
  782.                 checkName = "weapon_uzi";
  783.             if (target.HasNamedPlayerItem(checkName) is null) {
  784.                 array<string> gargs = {impulse_101_weapons[i]};
  785.                 giveItem(target, gargs);
  786.             }
  787.         }
  788.        
  789.         // Replicate impulse 101 exactly (even though it's ineffecient)
  790.         giveAmmoCapped(target, g_PlayerFuncs.GetAmmoIndex("buckshot"), "ammo_buckshot", 1);
  791.         giveAmmoCapped(target, g_PlayerFuncs.GetAmmoIndex("556"), "ammo_556", 1);
  792.         giveAmmoCapped(target, g_PlayerFuncs.GetAmmoIndex("m40a1"), "ammo_762", 1);
  793.         giveAmmoCapped(target, g_PlayerFuncs.GetAmmoIndex("argrenades"), "ammo_ARgrenades", 1);
  794.         giveAmmoCapped(target, g_PlayerFuncs.GetAmmoIndex("357"), "ammo_357", 1);
  795.         giveAmmoCapped(target, g_PlayerFuncs.GetAmmoIndex("9mm"), "ammo_9mmAR", 1);
  796.         giveAmmoCapped(target, g_PlayerFuncs.GetAmmoIndex("9mm"), "ammo_9mmclip", 1);
  797.         giveAmmoCapped(target, g_PlayerFuncs.GetAmmoIndex("sporeclip"), "ammo_sporeclip", 5);
  798.         giveAmmoCapped(target, g_PlayerFuncs.GetAmmoIndex("uranium"), "ammo_gaussclip", 1);
  799.         giveAmmoCapped(target, g_PlayerFuncs.GetAmmoIndex("rockets"), "ammo_rpgclip", 1);
  800.         giveAmmoCapped(target, g_PlayerFuncs.GetAmmoIndex("bolts"), "ammo_crossbow", 1);
  801.         giveAmmoCapped(target, g_PlayerFuncs.GetAmmoIndex("trip mine"), "weapon_tripmine", 1);
  802.         giveAmmoCapped(target, g_PlayerFuncs.GetAmmoIndex("satchel charge"), "weapon_satchel", 1);
  803.         giveAmmoCapped(target, g_PlayerFuncs.GetAmmoIndex("hand grenade"), "weapon_handgrenade", 1);
  804.         giveAmmoCapped(target, g_PlayerFuncs.GetAmmoIndex("snarks"), "weapon_snark", 1);
  805.        
  806.         // give battery if not fully charged
  807.         if (target.pev.armorvalue < target.pev.armortype) {
  808.             array<string> gargs = {"item_battery"};
  809.             giveItem(target, gargs);
  810.         }
  811.     }
  812.     return 0;
  813. }
  814.  
  815. int giveItem(CBasePlayer@ target, array<string>@ args)
  816. {
  817.     bool validItem = false;
  818.     bool isAmmo = args[0].Find("ammo_") == 0;
  819.     if (args[0].Find("weapon_") == 0) validItem = true;
  820.     if (isAmmo) validItem = true;
  821.     if (args[0].Find("item_") == 0) validItem = true;
  822.    
  823.     if (validItem and @target.HasNamedPlayerItem(args[0]) == @null)
  824.     {
  825.         if (isAmmo) {
  826.             // for some reason GiveNamedItem gives the wrong ammo types
  827.             dictionary keys;
  828.             keys["origin"] = target.pev.origin.ToString();
  829.             CBaseEntity@ item = g_EntityFuncs.CreateEntity(args[0], keys, false);
  830.             item.pev.spawnflags |= SF_NORESPAWN;
  831.             g_EntityFuncs.DispatchSpawn(item.edict());
  832.             item.Touch(target);
  833.         } else {
  834.             target.GiveNamedItem(args[0], 0, 0);
  835.         }
  836.     }
  837.     return 0;
  838. }
  839.  
  840. int givePoints(CBasePlayer@ target, array<string>@ args)
  841. {
  842.     target.pev.frags += atoi(args[0]);
  843.     return 0;
  844. }
  845.  
  846. int setMaxHealth(CBasePlayer@ target, array<string>@ args)
  847. {
  848.     target.pev.max_health = atoi(args[0]);
  849.     g_PlayerFuncs.PrintKeyBindingString(target, "Max health " + target.pev.max_health);
  850.     return 0;
  851. }
  852.  
  853. int setMaxCharge(CBasePlayer@ target, array<string>@ args)
  854. {
  855.     target.pev.armortype = atoi(args[0]);
  856.     g_PlayerFuncs.PrintKeyBindingString(target, "Max armor " + target.pev.armortype);
  857.     return 0;
  858. }
  859.  
  860. int setMaxSpeed(CBasePlayer@ target, array<string>@ args)
  861. {
  862.     float speed = atof(args[0]);
  863.     float max = g_EngineFuncs.CVarGetFloat("sv_maxspeed");
  864.     if (speed <= 0)
  865.         speed = 0.0001; // 0 just resets to default
  866.     if (speed > max)
  867.         speed = max;
  868.        
  869.     target.pev.maxspeed = speed;
  870.    
  871.     g_PlayerFuncs.PrintKeyBindingString(target, "Speed " + int(speed));
  872.     return 0;
  873. }
  874.  
  875. int setWepDamage(CBasePlayer@ target, array<string>@ args)
  876. {
  877.     CBasePlayerWeapon@ activeItem = cast<CBasePlayerWeapon@>(target.m_hActiveItem.GetEntity());
  878.     float damage = atof(args[0]);
  879.     if (activeItem !is null) {
  880.         activeItem.m_flCustomDmg = damage;
  881.     }
  882.     g_PlayerFuncs.PrintKeyBindingString(target, "Damage " + int(damage));
  883.     return 0;
  884. }
  885.  
  886. int setGravity(CBasePlayer@ target, array<string>@ args)
  887. {
  888.     int arg = atoi(args[0]);
  889.     float gravity = arg/100.0f;
  890.     target.pev.gravity = gravity;
  891.    
  892.     bool existingCheat = false;
  893.     for (uint i = 0; i < constant_cheats.length(); i++)
  894.     {
  895.         if (constant_cheats[i].isValid())
  896.         {
  897.             CBaseEntity@ ent = constant_cheats[i].player;
  898.             if (ent.entindex() == target.entindex())
  899.             {
  900.                 constant_cheats[i].gravity = arg;
  901.                 existingCheat = true;
  902.                 break;
  903.             }
  904.         }
  905.     }
  906.     if (!existingCheat)
  907.     {
  908.         EHandle h_plr = target;
  909.         ConstantCheat cheat(h_plr);
  910.         cheat.gravity = arg;
  911.         constant_cheats.insertLast(cheat);
  912.     }
  913.     g_PlayerFuncs.PrintKeyBindingString(target, "Gravity " + arg + "%");
  914.     return 0;
  915. }
  916.  
  917. int heal(CBasePlayer@ target, array<string>@ args)
  918. {
  919.     if (target.pev.deadflag != 0) {
  920.         g_PlayerFuncs.PrintKeyBindingString(target, "Heal N/A: You're dead");
  921.         return FAIL_TARGET_DEAD;
  922.     } else {
  923.         target.pev.health = target.pev.max_health;
  924.         return 0;
  925.     }
  926. }
  927.  
  928. int charge(CBasePlayer@ target, array<string>@ args)
  929. {
  930.     if (target.pev.deadflag != 0) {
  931.         g_PlayerFuncs.PrintKeyBindingString(target, "HEV charge N/A: You're dead");
  932.         return FAIL_TARGET_DEAD;
  933.     } else {
  934.         target.pev.armorvalue = target.pev.armortype;
  935.         return 0;
  936.     }
  937. }
  938.  
  939. int hc(CBasePlayer@ target, array<string>@ args)
  940. {
  941.     if (target.pev.deadflag != 0) {
  942.         g_PlayerFuncs.PrintKeyBindingString(target, "Heal & HEV charge N/A: You're dead");
  943.         return FAIL_TARGET_DEAD;
  944.     } else {
  945.         target.pev.health = target.pev.max_health;
  946.         target.pev.armorvalue = target.pev.armortype;
  947.         return 0;
  948.     }
  949. }
  950.  
  951. int revive(CBasePlayer@ target, array<string>@ args)
  952. {
  953.     if (target.pev.deadflag == 0) {
  954.         g_PlayerFuncs.PrintKeyBindingString(target, "Self revive N/A: Already alive");
  955.         return FAIL_TARGET_ALIVE;
  956.     } else {
  957.         target.EndRevive(0);
  958.         return 0;
  959.     }
  960. }
  961.  
  962. int strip(CBasePlayer@ target, array<string>@ args)
  963. {
  964.     target.RemoveAllItems(false);
  965.     target.SetItemPickupTimes(0);
  966.     return 0;
  967. }
  968.  
  969. int giveAll(CBasePlayer@ target, array<string>@ args)
  970. {
  971.     // remember current weapon
  972.     string activeItem;
  973.     if (target.m_hActiveItem.GetEntity() !is null)
  974.         activeItem = target.m_hActiveItem.GetEntity().pev.classname;
  975.  
  976.     target.SetItemPickupTimes(0); // maybe not needed?
  977.    
  978.     // no delays needed for weapons. Does not cause a crash like with ammo entities
  979.     for (uint i = 0; i < giveAllList.length(); i++) {
  980.         array<string> gargs = {giveAllList[i]};
  981.         giveItem(target, gargs);
  982.     }
  983.    
  984.     // "infinite" ammo for all weapons
  985.     for (int i = 0; i < 64; i++)
  986.         target.m_rgAmmo(i, 1000000);
  987.        
  988.     if (activeItem.Length() > 0)
  989.         target.SelectItem(activeItem);
  990.     return 0;
  991. }
  992.  
  993. // entering a trigger_gravity or friction disables noclip for some reason
  994. // so I guess we just have to keep setting the noclip flag every single frame
  995. void constantCheats()
  996. {
  997.     for (uint i = 0; i < constant_cheats.length(); i++)
  998.     {
  999.         if (constant_cheats[i].isValid())
  1000.         {
  1001.             CBasePlayer@ plr = cast<CBasePlayer@>(constant_cheats[i].player.GetEntity());
  1002.             if (plr is null)
  1003.                 continue;
  1004.             if (constant_cheats[i].noclip)
  1005.                 plr.pev.movetype = MOVETYPE_NOCLIP;
  1006.             if (constant_cheats[i].godmode)
  1007.             {
  1008.                 plr.pev.flags |= FL_GODMODE;
  1009.                 plr.pev.takedamage = DAMAGE_NO;
  1010.             }
  1011.             if (constant_cheats[i].gravity != 100)
  1012.             {
  1013.                 plr.pev.gravity = constant_cheats[i].gravity / 100.0f;
  1014.                 if (plr.pev.gravity == 0)
  1015.                     plr.pev.gravity = -0.00000000000000000000000000001;
  1016.             }
  1017.             if (constant_cheats[i].rambo)
  1018.             {
  1019.                 CBasePlayerWeapon@ activeItem = cast<CBasePlayerWeapon@>(plr.m_hActiveItem.GetEntity());
  1020.                 if (activeItem !is null) {
  1021.                     float ramboDelay = 0.05f;
  1022.                     if (rambo_special_delay_weapons.exists(activeItem.pev.classname)) {
  1023.                         ramboDelay += g_Engine.time;
  1024.                     }
  1025.                     if (activeItem.m_flNextPrimaryAttack > ramboDelay) {
  1026.                         activeItem.m_flNextPrimaryAttack = ramboDelay;
  1027.                     }
  1028.                     if (activeItem.m_flNextSecondaryAttack > ramboDelay) {
  1029.                         activeItem.m_flNextSecondaryAttack = ramboDelay;
  1030.                     }
  1031.                     if (activeItem.m_flNextTertiaryAttack > ramboDelay) {
  1032.                         activeItem.m_flNextTertiaryAttack = ramboDelay;
  1033.                     }
  1034.                     if (plr.m_flNextAttack > ramboDelay) {
  1035.                         plr.m_flNextAttack = ramboDelay;
  1036.                     }
  1037.                    
  1038.                     activeItem.m_iClip = 9999;
  1039.                     activeItem.m_iClip2 = 9999;
  1040.                     plr.pev.punchangle = Vector(0,0,0);
  1041.                 }
  1042.             }
  1043.             continue;
  1044.         }
  1045.         constant_cheats.removeAt(i);
  1046.         i--;
  1047.     }
  1048. }
  1049.  
  1050. bool doCheat(CBasePlayer@ plr, const CCommand@ args)
  1051. {
  1052.     if (cheats.exists(args[0]))
  1053.     {
  1054.         Cheat@ cheat = cast<Cheat@>( cheats[args[0]] );
  1055.         applyCheat(cheat, plr, args);
  1056.         return true;
  1057.     }
  1058.     else if (args[0] == '.cheatlist')
  1059.     {
  1060.         printlnPlr(plr, "--------------------- Available cheat commands --------------------");
  1061.         if (isAdmin(plr)) {
  1062.             printlnPlr(plr, ".cheats [0,1] [player] - Enable/disable cheats for everyone or a specfic player");
  1063.         }
  1064.         printlnPlr(plr, ".noclip - Fly through walls");
  1065.         printlnPlr(plr, ".god - Become invincible");
  1066.         printlnPlr(plr, ".notarget - Monsters ignore you");
  1067.         printlnPlr(plr, ".notouch - Entities pass through you and map triggers ignore you");
  1068.         printlnPlr(plr, ".rambo - Disables weapon cooldowns and reloading");
  1069.         printlnPlr(plr, ".impulse 101 - Gives all weapons, some ammo, and a battery");
  1070.         printlnPlr(plr, ".give - Gives a weapon, ammo, or item entity");
  1071.         printlnPlr(plr, ".givepoints - Add points to score");
  1072.         printlnPlr(plr, ".giveall - Give all weapons and INFINITE AMMO (even better than impulse 101)");
  1073.         printlnPlr(plr, ".heal - Fully restores health");
  1074.         printlnPlr(plr, ".charge - Fully charges HEV suit");
  1075.         printlnPlr(plr, ".hc - Fully charges HEV suit and Fully restores health");
  1076.         printlnPlr(plr, ".maxhealth - Change max health value");
  1077.         printlnPlr(plr, ".maxcharge - Change max armor value");
  1078.         printlnPlr(plr, ".revive - Come back to life");
  1079.         printlnPlr(plr, ".strip - Remove all weapons and ammo");
  1080.         printlnPlr(plr, ".cloak - Same as notarget but also makes your player model invisible");
  1081.         printlnPlr(plr, ".speed - Change movement speed (range is 0 to sv_maxspeed)");
  1082.         printlnPlr(plr, ".damage - Adjust damage for current weapon (most weapons don't respond to this properly)");
  1083.         printlnPlr(plr, ".gravity - Change gravity percentage (100 = 100%)");
  1084.         printlnPlr(plr, "\n---------------------------- Command Syntax ---------------------");
  1085.         printlnPlr(plr, "Format for cheats:");
  1086.        
  1087.         if (isAdmin(plr)) {
  1088.             printlnPlr(plr, "\n.god [0,1] [player]\n");
  1089.             printlnPlr(plr, "The 0/1 argument is optional, and only applies to toggled cheats (god, noclip, notarget, notouch, rambo)");
  1090.             printlnPlr(plr, "\nWhen specifying a player (optional), you can use part of their username, or their Steam ID.");
  1091.             printlnPlr(plr, 'To apply a cheat to all players in a server, use \\all (ex: ".god 1 \\all")');
  1092.         } else {
  1093.             printlnPlr(plr, "\n.god [0,1]\n");
  1094.             printlnPlr(plr, "The 0/1 argument is optional, and only applies to toggled cheats (god, noclip, notarget, notouch)");
  1095.             printlnPlr(plr, 'Example: to turn on godmode, type ".god 1"');
  1096.         }
  1097.         printlnPlr(plr, '\nAll commands can be used in chat as well as the console.');
  1098.         printlnPlr(plr, "\n------------------------------------------------------------------");
  1099.        
  1100.         return true;
  1101.     }
  1102.     return false;
  1103. }
  1104.  
  1105. HookReturnCode ClientSayCheat( SayParameters@ pParams )
  1106. {
  1107.     CBasePlayer@ plr = pParams.GetPlayer();
  1108.     const CCommand@ args = pParams.GetArguments();
  1109.     if (plr is null)
  1110.         return HOOK_CONTINUE;
  1111.    
  1112.     if ( args.ArgC() > 0 )
  1113.     {
  1114.         if (doCheat(plr, args))
  1115.         {
  1116.             pParams.ShouldHide = true;
  1117.             return HOOK_HANDLED;
  1118.         }
  1119.     }
  1120.     return HOOK_CONTINUE;
  1121. }
  1122.  
  1123. void cheatCmd( const CCommand@ args )
  1124. {
  1125.     CBasePlayer@ plr = g_ConCommandSystem.GetCurrentPlayer();
  1126.     doCheat(plr, args);
  1127. }
  1128.  
Add Comment
Please, Sign In to add comment