Jump to content

[REL] /do and /my command for RP


cyklopas

Recommended Posts

Well, whoever is familiar to Roleplay, must know what "/do" is used for. So yeah. It's my first normal script.

And whoever doesn't know what /my command does, I'll explain you...

For example your nickname is Doctor. You type /my balls are big.

And here comes the screen: *Doctor's balls are big.

Thanks for downloading and helping the project.

Version 1.0 DOWNLOAD: Here.

Version 2.0 DOWNLOAD: Here.

Changelog:

Version 2.0- Added the /my command.

Thanks to:

Me- the main idea.

ThaCoinz- Bug Fixing

Edited by Guest
Link to comment

We've always recommended _not_ using onConsole for this. addCommandHandler is both easier and more secure as you can easily secure console commands from being used through the ACL, plus write much less code.

This is a very silly way to do it.

Your code:

  
function input_Console ( text ) 
    local command = gettok (text, 1, 32 ) 
    if ( command == "my" ) then 
        local playerName = getPlayerName ( source ) 
        local actionText = string.sub ( text, 3 ) 
        outputChatBox ( " *" .. playerName .. "'s" .. actionText .. " ", root, 255, 40, 80, true ) 
    end 
end 
addEventHandler ( "onConsole", getRootElement(), input_Console ) 
  

How it should be done:

  
function myCommand( playerSource, commandName, ...) 
    local actionText = table.concat( arg, " " ) 
    local playerName = getPlayerName ( playerSource ) 
    outputChatBox ( " *" .. playerName .. "'s" .. actionText .. " ", root, 255, 40, 80, true ) 
end 
addCommandHandler("my", myCommand) 
  

Link to comment
We've always recommended _not_ using onConsole for this. addCommandHandler is both easier and more secure as you can easily secure console commands from being used through the ACL, plus write much less code.

This is a very silly way to do it.

Your code:

  
function input_Console ( text ) 
    local command = gettok (text, 1, 32 ) 
    if ( command == "my" ) then 
        local playerName = getPlayerName ( source ) 
        local actionText = string.sub ( text, 3 ) 
        outputChatBox ( " *" .. playerName .. "'s" .. actionText .. " ", root, 255, 40, 80, true ) 
    end 
end 
addEventHandler ( "onConsole", getRootElement(), input_Console ) 
  

How it should be done:

  
function myCommand( playerSource, commandName, ...) 
    local actionText = table.concat( arg, " " ) 
    local playerName = getPlayerName ( playerSource ) 
    outputChatBox ( " *" .. playerName .. "'s" .. actionText .. " ", root, 255, 40, 80, true ) 
end 
addCommandHandler("my", myCommand) 
  

Many thanks, mate ;)

Link to comment
  • 4 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...