Vice City: Multiplayer

VC:MP Discussion => General Discussion => Topic started by: ! on Apr 04, 2017, 01:16 PM

Title: [Question]Sending incorrect command message in different ways
Post by: ! on Apr 04, 2017, 01:16 PM
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;
}
Title: Re: [Question]Sending incorrect command message in different ways
Post by: KAKAN on Apr 04, 2017, 01:38 PM
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.
Title: Re: [Question]Sending incorrect command message in different ways
Post by: ! on Apr 04, 2017, 01:57 PM
Quote from: KAKAN on Apr 04, 2017, 01:38 PMAlso, you can make a command system. Check SLC's snippet on it :)
Link pls.
Title: Re: [Question]Sending incorrect command message in different ways
Post by: EK.IceFlake on Apr 04, 2017, 06:08 PM
It won't lag however many files there are, because they are all stored in Memory.
Title: Re: [Question]Sending incorrect command message in different ways
Post by: KAKAN on Apr 05, 2017, 05:02 AM
Quote from: zeus on Apr 04, 2017, 01:57 PM
Quote from: KAKAN on Apr 04, 2017, 01:38 PMAlso, you can make a command system. Check SLC's snippet on it :)
Link pls.
http://forum.vc-mp.org/?topic=424.0
there ya go.