[Question]Sending incorrect command message in different ways

Started by !, Apr 04, 2017, 01:16 PM

Previous topic - Next topic

!

How to do it with different methods.

Suppose this is the server-commands directory
Commands.nut
Admin-Commands.nut
Player-Commands.nut

Now lets suppose both files
Admin-Commands & Player-Commands contain more than 100 commands
means total 200 commands

This is how Commands.nut looks like
function onPlayerCommand( player, cmd, text )
{
admincommands(player,cmd,text);//For loading admin commands
eventcommands(player,cmd,text);//For loading player commands
}

Now suppose player in server has typed a command whish is not present in both Admin-Commands.nut & Player-Commands.nut

How i can send a message [Incorrect command] to player upon usage of incorrect command.

This is the method i am using but i think it will lag the player when the commands are splitted in 20+ files.
//On script load
function onServerStart()
{
AdminCMDS <- array( GetMaxPlayers(), true );
PlayerCMDS <- array( GetMaxPlayers(), true );
}

This is Commands.nut file
function onPlayerCommand( player, cmd, text )
{
admincommands(player,cmd,text);//For loading admin commands
playercommands(player,cmd,text);//For loading player commands

if ( AdminCMDS[player.ID] == false && PlayerCMDS[player.ID] == false )
{
AdminCMDS[player.ID] = true;
PlayerCMDS[player.ID] = true;
MessagePlayer( COLOR_RED+"Incorrect Command.", player );
}
else
{
AdminCMDS[player.ID] = true;
PlayerCMDS[player.ID] = true;
}
}

This is Admin-Commands.nut file
function admincommands( player, cmd, text )
{
if ( cmd == "kick" ) bla bla bla
//other commands
//And this at the end of admin commands
else AdminCMDS[player.ID] = false;
}

This is Player-Commands.nut file
function playercommands( player, cmd, text )
{
if ( cmd == "heal" ) bla bla bla
//other commands
//And this at the end of player commands
else PlayerCMDS[player.ID] = false;
}

Discord: zeus#5155

KAKAN

Can't you just return something lol? Also, you can make a command system. Check SLC's snippet on it :)
Also, I guess it won't lag unless you have like a 1000 commands. In that case, table is more efficient.
oh no

!


Discord: zeus#5155

EK.IceFlake

It won't lag however many files there are, because they are all stored in Memory.

KAKAN

oh no