Vice City: Multiplayer

Server Development => Scripting and Server Management => Snippet Showroom => Topic started by: soulshaker on Sep 07, 2015, 12:24 PM

Title: Avoiding "!" Prefix
Post by: soulshaker on Sep 07, 2015, 12:24 PM
As we know that we generally use "/" prefix now but some players still tries to use "!" prefix. So to avoid that, we can tell players that "!" prefix is removed from your server(if you really removed it) like this:-

(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi.imgur.com%2FNkVQm01.png&hash=050767ae541212d7adfe8471e5bd4d5548158979)

function onPlayerChat( player, text )
{
    local msg
    if ( text ) msg = text.tolower();
        {
        if ( text )
        { 
                if ( text.slice( 0, 1 ) == "!" )
                {
                        local i = NumTok( text, " " ), xp = null;
                       
                        if ( i == 1 ) MessagePlayer("[#EE3B3B]>> Error - [#FFFFFE]The server uses / prefix for commands. Try [#00EEEE]/"+ text.slice( 1 ) ,player);
                }
                }
        }             
        return 1;
}
 
function NumTok(string, separator)
{
    local tokenized = split(string, separator);
    return tokenized.len();
    local s = split(string, separator);
    return s.len();
}
Title: Re: Avoiding "!" Prefix
Post by: FinchDon on Sep 07, 2015, 02:22 PM
Yeah I have that system in my server but i don't know why

when i type !deposit then nothing happen when i type /deposit it show nick money

I am using Warchief's Deposit Command
Title: Re: Avoiding "!" Prefix
Post by: KAKAN on Sep 07, 2015, 05:31 PM
You didn't even understand what he mean
ONTOPIC: Nice work!
Title: Re: Avoiding "!" Prefix
Post by: soulshaker on Sep 07, 2015, 06:17 PM
Quote from: KAKAN on Sep 07, 2015, 05:31 PMYou didn't even understand what he mean
And I too didn't even understand what he mean!! :P
Title: Re: Avoiding "!" Prefix
Post by: KAKAN on Sep 07, 2015, 06:40 PM
Ahh, let me tell, Some servers have their prefix with '/' like /commands instead of !commands
So if anyone types !commands, the system will message us to use /commands, as we don't have '!' key on our prefix as we do in 0.3
Title: Re: Avoiding "!" Prefix
Post by: MacTavish on Sep 08, 2015, 05:31 AM
The "!" Perfix commands could be prepare easily just put your cmds in onPlayerCommand2
Title: Re: Avoiding "!" Prefix
Post by: Thijn on Sep 08, 2015, 05:55 AM
Quote from: Kusanagi on Sep 08, 2015, 05:31 AMThe "!" Perfix commands could be prepare easily just put your cmds in onPlayerCommand2
And then what? There's no event that will call that. So unless you make something on your onPlayerChat function, this aint gonna do much.
Title: Re: Avoiding "!" Prefix
Post by: MacTavish on Sep 08, 2015, 05:58 AM
Quote from: Thijn on Sep 08, 2015, 05:55 AM
Quote from: Kusanagi on Sep 08, 2015, 05:31 AMThe "!" Perfix commands could be prepare easily just put your cmds in onPlayerCommand2
And then what? There's no event that will call that. So unless you make something on your onPlayerChat function, this aint gonna do much.

I know @Thijn but there are many newbies who are still using warcheifs so just putting cmds in command2 will work for them
Title: Re: Avoiding "!" Prefix
Post by: KAKAN on Sep 08, 2015, 06:00 AM
Can u give me the prefix slice?
Title: Re: Avoiding "!" Prefix
Post by: MacTavish on Sep 08, 2015, 06:02 AM
You can copy that thing from any 0.3 script., atm i am on phone
Title: Re: Avoiding "!" Prefix
Post by: KAKAN on Sep 08, 2015, 06:05 AM
:P Okay
Title: Re: Avoiding "!" Prefix
Post by: KAKAN on Sep 08, 2015, 06:05 AM
can u give me any link, I never search for sh!t in forums
Title: Re: Avoiding "!" Prefix
Post by: MacTavish on Sep 08, 2015, 06:12 AM
warchiefs 2.0 ( 0.3 script ) (http://vcmp.liberty-unleashed.co.uk/forum/index.php?topic=1597.0)
Title: Re: Avoiding "!" Prefix
Post by: KAKAN on Sep 08, 2015, 07:28 AM
Thanks, But i did it in my own way using this snippet
Title: Re: Avoiding "!" Prefix
Post by: Xmair on Sep 08, 2015, 09:35 AM
Stop spamming, why edit button is made than?
Title: Re: Avoiding "!" Prefix
Post by: KAKAN on Sep 08, 2015, 11:01 AM
I merged them, can;t u see?
Title: Re: Avoiding "!" Prefix
Post by: EK.IceFlake on Sep 08, 2015, 12:04 PM
function onPlayerCommand(player, command, text)
{
 if (command == "c") return onPlayerCCommand(player, split(text, ' ')[0], split(text, ' ').remove(0));
}
function onPlayerCCommand(player, command, textarray)
{
 if (command == "kill") player.Health = 0;
}
Note: the last parameter of onPlayerCCommand is an array not string
Also it isn't tested
Title: Re: Avoiding "!" Prefix
Post by: KAKAN on Sep 08, 2015, 12:50 PM
Ahh, yopu can do it through onPlayerChat XD