Vice City: Multiplayer

Server Development => Scripting and Server Management => Snippet Showroom => Topic started by: Retard on Feb 02, 2018, 03:58 PM

Title: Use cmds with "!"
Post by: Retard on Feb 02, 2018, 03:58 PM
I couldnt  find anything like this on the forum so i made this
With this following script you can use your cmds with "!" or anything you like.This bascially sends the information typed after ! to onplayercommand and then that takes care of it and it works like a normal cmd.
local backupText = text;
    local firstletteris = backupText.slice( 0, 1 ); //slice the text
    if (  firstletteris == "!" ) //you can change the ! to anything to make it work it with that
    {
        local splitthetext = text.slice( 1 ); //now split it
        local params = split( splitthetext, " " ); //split  it further
        if ( params.len() == 1 ) onPlayerCommand( player, params[ 0 ], "" );
        else
        {                                                       //send it to function OnPlayerCommand
            splitthetext = splitthetext.slice( splitthetext.find( " " ) + 1 );
            onPlayerCommand( player, params[ 0 ], splitthetext );
return 0;
        }       
    }
Title: Re: Use cmds with "!"
Post by: Mötley on Feb 02, 2018, 07:57 PM
Maybe the script should use a separate command other than onPlayerCommand, as some players are weird..

Lol: !login (password)

Just saying

I would just add an array of strings that are commands, if that string exist, don't output the command and notify the player


Sorry I'm on my phone at the moment
Title: Re: Use cmds with "!"
Post by: Retard on Feb 03, 2018, 02:09 AM
I got what you are trying to say but i made this for cmds except login and register + I actually made it according to my script which has gui registration system that means that i just have to type !login and gui opens and i have to enter the pass in that
Title: Re: Use cmds with "!"
Post by: EK.IceFlake on Feb 03, 2018, 07:04 AM
You can return 0; after calling onPlayerCommand in order to prevent the message from propagating to the chat.
Title: Re: Use cmds with "!"
Post by: Retard on Feb 03, 2018, 07:34 AM
Thanks for telling
Updated
Title: Re: Use cmds with "!"
Post by: Mötley on Feb 03, 2018, 01:19 PM
This still does not mean the players would still attempt to use !login (password)

Should add something like this to the code as not every scripter/player is bright

g_CommandNames <- [ "login", "register", "blah", "blahblah" ];

    foreach ( name in g_CommandNames )
    {
        if ( name == params[ 0 ] )
        {
            MessagePlayer( "This is a private command", player );
            return;
        }
    }

Also wouldn't return 0 make this no longer a public command script?
Title: Re: Use cmds with "!"
Post by: KrOoB_ on Jun 13, 2018, 04:49 AM
where do i put it bro ?
Title: Re: Use cmds with "!"
Post by: umar4911 on Jun 13, 2018, 07:26 AM
Quote from: h4fmaster on Jun 13, 2018, 04:49 AMwhere do i put it bro ?
in onPlayerChat
Title: Re: Use cmds with "!"
Post by: KrOoB_ on Jun 13, 2018, 02:55 PM
Quote from: umar4911 on Jun 13, 2018, 07:26 AM
Quote from: h4fmaster on Jun 13, 2018, 04:49 AMwhere do i put it bro ?
in onPlayerChat

thanks bro ,good job :)