Invalid command feature

Started by Humzasajjad, Sep 30, 2018, 03:59 PM

Previous topic - Next topic

Humzasajjad

If i write anycommand which is not exist in script there was written invalid command plz tell me any script....

MEGAMIND

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);
}

NicusorN5

I would recommend using a switch-case in this situation.

Humzasajjad

Quote from: Humzasajjad on Sep 30, 2018, 03:59 PMIf i write anycommand which is not exist in script there was written invalid command plz tell me any script....
i need this function.i really need plz give me.plz

Xhefri

You already got an answer from MEGAMIND.Add this in the end of onPlayerCommand
else MessagePlayer("Invalid Command",player);
}

Humzasajjad


Humzasajjad

allfine but if i type any cmd i.e /heal there was written
you successful healed
invalid command

why?

MEGAMIND


NicusorN5

Nah he propably forgot to put a break instruction into the cases.