Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: Diamond on Nov 04, 2015, 10:27 AM

Title: Command does not exist error
Post by: Diamond on Nov 04, 2015, 10:27 AM
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?

Title: Re: Command does not exist error
Post by: 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 );
}
Title: Re: Command does not exist error
Post by: Xmair on Nov 04, 2015, 11:08 AM
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!
Title: Re: Command does not exist error
Post by: Diamond on Nov 04, 2015, 11:14 AM
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
Title: Re: Command does not exist error
Post by: KAKAN on Nov 04, 2015, 11:19 AM
LOL!
Because he used arguments instead of the parameter text., or maybe something wrong in your script.
Title: Re: Command does not exist error
Post by: Diamond on Nov 04, 2015, 11:30 AM
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?
Title: Re: Command does not exist error
Post by: KAKAN on Nov 04, 2015, 11:57 AM
Yea, you did.
His example just works fine