Dimos7 Posted March 28, 2016 Share Posted March 28, 2016 function getPlayerFromPatrialName(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 function privateMessage(thePlayer, sendToName, ...) local message = table.concat({...}, "") if sendToName then if (getPlayerFromPatrialName(sendToName)) then toPlayer = (getPlayerFromPatrialName(sendToName)) if not toPlayer == thePlayer then if not message == "" then outputChatBox("#18BC5BPM to "..getPlayerName(toPlayer)..":#FFFFFF "..message, thePlayer, 255, 255, 255, true) outputChatBox("#18BC5BPM from"..getPlayerName(thePlayer)..":#FFFFFF "..message, toPlayer, 255, 255, 255, true) outputChatBox("#18BC5BPM Use /reply [message]", toPlayer, 255, 255, 255, true) setElementData(thePlayer, "pmPartner", toPlayer) setElementData(toPlayer, "pmPartner", thePlayer) else outputChatBox("Use /pm [part of name] [message]", thePlayer, 255, 0, 0) return false end else outputChatBox("You cannot pm to yourself!", thePlayer, 255, 0, 0) return false end else outputChatBox("Player not found!", thePlayer, 255, 0, 0) return false end else outputChatBox("Use /pm [part of name] [message]", thePlayer, 255, 0, 0) return false end end addCommandHandler("pm", privateMessage) function privateMessageReply(thePlayer, ...) local message table.concat({...}, "") local toPlayer = getElementData(thePlayer, "pmPartner") if toPlayer then if not message == "" then outputChatBox("#18BC5BPM to".. getPlayerName(toPlayer)..":#FFFFFF "..message, thePlayer, 255, 255, 255, true) outputChatBox("#18BC5BPM from"..getPlayerName(thePlayer)..":#FFFFFF"..message, toPlayer, 255, 255, 255, true) outputChatBox("#18BC5BPM Use /reply [message]", toPlayer, 255, 255, 255, true) else outputChatBox("Use /reply [message]", thePlayer, 255, 0, 0) return false end else outputChatBox("No partner has been found!", thePlayer, 255, 0, 0) return false end end addCommandHandler("reply", privateMessageReply) no error or warning just only appear not player found wihtout put a player Link to comment
Anubhav Posted March 29, 2016 Share Posted March 29, 2016 function getPlayerFromPatrialName(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 function privateMessage(thePlayer, _, sendToName, ...) local message = table.concat({...}, "") if sendToName then if (getPlayerFromPatrialName(sendToName)) then toPlayer = (getPlayerFromPatrialName(sendToName)) if not toPlayer == thePlayer then if not message == "" then outputChatBox("#18BC5BPM to "..getPlayerName(toPlayer)..":#FFFFFF "..message, thePlayer, 255, 255, 255, true) outputChatBox("#18BC5BPM from"..getPlayerName(thePlayer)..":#FFFFFF "..message, toPlayer, 255, 255, 255, true) outputChatBox("#18BC5BPM Use /reply [message]", toPlayer, 255, 255, 255, true) setElementData(thePlayer, "pmPartner", toPlayer) setElementData(toPlayer, "pmPartner", thePlayer) else outputChatBox("Use /pm [part of name] [message]", thePlayer, 255, 0, 0) return false end else outputChatBox("You cannot pm to yourself!", thePlayer, 255, 0, 0) return false end else outputChatBox("Player not found!", thePlayer, 255, 0, 0) return false end else outputChatBox("Use /pm [part of name] [message]", thePlayer, 255, 0, 0) return false end end addCommandHandler("pm", privateMessage) function privateMessageReply(thePlayer,_, ...) local message table.concat({...}, "") local toPlayer = getElementData(thePlayer, "pmPartner") if toPlayer then if not message == "" then outputChatBox("#18BC5BPM to".. getPlayerName(toPlayer)..":#FFFFFF "..message, thePlayer, 255, 255, 255, true) outputChatBox("#18BC5BPM from"..getPlayerName(thePlayer)..":#FFFFFF"..message, toPlayer, 255, 255, 255, true) outputChatBox("#18BC5BPM Use /reply [message]", toPlayer, 255, 255, 255, true) else outputChatBox("Use /reply [message]", thePlayer, 255, 0, 0) return false end else outputChatBox("No partner has been found!", thePlayer, 255, 0, 0) return false end end addCommandHandler("reply", privateMessageReply) Link to comment
Dimos7 Posted April 1, 2016 Author Share Posted April 1, 2016 (edited) function getPlayerFromPatrialName(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 function privateMessage(thePlayer, _, sendToName, ...) local message = table.concat({...}, "") if sendToName then if (getPlayerFromPatrialName(sendToName)) then toPlayer = (getPlayerFromPatrialName(sendToName)) if toPlayer ~= thePlayer then if message ~= "" then outputChatBox("#18CB5BPM to "..getPlayerName(toPlayer)..":#FFFFFF "..message, thePlayer, 255, 255, 255, true) outputChatBox("#18CB5BPM from "..getPlayerName(thePlayer)..":#FFFFFF "..message, toPlayer, 255, 255, 255, true) outputServerLog("#18CB5BPM to "..getPlayerName(toPlayer)..":#FFFFFF "..message) outputServerLog("#18CB5BPM from "..getPlayerName(thePlayer).."#FFFFFF "..message) outputChatBox("#18CB5B /reply [message]", toPlayer, 255, 255, 255, true) setElementData(thePlayer, "pmPartner", toPlayer) setElementData(toPlayer, "pmPartner", thePlayer) else outputChatBox("Use /pm [part of name] [message]", thePlayer, 255, 0, 0) return false end else outputChatBox("You cannot pm to yourself!", thePlayer, 255, 0, 0) return false end else outputChatBox("Player not found!", thePlayer, 255, 0, 0) return false end else outputChatBox("Use /pm [part of name] [message]", thePlayer, 255, 0, 0) return false end end addCommandHandler("pm", privateMessage) function privateMessageReply(thePlayer, _, ...) local message = table.concat({...}, "") local toPlayer = getElementData(thePlayer, "pmPartner") if toPlayer then if message ~= "" then outputChatBox("#18CB5BPM to "..getPlayerName(toPlayer)..":#FFFFFF "..message, thePlayer, 255, 255, 255, true) outputChatBox("#18CB5BPM from "..getPlayerName(thePlayer)..":#FFFFFF "..message, toPlayer, 255, 255, 255, true) outputServerLog("#18CB5BPM to "..getPlayerName(toPlayer)..":#FFFFFF "..message) outputServerLog("#18CB5BPM from "..getPlayerName(thePlayer)..":#FFFFFF "..message) outputChatBox("#18CB5B /reply [message]", toPlayer, 255, 255, 255, true) else outputChatBox("Use /reply [message]", thePlayer, 255, 0, 0) return false end else outputChatBox("None is pmming you!", thePlayer, 255, 0, 0) return false end end addCommandHandler("reply", privateMessageReply) Now there is another problem whan i pm to a different person say you cannot speak to yourself Edited April 1, 2016 by Guest Link to comment
Anubhav Posted April 1, 2016 Share Posted April 1, 2016 function getPlayerFromPatrialName(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 function privateMessage(thePlayer, _, sendToName, id, ...) local message = table.concat({...}, "") if sendToName then if (getPlayerFromPatrialName(sendToName)) then toPlayer = getPlayerFromPatrialName(sendToName) if toPlayer ~= thePlayer then if message ~= "" then outputChatBox("#18CB5BPM to "..getPlayerName(toPlayer)..":#FFFFFF "..message, thePlayer, 255, 255, 255, true) outputChatBox("#18CB5BPM from "..getPlayerName(thePlayer)..":#FFFFFF "..message, toPlayer, 255, 255, 255, true) outputServerLog("#18CB5BPM to "..getPlayerName(toPlayer)..":#FFFFFF "..message) outputServerLog("#18CB5BPM from "..getPlayerName(thePlayer).."#FFFFFF "..message) outputChatBox("#18CB5B /reply [message]", toPlayer, 255, 255, 255, true) setElementData(thePlayer, "pmPartner", toPlayer) setElementData(toPlayer, "pmPartner", thePlayer) else outputChatBox("Use /pm [part of name] [message]", thePlayer, 255, 0, 0) return false end else outputChatBox("You cannot pm to yourself!", thePlayer, 255, 0, 0) return false end else outputChatBox("Player not found!", thePlayer, 255, 0, 0) return false end else outputChatBox("Use /pm [part of name] [message]", thePlayer, 255, 0, 0) return false end end addCommandHandler("pm", privateMessage) function privateMessageReply(thePlayer, _, ...) local message = table.concat({...}, "") local toPlayer = getElementData(thePlayer, "pmPartner") if toPlayer then if message ~= "" then outputChatBox("#18CB5BPM to "..getPlayerName(toPlayer)..":#FFFFFF "..message, thePlayer, 255, 255, 255, true) outputChatBox("#18CB5BPM from "..getPlayerName(thePlayer)..":#FFFFFF "..message, toPlayer, 255, 255, 255, true) outputServerLog("#18CB5BPM to "..getPlayerName(toPlayer)..":#FFFFFF "..message) outputServerLog("#18CB5BPM from "..getPlayerName(thePlayer)..":#FFFFFF "..message) outputChatBox("#18CB5B /reply [message]", toPlayer, 255, 255, 255, true) else outputChatBox("Use /reply [message]", thePlayer, 255, 0, 0) return false end else outputChatBox("None is pmming you!", thePlayer, 255, 0, 0) return false end end addCommandHandler("reply", privateMessageReply) Link to comment
Dimos7 Posted June 30, 2016 Author Share Posted June 30, 2016 function getPlayerFromPatrialName(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 function privateMessage(thePlayer, _, sendToName, ...) local message = table.concat({...}, "") if sendToName then if (getPlayerFromPatrialName(sendToName)) then toPlayer = getPlayerFromPatrialName(sendToName) if toPlayer ~= thePlayer then if message ~= "" then outputChatBox("#18CB5BPM to "..getPlayerName(toPlayer)..":#FFFFFF "..message, thePlayer, 255, 255, 255, true) outputChatBox("#18CB5BPM from "..getPlayerName(thePlayer)..":#FFFFFF "..message, toPlayer, 255, 255, 255, true) outputServerLog("#18CB5BPM to "..getPlayerName(toPlayer)..":#FFFFFF "..message) outputServerLog("#18CB5BPM from "..getPlayerName(thePlayer).."#FFFFFF "..message) outputChatBox("#18CB5B /reply [message]", toPlayer, 255, 255, 255, true) setElementData(thePlayer, "pmPartner", toPlayer) setElementData(toPlayer, "pmPartner", thePlayer) else outputChatBox("Use /pm [part of name] [message]", thePlayer, 255, 0, 0) return false end else outputChatBox("You cannot pm to yourself!", thePlayer, 255, 0, 0) return false end else outputChatBox("Player not found!", thePlayer, 255, 0, 0) return false end else outputChatBox("Use /pm [part of name] [message]", thePlayer, 255, 0, 0) return false end end addCommandHandler("pm", privateMessage) function privateMessageReply(thePlayer, _, ...) local message = table.concat({...}, "") local toPlayer = getElementData(thePlayer, "pmPartner") if toPlayer then if message ~= "" then outputChatBox("#18CB5BPM to "..getPlayerName(toPlayer)..":#FFFFFF "..message, thePlayer, 255, 255, 255, true) outputChatBox("#18CB5BPM from "..getPlayerName(thePlayer)..":#FFFFFF "..message, toPlayer, 255, 255, 255, true) outputServerLog("#18CB5BPM to "..getPlayerName(toPlayer)..":#FFFFFF "..message) outputServerLog("#18CB5BPM from "..getPlayerName(thePlayer)..":#FFFFFF "..message) outputChatBox("#18CB5B /reply [message]", toPlayer, 255, 255, 255, true) else outputChatBox("Use /reply [message]", thePlayer, 255, 0, 0) return false end else outputChatBox("None is pmming you!", thePlayer, 255, 0, 0) return false end end addCommandHandler("reply", privateMessageReply) i press space for a message and send it without space why? Link to comment
Tails Posted June 30, 2016 Share Posted June 30, 2016 i press space for a message and send it without space why? local message = table.concat({...}, " ") not "" but " " will add a space between every word. "," would add a comma between every word. "" adds nothing. 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