Error cmd Function

Started by Shovon^, Aug 28, 2016, 11:37 AM

Previous topic - Next topic

Shovon^

I want a error function ....like its a cmds error or invalid cmds so there is written ([ERROR]Invalid Command). . . .. . .. . .i know u guyz will tell "ITS ezy who can do it?"but i am not getting idea of how to do this? :P
Iam the best and i only believe in Allah

Conatact me here on IRC:  #shovon^ @LUnet

Xmair

An example:
function onPlayerCommand( iPlayer, szCmd, szArguments ) {

switch( szCmd.tolower( ) ) {

case "mycommand":

/* ... */

break;

case "mycommand2":

/* ... */

break;

default:

MessagePlayer( "Invalid command.", iPlayer );

break;

}

}

function onPlayerCommand( iPlayer, szCmd, szArguments ) {

if ( szCmd.tolower( ) == "mycommand" ) {

/* ... */

}

else if ( szCmd.tolower( ) == "mycommand" ) {

/* ... */

}

else MessagePlayer( "Invalid command.", iPlayer );

}

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

Shovon^

I will try it thnx but plz send more good and tested one plz :)
Iam the best and i only believe in Allah

Conatact me here on IRC:  #shovon^ @LUnet

Anik

Quote from: Shovon^ on Aug 28, 2016, 03:45 PMI will try it thnx but plz send more good and tested one plz :)
more good?? This is a perfect example and solution for your problem.

Shovon^

Iam the best and i only believe in Allah

Conatact me here on IRC:  #shovon^ @LUnet

Shovon^

Why there is two time the Function onplayercommand.....????
Should I add as it is ???
Iam the best and i only believe in Allah

Conatact me here on IRC:  #shovon^ @LUnet

KAKAN

lol, 2 times = won't work. Any 1 of 'em will work. Usually, teh one which appears after the first one will work.
oh no

Shovon^

XDD now not even a single cmds are working...i type any cmd its just written (Invalid Cmds).... :o
Iam the best and i only believe in Allah

Conatact me here on IRC:  #shovon^ @LUnet

Xmair

The code I posted was just an example. Copy pasting won't work.

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

Mötley

This is from another script help, You can see that every command is returned true. This was your issue, EVERY Command needs to be returned true...

function onPremisionCommand(player) {
  MessagePlayer( "Invalid command! Type /cmds", player);
}

function onPlayerCommand(player, cmd, text) {

  if (cmd == "kick") {
   
    if ( IsAdmin( player, cmd ) ) {
     
      onPremisionCommand(player);
     
      return true;
   
    }
   
    if (!text) {
       
       MessagePlayer("[Syntax] /" + cmd + " <Nick/ID> <Reason>", player );

       return true;
   
    }
   
    local plr = FindPlayer(text.tointeger()), reason = GetTok( text, " ", 2, NumTok( text, " " ) );
   
    if (!plr) {
       
       MessagePlayer("[Error] - Invalid Nick/ID Specified !!", player );
       
       return true;   
   
    }
         
    Kick( plr, player, reason );

    return true;
  }
 
  onPremisionCommand(player);
 
  return false;
}