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??? ??? ???
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;
}
}
bro it is possible i dided i asking its good to add or not
well, if its possible then it must be good.. but i'll also like to know how?
i am not sure it will works with all SCRIPTS i scripted my script from scratch with the help of
@Kusanagi @KAKANvery easy onPlayerCommand && onPlayerCommand2
oh i see.. my sick brain :D ..
but i even prefer to use separate...
Why go back to the horrible syntax of !command ....
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