Invalid command feature

Humzasajjad

  • Newbie
  • Posts: 24
Invalid command feature
«  »
If i write anycommand which is not exist in script there was written invalid command plz tell me any script....

MEGAMIND

  • Hero Member
  • Developer of "Web-Net" search engine
  • Posts: 681
Re: Invalid command feature
« Reply #1,  »
Code: [Select]
function onPlayerCommand( player, cmd, text )
{
    if(cmd == "hello")
    {
        MessagePlayer("server says hello back",player);
       }

else if(cmd == newcmdhere){
//stuff goes here
}

else MessagePlayer("Invalid Command",player);
}

Athanatos

  • Hero Member
  • Just stopped playing VC:MP.
  • Posts: 761
Re: Invalid command feature
« Reply #2,  »
I would recommend using a switch-case in this situation.

Humzasajjad

  • Newbie
  • Posts: 24

Xhefri

  • Newbie
  • Posts: 34
Re: Invalid command feature
« Reply #4,  »
You already got an answer from MEGAMIND.Add this in the end of onPlayerCommand
Code: [Select]
else MessagePlayer("Invalid Command",player);
}

Humzasajjad

  • Newbie
  • Posts: 24
Re: Invalid command feature
« Reply #6,  »
allfine but if i type any cmd i.e /heal there was written
you successful healed
invalid command

why?

MEGAMIND

  • Hero Member
  • Developer of "Web-Net" search engine
  • Posts: 681

Athanatos

  • Hero Member
  • Just stopped playing VC:MP.
  • Posts: 761
Re: Invalid command feature
« Reply #8,  »
Nah he propably forgot to put a break instruction into the cases.