Jump to content

Chat replies are repeated


Mossy

Recommended Posts

Mostly, this is caused from resource "Freeroam", but since you're using "race" there are two possibilities:

1- You were test your scripts in your lan server and Freeroam was running.

2- You have other resource has event onPlayerChat and whenever you say anything in the chat it will outputChatBox without cancelEvent and because this you will see it twice.

Link to comment
Mostly, this is caused from resource "Freeroam", but since you're using "race" there are two possibilities:

1- You were test your scripts in your lan server and Freeroam was running.

2- You have other resource has event onPlayerChat and whenever you say anything in the chat it will outputChatBox without cancelEvent and because this you will see it twice.

Figured out what resource caused it. Here's a portion of the script with the onPlayerChat function:

--- Chat & Name Color 
function chatNameColor(message,messageType) 
 local color = getElementData (source, "info.namecolor") 
 local color2 = getElementData(source, "info.chatcolor") 
 local serial = getPlayerSerial(source) 
 local playername = getPlayerName(source) 
 if (color) and (color2) then 
 outputChatBox(color..playername..": "..color2..message,getRootElement(),0,0,0,true) 
 executeSQLUpdate ( "Colors", "Ncolor = '"..color.."'","serial = '" .. serial .. "'") 
 executeSQLUpdate ( "Colors", "Ccolor = '"..color2.."'","serial = '" .. serial .. "'") 
 else 
 outputChatBox(playername..": "..message,getRootElement(),255,255,255,true) 
 end 
 end 
 addEventHandler("onPlayerChat",getRootElement(),chatNameColor)  
  
 function cancel() 
 cancelEvent() 
 end 
 addEventHandler("onPlayerChat",getRootElement(),cancel) 
 --- Cash !Command 
 function PubMoney(message,messageType) 
 if message == "!money" or message == "!cash" or message =="!Money" or message == "!Cash" then 
 local serial = getPlayerSerial(source) 
 local Money = executeSQLSelect ( "MoneyB", "Money","serial = '" .. serial .. "'") 
 local name = getPlayerName(source) 
 outputChatBox(name.." has $"..tonumber(Money[1]["Money"]),getRootElement(),255,255,0,true) 
 end 
 end 
 addEventHandler("onPlayerChat",getRootElement(),PubMoney) 

Link to comment

here, try this:

--- Chat & Name Color 
function chatNameColor(message) 
if string.find(message,"!",1,true) then return end 
 local color = getElementData (source, "info.namecolor") 
 local color2 = getElementData(source, "info.chatcolor") 
 local playername = getPlayerName(source) 
 if (color) and (color2) then 
 local serial = getPlayerSerial(source) 
 outputChatBox(color..""..playername..": "..color2..""..message,root,0,0,0,true) 
 executeSQLUpdate ( "Colors", "Ncolor = '"..color.."'","serial = '" .. serial .. "'") 
 executeSQLUpdate ( "Colors", "Ccolor = '"..color2.."'","serial = '" .. serial .. "'") 
 else 
 outputChatBox(playername..": "..message,getRootElement(),255,255,255,true) 
 end 
 end 
 addEventHandler("onPlayerChat",getRootElement(),chatNameColor) 
  
 function cancel() 
 cancelEvent() 
 end 
 addEventHandler("onPlayerChat",getRootElement(),cancel) 
 --- Cash !Command 
function PubMoney(message) 
    if not string.find(message,"!",1,true) then return end 
    message = string.lower(message) 
    if message == "!money" or message == "!cash" then 
        local serial = getPlayerSerial(source) 
        local Money = executeSQLSelect ( "MoneyB", "Money","serial = '" .. serial .. "'") 
        local name = getPlayerName(source) 
        outputChatBox(name.." has $"..tonumber(Money[1]["Money"]),getRootElement(),255,255,0,true) 
    end 
end 
addEventHandler("onPlayerChat",getRootElement(),PubMoney) 

Link to comment
--- Chat & Name Color 
function chatNameColor(message,messageType) 
 cancelEvent() 
 local color = getElementData (source, "info.namecolor") 
 local color2 = getElementData(source, "info.chatcolor") 
 local serial = getPlayerSerial(source) 
 local playername = getPlayerName(source) 
if message == "!money" or message == "!cash" or message =="!Money" or message == "!Cash" then 
 local serial = getPlayerSerial(source) 
 local Money = executeSQLSelect ( "MoneyB", "Money","serial = '" .. serial .. "'") 
 local name = getPlayerName(source) 
 outputChatBox(name.." has $"..tonumber(Money[1]["Money"]),getRootElement(),255,255,0,true) 
 return 
 end 
 if (color) and (color2) then 
 outputChatBox(color..playername..": "..color2..message,getRootElement(),0,0,0,true) 
 executeSQLUpdate ( "Colors", "Ncolor = '"..color.."'","serial = '" .. serial .. "'") 
 executeSQLUpdate ( "Colors", "Ccolor = '"..color2.."'","serial = '" .. serial .. "'") 
 else 
 outputChatBox(playername..": "..message,getRootElement(),255,255,255,true) 
 end 
 end 
 addEventHandler("onPlayerChat", getRootElement(), chatNameColor) 

Edited by Guest
Link to comment
--- Chat & Name Color 
function chatNameColor(message,messageType) 
 cancelEvent() 
 local color = getElementData (source, "info.namecolor") 
 local color2 = getElementData(source, "info.chatcolor") 
 local serial = getPlayerSerial(source) 
 local playername = getPlayerName(source) 
if message == "!money" or message == "!cash" or message =="!Money" or message == "!Cash" then 
 local serial = getPlayerSerial(source) 
 local Money = executeSQLSelect ( "MoneyB", "Money","serial = '" .. serial .. "'") 
 local name = getPlayerName(source) 
 outputChatBox(name.." has $"..tonumber(Money[1]["Money"]),getRootElement(),255,255,0,true) 
 return 
 end 
 if (color) and (color2) then 
 outputChatBox(color..playername..": "..color2..message,getRootElement(),0,0,0,true) 
 executeSQLUpdate ( "Colors", "Ncolor = '"..color.."'","serial = '" .. serial .. "'") 
 executeSQLUpdate ( "Colors", "Ccolor = '"..color2.."'","serial = '" .. serial .. "'") 
 else 
 outputChatBox(playername..": "..message,getRootElement(),255,255,255,true) 
 end 
 end 
 addEventHandler("onPlayerChat", getRootElement(), chatNameColor) 

Hey your script worked. Thanks!

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