~Air Posted December 20, 2014 Share Posted December 20, 2014 (edited) Hey guys, I am back with an another problem and I already tried it 100 of times to fix it. Maybe I am to retarded for it. I hope you can help me... Code: --NEW CODE-- Scroll down Edited December 23, 2014 by Guest Link to comment
Anubhav Posted December 20, 2014 Share Posted December 20, 2014 function playerChat(message, messageType) if messageType == 2 then cancelEvent() local acc = getPlayerAccount(source) if not isGuestAccount(acc) then if getAccountData(acc,"chatc") and getElementData(source, "Vip") == true then local color = getAccountData(acc,"chatc") for i,team in ipairs(getPlayersInTeam(getPlayerTeam(source))) do local r,g,b = getTeamColor(getPlayerTeam(source)) if ( r ) and ( g ) and ( b ) then outputChatBox(RGBToHex(r,g,b).."(TEAM): "..getPlayerName(source)..": "..color..""..message, root, r, g, b, true ) else outputChatBox(RGBToHex(r,g,b).."(TEAM): "..getPlayerName(source)..": #FFFFFF"..message, root, r, g, b, true ) end else outputChatBox("(TEAM): "..getPlayerName(source)..": #FFFFFF"..message, root, r, g, b, true ) end outputServerLog("CHAT: "..getPlayerName(source)..": "..message) end end end addEventHandler("onPlayerChat", root, playerChat) function RGBToHex(red, green, blue, alpha) if((red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255) or (alpha and (alpha < 0 or alpha > 255))) then return nil end if(alpha) then return string.format("#%.2X%.2X%.2X%.2X", red,green,blue,alpha) else return string.format("#%.2X%.2X%.2X", red,green,blue) end end Link to comment
Anubhav Posted December 20, 2014 Share Posted December 20, 2014 function playerChat(message, messageType) if messageType == 2 then cancelEvent() local acc = getPlayerAccount(source) if not isGuestAccount(acc) then if getAccountData(acc,"chatc") and getElementData(source, "Vip") == true then local color = getAccountData(acc,"chatc") for i,team in ipairs(getPlayersInTeam(getPlayerTeam(source))) do local r,g,b = getTeamColor(getPlayerTeam(source)) if ( r ) and ( g ) and ( b ) then outputChatBox(RGBToHex(r,g,b).."(TEAM): "..getPlayerName(source)..": "..color..""..message, root, r, g, b, true ) else outputChatBox(RGBToHex(r,g,b).."(TEAM): "..getPlayerName(source)..": #FFFFFF"..message, root, r, g, b, true ) end end else outputChatBox("(TEAM): "..getPlayerName(source)..": #FFFFFF"..message, root, r, g, b, true ) end outputServerLog("CHAT: "..getPlayerName(source)..": "..message) end end end addEventHandler("onPlayerChat", root, playerChat) function RGBToHex(red, green, blue, alpha) if((red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255) or (alpha and (alpha < 0 or alpha > 255))) then return nil end if(alpha) then return string.format("#%.2X%.2X%.2X%.2X", red,green,blue,alpha) else return string.format("#%.2X%.2X%.2X", red,green,blue) end end Link to comment
TAPL Posted December 20, 2014 Share Posted December 20, 2014 function playerChat(message, messageType) if messageType == 2 then cancelEvent() local acc = getPlayerAccount(source) if not isGuestAccount(acc) then local color = getAccountData(acc, "chatc") local VIP = getElementData(source, "Vip") local team = getPlayerTeam(source) local r, g, b = getTeamColor(team) local name = getPlayerName(source) for i, player in ipairs(getPlayersInTeam(team)) do if color and VIP then outputChatBox("(TEAM): "..name..": "..color..message, player, r, g, b, true) else outputChatBox("(TEAM): "..name..": #FFFFFF"..message, player, r, g, b, true) end end outputServerLog("CHAT: "..name..": "..message) end end end addEventHandler("onPlayerChat", root, playerChat) Link to comment
~Air Posted December 20, 2014 Author Share Posted December 20, 2014 Thanks to Anubhav, it worked! Link to comment
TAPL Posted December 20, 2014 Share Posted December 20, 2014 Thanks to Anubhav, it worked! Are you sure? Link to comment
~Air Posted December 20, 2014 Author Share Posted December 20, 2014 Yes it works perfectly Link to comment
~Air Posted December 23, 2014 Author Share Posted December 23, 2014 I have got one more problem but at one other script: I had lots of tries to fix it but it still doesn't work. (end expected near else) Here is the script: function setDiscoLights () local bougheadlights = getAccountData(account,"boughtHeadlights2") if not bougheadlights then if cash >= 10000 or (getElementData(source, "Vip") and cash >= 5000) then setTimer(outputChatBox,50,1,"* #FFFFFF"..getPlayerName(source).."#FFFFFF bought Disco-Headlights!",getRootElement(),0,255,0,true) if getElementData(source, "Vip") == true then addStat(account, "cash", -5000) else addStat(account, "cash", -10000) end setAccountData(account, "DiscoLights",true) setAccountData(account, "boughtHeadlights2",true) end else outputChatBox ("* #FFFFFFYou don't have got enough money!",source,unpack(scriptcol[5])) cancelEvent() else outputChatBox ("* #FFFFFFYou already have bought Disco-Headlights!",source,unpack(scriptcol[5])) cancelEvent() end addEvent("setDiscoLights",true) addEventHandler("setDiscoLights",getRootElement(),setDiscoLights) Link to comment
Bonsai Posted December 23, 2014 Share Posted December 23, 2014 I have got one more problem but at one other script:I had lots of tries to fix it but it still doesn't work. (end expected near else) Here is the script: function setDiscoLights () local bougheadlights = getAccountData(account,"boughtHeadlights2") if not bougheadlights then if cash >= 10000 or (getElementData(source, "Vip") and cash >= 5000) then setTimer(outputChatBox,50,1,"* #FFFFFF"..getPlayerName(source).."#FFFFFF bought Disco-Headlights!",getRootElement(),0,255,0,true) if getElementData(source, "Vip") == true then addStat(account, "cash", -5000) else addStat(account, "cash", -10000) end setAccountData(account, "DiscoLights",true) setAccountData(account, "boughtHeadlights2",true) end else outputChatBox ("* #FFFFFFYou don't have got enough money!",source,unpack(scriptcol[5])) cancelEvent() else outputChatBox ("* #FFFFFFYou already have bought Disco-Headlights!",source,unpack(scriptcol[5])) cancelEvent() end addEvent("setDiscoLights",true) addEventHandler("setDiscoLights",getRootElement(),setDiscoLights) How hard can this be... Two else in a row. Link to comment
Dealman Posted December 24, 2014 Share Posted December 24, 2014 Use proper indentations and you won't be having as a hard time seeing where you messed up. Also, reading up how if statements work within Lua could be useful. 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