Command does not exist error

Started by Diamond, Nov 04, 2015, 10:27 AM

Previous topic - Next topic

Diamond

When i do /login and in more cmds also this is like this

else if (!text) MessagePlayer( bla bla )

and my command dose not exits

else if (!text) bla bla..

BEcause there is else it comes and if there will be like if, it will not come...
So, in my script there are lot of cmds sin which else if (!text) is there


So, in this [ else if (!text) MessagePlayer("command does not exist, player) ] , is there any other thing that can be put instead of !text.

I tested !cmd but message does not appear if we type wrong cmd.
Any help?


Mashreq

!text or !arguments means it will not check if command is typed or not, it checks if a text after a command is given.

To setup an invalid command - error message you can use the following - which I am showing you for an example:

function onPlayerCommand( player, cmd, arguments )
{
if ( cmd == "test" )
{
MessagePlayer( "testing the command", player );
}
else if ( cmd == "hello" )
{
MessagePlayer( "hello " + player.Name, player );
}
else MessagePlayer( "Error - Invalid commad", player );
}

Xmair

You may be using something like this as I aspect from some players:
  if (status[ player.ID ].IsReg == true && status[ player.ID ].IsLogged == true )
{
  if ( cmd ........
}
else MessagePlayer( "You need to be signed in!",player);
Change it to:
else if (status[ player.ID ].IsReg == true && status[ player.ID ].IsLogged == true )
{
MessagePlayer( "You need to be signed in!",player);
}
else if ( cmd ......
Not tested but I tried the same to fix my script!

Credits to Boystang!

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

Diamond

#3
Quote from: Mashreq on Nov 04, 2015, 10:59 AM !text or !arguments means it will not check if command is typed or not, it checks if a text after a command is given.

To setup an invalid command - error message you can use the following - which I am showing you for an example:

function onPlayerCommand( player, cmd, arguments )
{
if ( cmd == "test" )
{
MessagePlayer( "testing the command", player );
}
else if ( cmd == "hello" )
{
MessagePlayer( "hello " + player.Name, player );
}
else MessagePlayer( "Error - Invalid commad", player );
}

Now even Message is not coming

KAKAN

LOL!
Because he used arguments instead of the parameter text., or maybe something wrong in your script.
oh no

Diamond

Quote from: KAKAN on Nov 04, 2015, 11:19 AMLOL!
Because he used arguments instead of the parameter text., or maybe something wrong in your script.

I tried Mashreq example?

KAKAN

Yea, you did.
His example just works fine
oh no