Use cmds with "!"

Started by Retard, Feb 02, 2018, 03:58 PM

Previous topic - Next topic

Retard

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;
        }       
    }
Just another retard roaming around.

Mötley

#1
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

Retard

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
Just another retard roaming around.

EK.IceFlake

You can return 0; after calling onPlayerCommand in order to prevent the message from propagating to the chat.

Retard

Thanks for telling
Updated
Just another retard roaming around.

Mötley

#5
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?

KrOoB_

where do i put it bro ?

umar4911

I am gamer, programmer and hacker. Try to find me!
xD

KrOoB_