SRB2 Message Board  

Go Back   SRB2 Message Board > Sonic Robo Blast 2 > Editing > Editing Help

Reply
 
Thread Tools Search this Thread
Old 09-08-2017   #1
Yoshirocks90
Eh, maybe later.
 
Yoshirocks90's Avatar
Default COM_AddCommand Help

I don't have a file for it, but how, exactly, do i use COM_AddCommand? I've tried using the wiki (several times) but I still can't manage to do it right.
Yoshirocks90 is offline   Reply With Quote
Old 09-09-2017   #2
Monster psychic cat
 
Monster psychic cat's Avatar
Default

It just executes a defined function, also passing the command parameters to the function. From the wiki:

Quote:
The first argument is the player who executed the command, and all subsequent arguments are arguments passed to the command.
Example:
PHP Code:
// this works:
COM_AddCommand("setgender", function(playerg)
    if 
g=="Male" or g=="male" or g=="m" then
        player
.character.gender CHARGENDER_MALE
    
elseif g=="Female" or g=="female" or g=="f" then
        player
.character.gender CHARGENDER_FEMALE
    
else        // let the code choose
        
player.character.gender CHARGENDER_UNKNOWN
    end
end
)
// example :
// COM_BufInsertText(player, "setgender Male")

// this also works:
local function COM_PrintTest()
    print(
"Hello, world!")
end)
COM_AddCommand("print_test"COM_PrintTest
The third argument to the command limits who can execute it:

Code:
local function COM_PrintTest()
    print("Hello, world!")
end)
COM_AddCommand("print_test", COM_PrintTest, 1)
// above command is now server or admin only
__________________
Discord: Monster psychic cat#7274
Monster psychic cat is offline   Reply With Quote
Old 09-09-2017   #3
Yoshirocks90
Eh, maybe later.
 
Yoshirocks90's Avatar
Default

Alright, thanks. I'll post again if I screw something up.
Yoshirocks90 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:06 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.