[DemoN] Posted June 6, 2011 Share Posted June 6, 2011 Guys I need help . I was editing playercolors for a clantag script but it outputs a message twice: When I type: Hello World, it outputs; DemoN: Hello World [TestTag]DemoN: Hello World If you know how to make it correct, here is my code(Note: I didn't make this resource, I've just changed it) : local lowerBound,upperBound = unpack(get"color_range") g_Root = getRootElement () g_ResourceRoot = getResourceRootElement ( getThisResource () ) getPlayerColor = getPlayerNametagColor getPlayerColour = getPlayerNametagColor addEventHandler ( "onResourceStart", g_ResourceRoot, function() for i,player in ipairs(getElementsByType"player") do processPlayer ( player ) end end ) function processPlayer ( player ) player = player or source local r, g, b = math.random(lowerBound, upperBound), math.random(lowerBound, upperBound), math.random(lowerBound, upperBound) setPlayerNametagColor(player, r, g, b) end addEventHandler ( "onPlayerJoin", g_Root, processPlayer ) function chatMyBox (msg, type) if type == 0 then cancelEvent() local account = getPlayerAccount(source) local r, g, b = getPlayerColor(source) local name = getPlayerName(source) local msg = msg:gsub('#%x%x%x%x%x%x', '') if isObjectInACLGroup( 'user.'..getAccountName( account ), aclGetGroup( 'Admin' ) ) then outputChatBox( "#FF0000[TestTag]" .. name .. ': #FFFFFF' .. msg, g_Root, r, g, b, true) elseif isObjectInACLGroup( 'user.'..getAccountName( account ), aclGetGroup( 'Moderator' ) ) then outputChatBox( "#FF8000[TestTag]" .. name .. ': #FFFFFF' .. msg, g_Root, r, g, b, true) elseif isObjectInACLGroup( 'user.'..getAccountName( account ), aclGetGroup( 'Member' ) ) then outputChatBox( "#00FF00[TestTag]" .. name .. ': #FFFFFF' .. msg, g_Root, r, g, b, true) elseif isObjectInACLGroup( 'user.'..getAccountName( account ), aclGetGroup( 'V.I.P' ) ) then outputChatBox( "#0000FF[TestTag]" .. name .. ': #FFFFFF' .. msg, g_Root, r, g, b, true) elseif isObjectInACLGroup( 'user.'..getAccountName( account ), aclGetGroup( 'Scripter' ) ) then outputChatBox( "#00FFFF[TestTag]" .. name .. ': #FFFFFF' .. msg, g_Root, r, g, b, true) end else outputChatBox( name .. ': #FFFFFF' .. msg, g_Root, r, g, b, true) end end addEventHandler('onPlayerChat', g_Root, chatMyBox) Link to comment
karlis Posted June 6, 2011 Share Posted June 6, 2011 move end in line 39 to line 42. also replace getPlayerColor with getPlayerNametagColor Link to comment
[DemoN] Posted June 6, 2011 Author Share Posted June 6, 2011 SCRIPT ERROR: playercolors\playercolors.lua:43: 'end' expected (to close 'function' at line 22) near '' WARNING: Loading script failed: playercolors\playercolors.lua:43: 'end' expected (to close 'function' at line 22) near '' not working and still outputs twice Link to comment
laserlaser Posted June 6, 2011 Share Posted June 6, 2011 Change local lowerBound,upperBound = unpack(get"color_range") g_Root = getRootElement () g_ResourceRoot = getResourceRootElement ( getThisResource () ) getPlayerColor = getPlayerNametagColor getPlayerColour = getPlayerNametagColor addEventHandler ( "onResourceStart", g_ResourceRoot, function() for i,player in ipairs(getElementsByType"player") do processPlayer ( player ) end end ) function processPlayer ( player ) player = player or source local r, g, b = math.random(lowerBound, upperBound), math.random(lowerBound, upperBound), math.random(lowerBound, upperBound) setPlayerNametagColor(player, r, g, b) end addEventHandler ( "onPlayerJoin", g_Root, processPlayer ) function chatMyBox (msg, type) if type == 0 then cancelEvent() local account = getPlayerAccount(source) local r, g, b = getPlayerColor(source) local name = getPlayerName(source) local msg = msg:gsub('#%x%x%x%x%x%x', '') if isObjectInACLGroup( 'user.'..getAccountName( account ), aclGetGroup( 'Admin' ) ) then outputChatBox( "#FF0000[TestTag]" .. name .. ': #FFFFFF' .. msg, g_Root, r, g, b, true) elseif isObjectInACLGroup( 'user.'..getAccountName( account ), aclGetGroup( 'Moderator' ) ) then outputChatBox( "#FF8000[TestTag]" .. name .. ': #FFFFFF' .. msg, g_Root, r, g, b, true) elseif isObjectInACLGroup( 'user.'..getAccountName( account ), aclGetGroup( 'Member' ) ) then outputChatBox( "#00FF00[TestTag]" .. name .. ': #FFFFFF' .. msg, g_Root, r, g, b, true) elseif isObjectInACLGroup( 'user.'..getAccountName( account ), aclGetGroup( 'V.I.P' ) ) then outputChatBox( "#0000FF[TestTag]" .. name .. ': #FFFFFF' .. msg, g_Root, r, g, b, true) elseif isObjectInACLGroup( 'user.'..getAccountName( account ), aclGetGroup( 'Scripter' ) ) then outputChatBox( "#00FFFF[TestTag]" .. name .. ': #FFFFFF' .. msg, g_Root, r, g, b, true) else outputChatBox( name .. ': #FFFFFF' .. msg, g_Root, r, g, b, true) end end end addEventHandler('onPlayerChat', g_Root, chatMyBox) Link to comment
karlis Posted June 6, 2011 Share Posted June 6, 2011 thats why you want to keep spacing, so you can read it function chatMyBox (msg, type) if type == 0 then cancelEvent() local account = getPlayerAccount(source) local r, g, b = getPlayerColor(source) local name = getPlayerName(source) local msg = msg:gsub('#%x%x%x%x%x%x', '') if isObjectInACLGroup( 'user.'..getAccountName( account ), aclGetGroup( 'Admin' ) ) the outputChatBox( "#FF0000[TestTag]" .. name .. ': #FFFFFF' .. msg, g_Root, r, g, b, true) elseif isObjectInACLGroup( 'user.'..getAccountName( account ), aclGetGroup( 'Moderator' ) ) the outputChatBox( "#FF8000[TestTag]" .. name .. ': #FFFFFF' .. msg, g_Root, r, g, b, true) elseif isObjectInACLGroup( 'user.'..getAccountName( account ), aclGetGroup( 'Member' ) ) then outputChatBox( "#00FF00[TestTag]" .. name .. ': #FFFFFF' .. msg, g_Root, r, g, b, true) elseif isObjectInACLGroup( 'user.'..getAccountName( account ), aclGetGroup( 'V.I.P' ) ) then outputChatBox( "#0000FF[TestTag]" .. name .. ': #FFFFFF' .. msg, g_Root, r, g, b, true) elseif isObjectInACLGroup( 'user.'..getAccountName( account ), aclGetGroup( 'Scripter' ) ) the outputChatBox( "#00FFFF[TestTag]" .. name .. ': #FFFFFF' .. msg, g_Root, r, g, b, true) else outputChatBox( name .. ': #FFFFFF' .. msg, g_Root, r, g, b, true) end end end EDIT:ninja'd Link to comment
[DemoN] Posted June 6, 2011 Author Share Posted June 6, 2011 it still outputs twice. Try it on your pc. If it's correct, tell me EDIT:ninja'd lol Link to comment
laserlaser Posted June 6, 2011 Share Posted June 6, 2011 Try; local lowerBound,upperBound = unpack(get("color_range")) g_Root = getRootElement () g_ResourceRoot = getResourceRootElement ( getThisResource () ) getPlayerColor = getPlayerNametagColor getPlayerColour = getPlayerNametagColor addEventHandler ( "onResourceStart", g_ResourceRoot, function() for i,player in ipairs(getElementsByType"player") do processPlayer ( player ) end end ) function processPlayer ( player ) local r, g, b = math.random(lowerBound, upperBound), math.random(lowerBound, upperBound), math.random(lowerBound, upperBound) setPlayerNametagColor(player, r, g, b) end addEventHandler ( "onPlayerJoin", g_Root, processPlayer ) function chatMyBox (msg, type) if type == 0 then cancelEvent() local account = getPlayerAccount(source) local r, g, b = getPlayerColor(source) local name = getPlayerName(source) local msg = msg:gsub('#%x%x%x%x%x%x', '') if isObjectInACLGroup( 'user.'..getAccountName( account ), aclGetGroup( 'Admin' ) ) then outputChatBox( "#FF0000[TestTag]" .. name .. ': #FFFFFF' .. msg, g_Root, r, g, b, true) elseif isObjectInACLGroup( 'user.'..getAccountName( account ), aclGetGroup( 'Moderator' ) ) then outputChatBox( "#FF8000[TestTag]" .. name .. ': #FFFFFF' .. msg, g_Root, r, g, b, true) elseif isObjectInACLGroup( 'user.'..getAccountName( account ), aclGetGroup( 'Member' ) ) then outputChatBox( "#00FF00[TestTag]" .. name .. ': #FFFFFF' .. msg, g_Root, r, g, b, true) elseif isObjectInACLGroup( 'user.'..getAccountName( account ), aclGetGroup( 'V.I.P' ) ) then outputChatBox( "#0000FF[TestTag]" .. name .. ': #FFFFFF' .. msg, g_Root, r, g, b, true) elseif isObjectInACLGroup( 'user.'..getAccountName( account ), aclGetGroup( 'Scripter' ) ) then outputChatBox( "#00FFFF[TestTag]" .. name .. ': #FFFFFF' .. msg, g_Root, r, g, b, true) else outputChatBox( name .. ': #FFFFFF' .. msg, g_Root, r, g, b, true) end end end addEventHandler('onPlayerChat', g_Root, chatMyBox) Link to comment
karlis Posted June 6, 2011 Share Posted June 6, 2011 it work twice cuz some other res is running, try stopping playerblips/playercolors res. Link to comment
CowTurbo Posted June 6, 2011 Share Posted June 6, 2011 freeroam can have chat script too ? Link to comment
karlis Posted June 6, 2011 Share Posted June 6, 2011 dont know, stop res one by one and check Link to comment
Castillo Posted June 6, 2011 Share Posted June 6, 2011 Freeroam has a chat script also (if i'm not wrong), so maybe it's that or "playercolors" (this is the most usual). Link to comment
[DemoN] Posted June 7, 2011 Author Share Posted June 7, 2011 it work twice cuz some other res is running, try stopping playerblips/playercolors res. If I close playercolors res., my script wont work because i'm working on it as Clan Tags. Freeroam has a chat script also (if i'm not wrong), so maybe it's that or "playercolors" (this is the most usual). Oh, really? If you know where i can find it, please tell me Castillo. I need it. Or tell me how can i make a script like that? when you type on your server, it will output (If you are admin and your nick is Castillo): [MM]Castillo (for example). Thanks for helpings but it still outputs twice. I think i won't make it correct Link to comment
karlis Posted June 7, 2011 Share Posted June 7, 2011 you just need to find other script that outputs chat too. EDIT: comment line 392-400 in fr_server.lua Link to comment
Castillo Posted June 7, 2011 Share Posted June 7, 2011 (edited) local lowerBound,upperBound = unpack(get("color_range")) g_Root = getRootElement () g_ResourceRoot = getResourceRootElement ( getThisResource () ) getPlayerColor = getPlayerNametagColor addEventHandler ( "onResourceStart", g_ResourceRoot, function() for i,player in ipairs(getElementsByType"player") do processPlayer ( player ) end end) function processPlayer ( player ) local r, g, b = math.random(lowerBound, upperBound), math.random(lowerBound, upperBound), math.random(lowerBound, upperBound) setPlayerNametagColor(player, r, g, b) end addEventHandler ( "onPlayerJoin", g_Root, processPlayer ) local groups = {"Admin","Moderator","Member","V.I.P","Scripter"} local clanTags = { ["Admin"] = "ADM", ["Moderator"] = "MOD", ["Member"] = "M", ["V.I.P"] = "V.I.P", ["Scripter"] = "SCP", } function chatMyBox (msg, type) if type == 0 then cancelEvent() local r, g, b = getPlayerColor(source) local name = getPlayerName(source) local msg = msg:gsub('#%x%x%x%x%x%x', '') if getMyGroup(source) then outputChatBox( "#FF0000["..clanTags[getMyGroup(source)].."]" .. name .. ': #FFFFFF' .. msg, g_Root, r, g, b, true) else outputChatBox( name .. ': #FFFFFF' .. msg, g_Root, r, g, b, true) end end end addEventHandler('onPlayerChat', g_Root, chatMyBox) function getMyGroup(player) local account = getPlayerAccount(player) for i,v in pairs(groups) do if isObjectInACLGroup( 'user.'..getAccountName( account ), aclGetGroup(v) ) then return v end end return false end I think that's a better way of doing this. Edited June 7, 2011 by Guest Link to comment
[DemoN] Posted June 7, 2011 Author Share Posted June 7, 2011 you just need to find other script that outputs chat too.EDIT: comment line 392-400 in fr_server.lua Thank you. local lowerBound,upperBound = unpack(get("color_range")) g_Root = getRootElement () g_ResourceRoot = getResourceRootElement ( getThisResource () ) getPlayerColor = getPlayerNametagColor addEventHandler ( "onResourceStart", g_ResourceRoot, function() for i,player in ipairs(getElementsByType"player") do processPlayer ( player ) end end) function processPlayer ( player ) local r, g, b = math.random(lowerBound, upperBound), math.random(lowerBound, upperBound), math.random(lowerBound, upperBound) setPlayerNametagColor(player, r, g, b) end addEventHandler ( "onPlayerJoin", g_Root, processPlayer ) local groups = {"Admin","Moderator","Member","V.I.P","Scripter","Sr.Admin"} local clanTags = { ["Admin"] = "ADM", ["Moderator"] = "MOD", ["Member"] = "M", ["V.I.P"] = "V.I.P", ["Scripter"] = "SCP", } function chatMyBox (msg, type) if type == 0 then cancelEvent() local r, g, b = getPlayerColor(source) local name = getPlayerName(source) local msg = msg:gsub('#%x%x%x%x%x%x', '') if getMyGroup(source) then outputChatBox( "#FF0000["..clanTags[getMyGroup(source)].."]" .. name .. ': #FFFFFF' .. msg, g_Root, r, g, b, true) else outputChatBox( name .. ': #FFFFFF' .. msg, g_Root, r, g, b, true) end end end addEventHandler('onPlayerChat', g_Root, chatMyBox) function getMyGroup(player) local account = getPlayerAccount(player) for i,v in pairs(groups) do if isObjectInACLGroup( 'user.'..getAccountName( account ), aclGetGroup(v) ) then return v end end return false end I think that's a better way of doing this. and thank you for this script Castillo 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