TheGamingMann Posted August 28, 2014 Share Posted August 28, 2014 Hello. I am attempting to make a custom PM system but I am having some issues. I get no errors but it sends the pm to me no matter what... I am confused. *EDIT* So I figured this out the PM works... it sends right but it sends to global when there is no one in the server with that name. or partial name... still really confused. function privateMessageTwo(player, command, sentTo, ...) if (command == "pm") then local messageTable = {...} local message = table.concat(messageTable, " ") local sendTo = getPlayerFromPartialName(sentTo, player) if (sendTo ~= "") then if (message ~= "") then outputChatBox("#00FF00[PM FROM]#FFFFFF"..getPlayerName(player).."#BDBDBD: "..message, sendTo, 255, 255, 255, true) outputChatBox("#00FF00[PM TO]#FFFFFF"..getPlayerName(sendTo).."#BDBDBD: "..message, player, 255, 255, 255, true) else outputChatBox("Failed No Message") end else outputChatBox("Failed No Name") end else outputChatBox("Failed No Command") end end addCommandHandler("pm", privateMessageTwo) function getPlayerFromPartialName(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end Link to comment
Gr0x Posted August 28, 2014 Share Posted August 28, 2014 You forgot about the second argument of outputChatBox. outputChatBox("Failed No Message",player) Link to comment
TheGamingMann Posted August 28, 2014 Author Share Posted August 28, 2014 You forgot about the second argument of outputChatBox. outputChatBox("Failed No Message",player) Those are just test messages. the problem I am having is it sends the message globally if there is no player by the name in the server. Link to comment
Gr0x Posted August 28, 2014 Share Posted August 28, 2014 if (sendTo ~= "") then to if sendTo then Link to comment
TheGamingMann Posted August 28, 2014 Author Share Posted August 28, 2014 if (sendTo ~= "") then to if sendTo then Thanks man that worked. Thank you so much for helping. There are so many friendly people on here. Have a good night/day. 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