Author Topic: Write invalid commands  (Read 2706 times)

Motley

  • Full Member
  • ***
  • Posts: 253
  • Karma: +32/-34
    • View Profile
Write invalid commands
« on: October 13, 2017, 11:13:11 pm »
So I created this a long time ago for fun. You must make sure you return all of your commands true of course or return 1;, I'm assuming you know the setup of proper commands...

I wasn't going to release it, But when I noticed there are commands that even I wish I had, And they were getting written I knew I should release it lol.


The objective of this script is to help you help the LU community, Maybe you have spawncar cmds, but there typing only 'v', or maybe they want a 'heal' command as well 'armour'. I seriously didn't know how useful this was going to be. And I hope it helps you to ;)

I used hashes as I didn't think much of it when I wrote it... I haven't even touched it since until attempting to modify it for a release

My Hashing file has it's own directory, Make sure to modify it!

The hashing system

Code: [Select]
/*
Hashes are only used for simple stuff.
In this case writing invalid commands to better our system in time.
*/
const HASH_TABLE_LOCATION = "Hashing/Hashes/";

function onScriptLoad()
{
LoadHashes();

print("The hash tables have been loaded!");
}

function onScriptUnload()
{
SaveHashes();
}
function CreateHashes()
{
hsh_Cmds <- HashTable("CMD");
}

function SaveHashes()
{
// This is where we will be saving the hash files
hsh_Cmds.Save("Scripts/" + HASH_TABLE_LOCATION + "INVALID_COMMANDS.hsh" );
}

function LoadHashes()
{
// This is where we are going to be loading the hash files
// First we need to create them
CreateHashes();

// And then load them
hsh_Cmds.Load("Scripts/" + HASH_TABLE_LOCATION + "Hashing/Hashes/INVALID_COMMANDS.hsh" );
}

And Command usage, You should look into VBS on Commands if you need help with this.

Code: [Select]
/* System Commands */
function onPlayerCommand( pPlayer, szCommand, szParams )
{
if (DEATH_MATCH_COMMANDER( pPlayer, szCommand, szParams )) return true;

if (ADMIN_AUTHORITY_COMMANDER( pPlayer, szCommand, szParams )) return true;

MessagePlayer("The command /"+szCommand+" does not exist", pPlayer, 255, 0, 0);

Write_Invalid_Command( szCommand );

return 1;
}

function Write_Invalid_Command( szCommand )
{
local Invalid_Cmd = hsh_Cmds.Get( "[COMMAND] " + szCommand );

if ( !Invalid_Cmd ) hsh_Cmds.Add( "[COMMAND] " + szCommand, 1 );
else
{
hsh_Cmds.Inc( "[COMMAND] " + szCommand, 1 )
}

SaveHashes();
}

I'm assuming you know how to code with releasing this..

If you are stuck with it feel free to ask me for help!

 

© Liberty Unleashed Team.