etlegacy-lua-scripts/pm/pm.lua

34 lines
1.2 KiB
Lua
Raw Normal View History

2014-02-08 17:36:06 +00:00
-- Private message
2014-02-08 17:36:06 +00:00
function et_ClientCommand(id, command)
if string.lower( et.trap_Argv(0) ) == "pm" then
if tonumber( et.trap_Argc ) < 3 then
et.trap_SendServerCommand( id, "chat \"Usage: pm name message\"" )
return(1)
end
2014-02-08 17:36:06 +00:00
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 = et.gentity_get( i, "pers.netname" )
2014-02-08 17:36:06 +00:00
if recipient_name then
local sender_name = et.gentity_get( id, "pers.netname" )
s, e = string.find( string.lower( et.Q_CleanStr( player_name ) ), recipient_name )
2014-02-08 17:36:06 +00:00
if s and e then
if i ~= id then -- PMing yourself?
et.trap_SendServerCommand( i, "chat \"" .. sender_name .. "^7 -> " .. player_name .. "^7: ^5" .. et.ConcatArgs(2) .. "\"" )
end
et.trap_SendServerCommand( id, "chat \"" .. sender_name .. "^7 -> " .. player_name .. "^7: ^5" .. et.ConcatArgs(2) .. "\"" )
2014-02-08 17:36:06 +00:00
return(1) -- send only to the first player matched
end
end
end
et.trap_SendServerCommand( id, "chat \"No player whose name matches the pattern \'" .. recipient_name .. "\' was found.\"" )
return(1)
2014-02-08 17:36:06 +00:00
end
end
end