如何在聊天框中找到玩家姓名?我需要帮助聊天中的私人消息。 [英] How do I find a player name in chat box? I need help with private messaging in chat.

查看:147
本文介绍了如何在聊天框中找到玩家姓名?我需要帮助聊天中的私人消息。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止我得到的并不多,我一直在努力寻找答案。

我需要通过键入/ pm用户名消息来允许私信消息



<前lang =text>函数Drsgrgsg(pl,text,teamonly)
if text:find(/ pm)然后
表示k,dhdddh成对( player.GetAll())如果string.sub(text,5,13)== dhdddh:Name()然后

PrintMessage(HUD_PRINTTALK,.. text) - 执行
作为测试

结束
结束
结束

hook.Add(PlayerSay,dthdthsrg,Drsgrgsg)

解决方案

几乎100%正常工作 -



for Garry的Mod私聊消息聊天命令/下午



/ pm用户名消息



- 来自服务器中其他人的消息隐藏,除了

用户名。



服务器端代码 -

函数Drsgrgsgg(pl,text, teamonly)
if text:find( / pm)然后
k,dhdddh 对(player.GetAll())执行
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
< span class =code-keyword>或 string.match(string.Replace(text, / pm ), [%a +] 1 )== string.match(dhdddh:Name(), [%a +] 1 )然后
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)




//以下是客户代码
本地函数Grhrdhrdhrdh (len,ply)
local ghrhh = net.ReadString() - 使用相同数量的位写入
// print( 播放器 。 .ghhr .. ..
chat.AddText(Color( 255 255 255 ),string.Replace(ghrhh , / pm [PM Recieved]))
end
net.Receive( dthrsrhrhd,Grhrdhrdhrdh)


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)

解决方案

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 -

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 ) 


这篇关于如何在聊天框中找到玩家姓名?我需要帮助聊天中的私人消息。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆