Jump to content

Fixing command from localchat to chatbox


//_Dragon

Recommended Posts

When i do some command's chatbox like :/disconnect /quit /nick ...

this pic :arrow:http://imgur.com/uPtiTqN will show yous the problem check it first

Idk what is the problem

function localMessage(thePlayer, cmd, ...) 
local message = table.concat({ ... }, " ") 
local name = getPlayerName(thePlayer) 
local r, g, b = getPlayerNametagColor(thePlayer) 
local hex = string.format("#%.2X%.2X%.2X", r, g, b) -- converts R, G, B to HEX value 
outputChatBox("(Local) "..hex..name..": #ffffff"..message, getRootElement(), 255, 255, 0, true) 
end 
addCommandHandler("Local", localMessage) 

Link to comment
When i do some command's chatbox like :/disconnect /quit /nick ...

this pic :arrow:http://imgur.com/uPtiTqN will show yous the problem check it first

Idk what is the problem

function localMessage(thePlayer, cmd, ...) 
local message = table.concat({ ... }, " ") 
local name = getPlayerName(thePlayer) 
local r, g, b = getPlayerNametagColor(thePlayer) 
local hex = string.format("#%.2X%.2X%.2X", r, g, b) -- converts R, G, B to HEX value 
outputChatBox("(Local) "..hex..name..": #ffffff"..message, getRootElement(), 255, 255, 0, true) 
end 
addCommandHandler("Local", localMessage) 

Why you create new topic? This is in your old topic..

Link to comment

I dont think so

How to getplayernametagcolor i mean local hex

local root = getRootElement() 
  
function localMessage(thePlayer, cmd, ...) 
local message = table.concat({ ... }, " ") 
    local account = getAccountName(getPlayerAccount(source)) 
    local name = getPlayerName(thePlayer) 
local r, g, b = getPlayerNametagColor(thePlayer) 
local hex = string.format("#%.2X%.2X%.2X", r, g, b) 
 cancelEvent() 
    if isObjectInACLGroup("user." .. account, aclGetGroup("Everyone")) then 
    outputChatBox("(Local) "..hex..name..": #ffffff" .. text, root, 255, 255, 255, true) 
        
    elseif isObjectInACLGroup("user." .. account, aclGetGroup("Admin")) then 
    outputChatBox("(Local) "..hex..name..": #ffffff" .. text, root, 255, 255, 255, true) 
     
    end 
function s3d() 
outputChatBox ( "", source, 0, 0, 0, true ) 
end 
addEventHandler("onPlayerJoin", getRootElement(), s3d) 
  
end 
addEventHandler("onPlayerChat", root, chatbox) 
  
outputChatBox ( "", 255, 255, 255, true ) 
outputChatBox ( "", 255, 255, 255, true ) 

Link to comment

check the first script u'll see this

local hex = string.format("#%.2X%.2X%.2X", r, g, b) -- converts R, G, B to HEX value 
outputChatBox("(Local) "..hex..name..": 
 

i want made it here

local root = getRootElement() 
  
function localMessage(thePlayer, cmd, ...) 
local message = table.concat({ ... }, " ") 
    local account = getAccountName(getPlayerAccount(source)) 
    local name = getPlayerName(thePlayer) 
local r, g, b = getPlayerNametagColor(thePlayer) 
local hex = string.format("#%.2X%.2X%.2X", r, g, b) 
 cancelEvent() 
    if isObjectInACLGroup("user." .. account, aclGetGroup("Everyone")) then 
    outputChatBox("(Local) "..hex..name..": #ffffff" .. text, root, 255, 255, 255, true) 
        
    elseif isObjectInACLGroup("user." .. account, aclGetGroup("Admin")) then 
    outputChatBox("(Local) "..hex..name..": #ffffff" .. text, root, 255, 255, 255, true) 
    
    end 
function s3d() 
outputChatBox ( "", source, 0, 0, 0, true ) 
end 
addEventHandler("onPlayerJoin", getRootElement(), s3d) 
  
end 
addEventHandler("onPlayerChat", root, chatbox) 
  
outputChatBox ( "", 255, 255, 255, true ) 
outputChatBox ( "", 255, 255, 255, true ) 

Link to comment
What is the exact problem? How doesn't it work? Any debugscript errors?

Check the pic for see debugscript errors

http://imgur.com/gHkVkT3

local root = getRootElement() 
  
function localMessage (thePlayer, cmd, ...) 
local message = table.concat({ ... }, " ") 
    local account = getAccountName(getPlayerAccount(source)) 
    local name = getPlayerName(thePlayer) 
local r, g, b = getPlayerNametagColor(thePlayer) 
local hex = string.format("#%.2X%.2X%.2X", r, g, b) 
 cancelEvent() 
    if isObjectInACLGroup("user." .. account, aclGetGroup("Everyone")) then 
    outputChatBox("(Local) "..hex..name..": #ffffff" .. text, root, 255, 255, 255, true) 
        
    elseif isObjectInACLGroup("user." .. account, aclGetGroup("Admin")) then 
    outputChatBox("(Local) "..hex..name..": #ffffff" .. text, root, 255, 255, 255, true) 
    
    end 
end 
addEventHandler("onPlayerChat", root, localMessage) 

Link to comment

It it's 'onPlayerChat' now, you need to edit the function intake arguments - there's no thePlayer (it's the source in this case)

Delete

local message = table.concat({ ... }, " ") -- line 4 

Change

local name = getPlayerName(thePlayer) -- line 6 
local r, g, b = getPlayerNametagColor(thePlayer) --line 7 

to

local name = getPlayerName(source) 
local r, g, b = getPlayerNametagColor(source) 

And change

function localMessage (thePlayer, cmd, ...) -- line 3 

to

function localMessage(message, chatType) 

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