Jump to content

Fixing command from localchat to chatbox


//_Dragon

Recommended Posts

Posted

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) 

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

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

Because no one can see it so i decide to creat new topic

Any one can fixe it ?

However, this topic see everyone so you do not write s.h.i.t anyone help? Whereas it is right first.

Posted
Nah dude i can i need only to add something i think i must change localmessage to chatbox

Help ?

I think this is not possible. Possible is disable old chat "T" and create new but with [Local].

Posted

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 ) 

Posted

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 ) 

Posted

Both

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

and

"(Local) "..hex..name..": #ffffff"..message 

are already in your script.

Posted
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) 

Posted

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) 

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