Author Topic: Commands  (Read 1465 times)

ARSEnic.

  • Newbie
  • *
  • Posts: 47
  • Karma: +17/-15
  • Hell o!
    • View Profile
Commands
« on: March 11, 2017, 04:36:14 am »
I found a more efficient way( or not depending on how you look at it ) of /cmds, it basically will check if you meet the criteria and if you do it'll show the command when you type /cmds


Code: [Select]

local CommandLines = 5; //This will show 5 commands per line


local Commands = ["a", "b", "c", "d", "e", "f", "g", "h"];//Define all server commands here

function onPlayerCommand( pPlayer, Command, Param )
{
Command = Command.tolower();
if( Command == "cmds" )
{
local MessageLine = "";
local MessageCount = 0;
foreach( String in Commands )
{
if( Your Criteria here )
{
if( MessageCount != 0 ) MessageLine += ", ";
MessageLine += "/" + String.tolower();
MessageCount++;
}
else if( 2nd Criteria )
{
if( More Criteria )
{
if( MessageCount != 0 ) MessageLine += ", ";
MessageLine += "/" + String.tolower();
MessageCount++;
}
}
else if( 3rd Criteria )
{
if( More Criteria )
{
if( MessageCount != 0 ) MessageLine += ", ";
MessageLine += "/" + String.tolower();
MessageCount++;
}
}
else if( Fourth Criteria )
{
if( More Criteria )
{
if( MessageCount != 0 ) MessageLine += ", ";
MessageLine += "/" + String.tolower();
MessageCount++;
}
}
else if( Fifth Criteria )
{
if( More Criteria )
{
if( Even More Criteria )
{
if( MessageCount != 0 ) MessageLine += ", ";
MessageLine += "/" + String.tolower();
MessageCount++;
}
}
}
if( MessageCount == CommandLines )
{
MessagePlayer(MessageLine, pPlayer);
MessageCount = 0;
MessageLine = "";
}

}
if( MessageLine != "" ) MessagePlayer( MessageLine, pPlayer);
}
}


The output will look something like this:
Code: [Select]
/a, /b, /d, /e, /g
/h

You can add more criteria if you want.

This probably isn't the most efficient method however i think its better than listing all the commands when a player types /cmds. If you have a better way of doing this, feel free to reply.

 

© Liberty Unleashed Team.