Jump to content

addCommandHandler on meta.xml


skybad

Recommended Posts

Hello, i need to know is it's possible put the addCommandHandler function in meta.xml file to change the command in game using admin panel and then settings, because if i want to change the command i need to edit the script and then restart the script for players use the new command, and i don't want to restart the script i want change it on Admin panel, btw the script is server side script

Something like this:

QTs3oVJ.png

There i can change for true or false colored names in socreboard...

Link to comment

Yeah i know that but how i made it for addCommandHandler? hi know i can make smething like this:

Server Side

colorCodesDefault = { } 
colorCodesDefault.colorcode1 = "#FF7300" 
colorCodesDefault.colorcode3 = "#FF7300" 
colorCodesDefault.colorcode2 = "#DBD7D7" 
  
colorCodes = { } 
colorCodes.colorcode1 = get ( "colorcode1" ) or colorCodesDefault.colorcode1 
colorCodes.colorcode2 = get ( "colorcode2" ) or colorCodesDefault.colorcode2 
colorCodes.colorcode3 = get ( "colorcode3" ) or colorCodesDefault.colorcode3 

Meta.xml

<setting name="*colorcode1" value="#AD505C" friendlyname="Prefix color" group="Colors" examples="#AD505C" desc="Color of the prefix" /> 
        <setting name="*colorcode2" value="#AD505C" friendlyname="Nick color" group="Colors" examples="#AD505C" desc="Color of the nickname" /> 
        <setting name="*colorcode3" value="#DBD7D7" friendlyname="Message color" group="Colors" examples="#DBD7D7" desc="Color of the message" /> 

Can someone make an example like the this one

colorCodesDefault = { } 
colorCodesDefault.colorcode1 = "#FF7300" 
colorCodes = { } 
colorCodes.colorcode1 = get ( "colorcode1" ) or colorCodesDefault.colorcode1 

but for commandHandler

Link to comment

I think like this

commands = {} 
commands.engine = 'setengine' 
commands.lock = 'lock' 
  
newcommands = {} 
newcommands.engine = get ( "engine" ) or commands.engine 
newcommands.lock = get( "lock" ) or commands.lock 
  
addCommandHandler(newcommands.engine, testFunction) 
addCommandHandler(newcommands.lock, test1Function) 

Link to comment

Is giving this error:

script/sv.lua:7: Bad argument @ 'addCommandHandler' [Expected function at argument 2, got nil]

I will post the code:

commands = {} 
commands.engine = "setengine" 
  
newcommands = {} 
newcommands.engine = get ( "engine" ) or commands.engine 
  
addCommandHandler(newcommands.engine, pack) 
  
function pack(thePlayer) 
local account = getPlayerAccount(thePlayer) 
if (not account or isGuestAccount(account)) then return end 
local accountName = getAccountName(account) 
if ( isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "Everyone" ) ) ) then 
        --Player Data 
        setElementData(thePlayer,"blood",12000) 
        end 
    end 

And the meta.xml file

<meta> 
<script src="sv.lua" type="server" /> 
<settings> 
<setting name="*engine" value="setengine" friendlyname="test1" group="test" examples="setengine" desc="TestT" /> 
</settings> 
</meta> 

Link to comment
  
commands = {} 
commands.engine = "setengine" 
  
newcommands = {} 
newcommands.engine = get ( "engine" ) or commands.engine 
  
  
  
function pack(thePlayer) 
local account = getPlayerAccount(thePlayer) 
if (not account or isGuestAccount(account)) then return end 
local accountName = getAccountName(account) 
if ( isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "Everyone" ) ) ) then 
        --Player Data 
        setElementData(thePlayer,"blood",12000) 
        end 
    end 
addCommandHandler(newcommands.engine, pack) 
  

Link to comment

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...