Mossy Posted September 24, 2012 Share 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. Link to comment
Castillo Posted September 24, 2012 Share Posted September 24, 2012 You must have more than one resource that is used to chat. Link to comment
Mossy Posted September 24, 2012 Author Share 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? Link to comment
Renkon Posted September 24, 2012 Share Posted September 24, 2012 Have you tried to do something related to onPlayerChat recently? Link to comment
TAPL Posted September 24, 2012 Share 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. Link to comment
Mossy Posted September 24, 2012 Author Share 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) Link to comment
Jaysds1 Posted September 24, 2012 Share 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) Link to comment
Jaysds1 Posted September 24, 2012 Share Posted September 24, 2012 was there any error? Link to comment
Renkon Posted September 24, 2012 Share 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 Link to comment
Mossy Posted September 24, 2012 Author Share Posted September 24, 2012 was there any error? I'll run the debug now. But it just repeated again. Link to comment
Mossy Posted September 24, 2012 Author Share 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! Link to comment
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