Click here to Skip to main content
15,890,609 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
What I got so far is not much I have been struggling to find the answer.
I need it to allow private messages by typing /pm username message

function Drsgrgsg(pl, text, teamonly)
if text:find( "/pm" ) then
for k,dhdddh in pairs(player.GetAll()) do
if string.sub( text, 5 , 13 )  == dhdddh:Name()	then

PrintMessage( HUD_PRINTTALK, "" ..text )-- as a test

end
end
end

hook.Add("PlayerSay", "dthdthsrg", Drsgrgsg)
Posted
Updated 20-Jan-16 6:28am
v3
Comments
CPallini 20-Jan-16 12:03pm    
So, what is the problem?
Member 12276450 20-Jan-16 17:52pm    
solved didn't notice the comment.

1 solution

Got it almost 100% working --

for Garry's Mod Private messaging chat command /pm

/pm username message

-- message hides from everyone else in server except the
username.

serverside code -
Python
function Drsgrgsgg(pl, text, teamonly)
if text:find( "/pm" ) then
for k,dhdddh in pairs(player.GetAll()) do
pl:SetNWInt("rsgggg", text)
local sgsg = pl:Name()
if string.match( string.Replace( text, "/pm", "" ), "[%a+]" , 1 )  == string.match( string.lower( dhdddh:Name() ), "[%a+]" , 1 ) 
or string.match( string.Replace( text, "/pm", "" ), "[%a+]" , 1 )  == string.match( dhdddh:Name() , "[%a+]" , 1 )	then
pl:SetNWInt("srhhr", pl:Name()) -- sender
util.AddNetworkString("dthrsrhrhd") -- gm_initialize
net.Start( "dthrsrhrhd", false ) 
net.WriteString( pl:GetNWInt("rsgggg") ) 
net.Send( dhdddh ) 
pl:SetNWInt("rsggsgrsggg", dhdddh:Name())
//print( "teset",dhdddh:Name() )
//print( "msg", pl:GetNWInt("rsgggg"))
end
end
end
end
hook.Add("PlayerSay", "dthdthsrgf", Drsgrgsgg)




// BELOW IS CLIENTSIDE CODE
local function Grhrdhrdhrdh(len, ply)
local ghrhh = net.ReadString()  -- use the same number of bits that were written
//print( "Player ", " is " .. ghrhh .. " .")
chat.AddText( Color( 255, 255, 255 ), string.Replace( ghrhh, "/pm", "[PM Recieved]" ) ) 
end
net.Receive( "dthrsrhrhd", Grhrdhrdhrdh ) 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900