Mossy Posted September 24, 2012 Posted September 24, 2012 Hello. I have a race server and whenever I type something in the chat it repeats itself. Like for example if I say Hi, it will look like I said Hi twice. Scripting error or should I re-download the race resource? Thanks in advance.
Castillo Posted September 24, 2012 Posted September 24, 2012 You must have more than one resource that is used to chat.
Mossy Posted September 24, 2012 Author Posted September 24, 2012 You must have more than one resource that is used to chat. I thought that too cause when I change my resolution they're all listed twice. I must have duplicated some files. Do you know where the chat file is located?
Renkon Posted September 24, 2012 Posted September 24, 2012 Have you tried to do something related to onPlayerChat recently?
TAPL Posted September 24, 2012 Posted September 24, 2012 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.
Mossy Posted September 24, 2012 Author Posted September 24, 2012 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)
Jaysds1 Posted September 24, 2012 Posted September 24, 2012 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)
Renkon Posted September 24, 2012 Posted September 24, 2012 (edited) --- 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 September 24, 2012 by Guest
Mossy Posted September 24, 2012 Author Posted September 24, 2012 was there any error? I'll run the debug now. But it just repeated again.
Mossy Posted September 24, 2012 Author Posted September 24, 2012 --- 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!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now