-.Paradox.- Posted July 24, 2013 Share Posted July 24, 2013 Hello all, i have this pm system and i want use getPlayerNametagColor here is the code: function privateMessage(thePlayer,commandName,sendToName,...) local pmWords = { ... } local pmMessage = table.concat( pmWords, " " ) if sendToName then if (getPlayerFromParticalName (sendToName)) then toPlayer = (getPlayerFromParticalName (sendToName)) if not (toPlayer == thePlayer) then if not (pmMessage == "") then outputChatBox("#0096ff[PM] to #ff0000" .. getPlayerName(toPlayer) .. ":#FFFFFF " .. pmMessage, thePlayer, 255, 255, 255, true) outputChatBox("#0096ff[PM] from #ff0000" .. getPlayerName(thePlayer) .. ":#FFFFFF " .. pmMessage, toPlayer, 255, 255, 255, true) else outputChatBox("#0044FF[PM]#FFFFFF Invalid syntax! Usage:#FFFFFF /pm [player name] [message]", thePlayer, 255, 255, 255, true) return false end else outputChatBox("#0044FF[PM]#FFFFFF You cannot PM yourself#FFFFFF!", thePlayer, 255, 255, 255, true) return false end else outputChatBox("#0044FF[PM]#FFFFFF Player not found! #FFFF00(#FFFFFF"..sendToName.."#FFFF00)", thePlayer, 255, 255, 255, true) return false end else outputChatBox("#0044FF[PM]#FFFFFF Invalid syntax! Usage:#FFFFFF /pm [partical player name] [message]", thePlayer, 255, 255, 255, true) return false end end addCommandHandler("pm", privateMessage) function getPlayerFromParticalName(thePlayerName) local thePlayer = getPlayerFromName(thePlayerName) if thePlayer then return thePlayer end for _,thePlayer in ipairs(getElementsByType("player")) do if string.find(string.gsub(getPlayerName(thePlayer):lower(),"#%x%x%x%x%x%x", ""), thePlayerName:lower(), 1, true) then return thePlayer end end return false end that's the backup, i hope somebody help me. Link to comment
-.Paradox.- Posted July 25, 2013 Author Share Posted July 25, 2013 getPlayerNametagColor I tried it but when i pm some one its how like that, [PM] to 0: or [PM] to nil Link to comment
codeluaeveryday Posted July 25, 2013 Share Posted July 25, 2013 Sorry this took so long, I am at school and I don't have much free time to do this: function privateMessage(thePlayer,commandName,sendToName,...) local pmWords = { ... } local pmMessage = table.concat( pmWords, " " ) if sendToName then if (getPlayerFromParticalName (sendToName)) then local toPlayer = (getPlayerFromParticalName (sendToName)) local toPlayerTeam = getPlayerTeam(toPlayer) if toPlayerTeam then local toRed, toGreen, toBlue = getTeamColor(toPlayerTeam) toColor = string.format("#%02X%02X%02X", toRed, toGreen, toBlue) else toColor = '#ffffff' end local fromPlayerTeam = getPlayerTeam(thePlayer) if fromPlayerTeam then local fromRed, fromGreen, fromBlue = getTeamColor(fromPlayerTeam) fromColor = string.format("#%02X%02X%02X", fromRed, fromGreen, fromBlue) else fromColor = '#ffffff' end if not (toPlayer == thePlayer) then if not (pmMessage == "") then outputChatBox("#0096ff[PM] to ".. toColor .. getPlayerName(toPlayer) .. ":#FFFFFF " .. pmMessage, thePlayer, 255, 255, 255, true) outputChatBox("#0096ff[PM] from " .. fromColor .. getPlayerName(thePlayer) .. ":#FFFFFF " .. pmMessage, toPlayer, 255, 255, 255, true) else outputChatBox("#0044FF[PM]#FFFFFF Invalid syntax! Usage:#FFFFFF /pm [player name] [message]", thePlayer, 255, 255, 255, true) return false end else outputChatBox("#0044FF[PM]#FFFFFF You cannot PM yourself#FFFFFF!", thePlayer, 255, 255, 255, true) return false end else outputChatBox("#0044FF[PM]#FFFFFF Player not found! #FFFF00(#FFFFFF"..sendToName.."#FFFF00)", thePlayer, 255, 255, 255, true) return false end else outputChatBox("#0044FF[PM]#FFFFFF Invalid syntax! Usage:#FFFFFF /pm [partical player name] [message]", thePlayer, 255, 255, 255, true) return false end end addCommandHandler("pm", privateMessage) function getPlayerFromParticalName(thePlayerName) local thePlayer = getPlayerFromName(thePlayerName) if thePlayer then return thePlayer end for _,thePlayer in ipairs(getElementsByType("player")) do if string.find(string.gsub(getPlayerName(thePlayer):lower(),"#%x%x%x%x%x%x", ""), thePlayerName:lower(), 1, true) then return thePlayer end end return false end 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