cmd.slice

Started by KAKAN, Sep 20, 2015, 06:22 PM

Previous topic - Next topic

KAKAN

I wanted to use this:-
    else if( stats[ player.ID ].Logged )
    {
      if( cmd.slice(0,1) == "!" && cmd.len() > 1 )
      {
        RegUserCmds( player, cmd.slice(1), text );
      }

      else if( cmd.slice(0,1) == "/" && cmd.len() > 1)
      {
        RegUserCmds( player, cmd.slice(1), text );
      }
    }

But unfortunately it doesn't work, can anyone tell me the problem?
oh no

.

Obviously this goes into onPlayerChat() Have you tested this with a hardcoded string? have you printed cmd to confirm it has what you expect? have you printed the result of slice? ffs have you done any debugging?
.

.

.

Debian

anything  typed with ' / ' in the beginning is not recognized as chat . So you have to make it in on player command.

Debian

Update 1 : is it onplayerchat or onplayercommand , you had put cmd.slice so i guess it is onplayercommand , when a player types command it removes '/' from it . so player should type /!command or //command to make it work

KAKAN

I already got it!, no need
oh no