pm: private messaging

This commit is contained in:
Radegast 2014-02-08 17:36:06 +00:00
parent daba4deb4f
commit 6b313e7e47
2 changed files with 30 additions and 0 deletions

View file

@ -23,3 +23,10 @@ Lua scripts for the Legacy mod
* Game manager, shrubbot and/or ET admin mod replacement
* LuaSQL module with sqlite3 or mysql driver are required
## pm - private messages
* use ```pm``` console command to send a private message to another player
* message is sent to the first matched player name
* player name is a colour and case-insensitive pattern, e.g. ton will match player /-^321ToN-/
* usage: pm player Hello, how are you?

23
pm/pm.lua Normal file
View file

@ -0,0 +1,23 @@
function et_ClientCommand(id, command)
-- Private message
if string.lower( et.trap_Argv(0) ) == "pm" then
local recipient_name = string.lower( et.Q_CleanStr( et.trap_Argv(1) ) )
if recipient_name then
for i=0, tonumber( et.trap_Cvar_Get( "sv_maxclients" ) )-1 do
local player_name = string.lower( et.Q_CleanStr( et.gentity_get( i, "pers.netname" ) ) )
if recipient_name then
local sender_name = et.gentity_get( id, "pers.netname" )
s, e = string.find( player_name, recipient_name )
if s and e then
et.trap_SendServerCommand( i, "chat \"" .. sender_name .. "^7: ^5" .. et.ConcatArgs(2) .. "\" " .. i .. " 0")
return(1) -- send only to the first player matched
end
end
end
end
end
end