Jump to content

Help me


Dimos7

Recommended Posts

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
  
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
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 by Guest
Link to comment
  
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
  • 2 months later...
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...