Vice City: Multiplayer

Off-Topic => Off-Topic General => Topic started by: Cool on Nov 08, 2015, 05:52 PM

Title: i need a sugesstion
Post by: Cool on Nov 08, 2015, 05:52 PM
hi guys if i add 2 prefix for every cmds  without adding commands 2 time add 2 prefix like /getcar !getcar both will works how is it??? ??? ???
Title: Re: i need a sugesstion
Post by: Decent_946 on Nov 08, 2015, 06:04 PM
well, i don't think its possible so...
u have to add both command functions for that and have to add commands also.

function onPlayerCommand( player, cmd, text )
&
function onPlayerCommand2( player, cmd, text )


eg:-
function onPlayerCommand( player, cmd, text )
{
 if ( cmd == "heal" )
 {
  if ( player.Health == 100 ) PrivMessage( player, "You have the health to maximum.");
  else
  {
   PrivMessage( player, "You healed successfully.");
   player.Health = 100;
 }
}

and
function onPlayerCommand2( player, cmd, text )
{
 if ( cmd == "heal" )
 {
  if ( player.Health == 100 ) PrivMessage( player, "You have the health to maximum.");
  else
  {
   PrivMessage( player, "You healed successfully.");
   player.Health = 100;
 }
}
Title: Re: i need a sugesstion
Post by: Cool on Nov 08, 2015, 06:07 PM
bro it is possible i dided i asking its good to  add or not
Title: Re: i need a sugesstion
Post by: Decent_946 on Nov 08, 2015, 06:11 PM
well, if its possible then it must be good.. but i'll also like to know how?
Title: Re: i need a sugesstion
Post by: Cool on Nov 08, 2015, 06:28 PM
i am not sure it will works with all SCRIPTS i scripted my script from scratch with the help of  @Kusanagi @KAKAN

very easy onPlayerCommand  && onPlayerCommand2
Title: Re: i need a sugesstion
Post by: Decent_946 on Nov 08, 2015, 06:35 PM
oh i see.. my sick brain :D ..

but i even prefer to use separate...
Title: Re: i need a sugesstion
Post by: Thijn on Nov 08, 2015, 09:46 PM
Why go back to the horrible syntax of !command ....
Title: Re: i need a sugesstion
Post by: KAKAN on Nov 09, 2015, 09:49 AM
Quote from: Thijn on Nov 08, 2015, 09:46 PMWhy go back to the horrible syntax of !command ....
\
Yea, that's pretty bad as it spams the whole chat.
Anyways, use this:-
function onPlayerChat( player, message ) {
  if ( message )
  {
    if ( message.slice( 0, 1 ) == "!" )
    {
      local i = NumTok( message, " " );
     
      if ( i == 1 ) onPlayerCommand( player, GetTok( message.slice( 1 ), " ", 1 ), null );
      else onPlayerCommand( player, GetTok( message.slice( 1 ), " ", 1 ), GetTok( message.slice( 1 ), " ", 2 8, i ) );
    }
  }
}
Make sure you have  GetTok and NumTok function.
Yet make the other things to.
Your next error( may happen )
The index 'message' doesn't exist