Jump to content

[Question]


ZeyadGTX

Recommended Posts

Posted
function randomname(theMessage --[[Message]], thePlayer --[[The player where the message is send to]]) 
--You can do the rest. (source = the player who send the message 
end 
  
addEventHandler("onPlayerPrivateMessage", getRootElement(), randomname) 

Good luck, you should try to make it by yourself.

Posted

you mean like this ? , i don't understand :(

function PM(theMessage, thePlayer) 
--You can do the rest. (source = the player who send the message 
end 
  
addEventHandler("onPlayerPrivateMessage", getRootElement(), randomname) 

Posted
function PM(theMessage, thePlayer) 
    outputServerLog("From: "..getPlayerName(source).." to: "..getPlayerName(thePlayer)..": "..theMessage) 
end 
  
addEventHandler("onPlayerPrivateMessage", getRootElement(), PM) 

Next script not helping. Go read and learn the link he posted above my post.

Posted

i tried this script server side and client not working , i have and this is my Pm system

but ican't read others Pms

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("#FF4646(WHISPER) To ".. toColor .. getPlayerName(toPlayer) .. ":#FFFFFF " .. pmMessage, thePlayer, 255, 255, 255, true) 
                    outputChatBox("#FF4646(WHISPER) From " .. fromColor .. getPlayerName(thePlayer) .. ":#FFFFFF " .. pmMessage, toPlayer, 255, 255, 255, true) 
                else 
                    outputChatBox("#FF4646(WHISPER)#FFFFFF Invalid syntax! Usage:#FFFFFF /pm [player name] [message]", thePlayer, 255, 255, 255, true) 
                    return false 
                end 
            else 
                outputChatBox("#0044FF(WHISPER)#FFFFFF You cannot Whisper yourself#FFFFFF!", thePlayer, 255, 255, 255, true) 
                return false 
            end 
        else 
            outputChatBox("#0044FF(WHISPER)#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) 
addCommandHandler("w", 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 

Posted

No, that script I posted have to be serverside, because onPlayerPrivateMessage is serverside only. e.e So that would be why it's not working.

Posted
any way its not working in Serverside too

Checked the server log files? Anyway I just used the code one of the people posted here. If there is nothing in the server log files, then change onPlayerPrivateMessage to onPlayerChat , then it should work. :)

Posted
function PM(theMessage, thePlayer) 
    outputServerLog("From: "..getPlayerName(source).." to: "..getPlayerName(thePlayer)..": "..theMessage) 
end 
  
addEventHandler("onPlayerChat", getRootElement(), PM) 

Posted
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("#FF4646(WHISPER) To ".. toColor .. getPlayerName(toPlayer) .. ":#FFFFFF " .. pmMessage, thePlayer, 255, 255, 255, true) 
                    outputChatBox("#FF4646(WHISPER) From " .. fromColor .. getPlayerName(thePlayer) .. ":#FFFFFF " .. pmMessage, toPlayer, 255, 255, 255, true) 
            outputServerLog("(WHISPER) From "..getPlayerName(thePlayer).." To ".. getPlayerName(toPlayer)..": " .. pmMessage) 
             
                else 
                    outputChatBox("#FF4646(WHISPER)#FFFFFF Invalid syntax! Usage:#FFFFFF /pm [player name] [message]", thePlayer, 255, 255, 255, true) 
                    return false 
                end 
            else 
                outputChatBox("#0044FF(WHISPER)#FFFFFF You cannot Whisper yourself#FFFFFF!", thePlayer, 255, 255, 255, true) 
                return false 
            end 
        else 
            outputChatBox("#0044FF(WHISPER)#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) 
addCommandHandler("w", 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 

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...