Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: KAKAN on Sep 20, 2015, 06:22 PM

Title: cmd.slice
Post by: KAKAN on Sep 20, 2015, 06:22 PM
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?
Title: Re: cmd.slice
Post by: . on Sep 20, 2015, 06:52 PM
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?
Title: Re: cmd.slice
Post by: . on Sep 20, 2015, 08:12 PM
Please consult the following (http://forum.vc-mp.org/?topic=1529.0).
Title: Re: cmd.slice
Post by: Debian on Sep 21, 2015, 10:10 AM
anything  typed with ' / ' in the beginning is not recognized as chat . So you have to make it in on player command.
Title: Re: cmd.slice
Post by: Debian on Sep 21, 2015, 10:33 AM
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
Title: Re: cmd.slice
Post by: KAKAN on Sep 21, 2015, 02:01 PM
I already got it!, no need