2014-02-08 17:36:06 +00:00
|
|
|
|
2014-02-12 23:54:18 +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
|
2014-02-12 23:54:18 +00:00
|
|
|
|
|
|
|
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
|
2014-02-08 21:03:05 +00:00
|
|
|
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" )
|
2014-02-08 21:03:05 +00:00
|
|
|
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
|
2014-02-08 21:03:05 +00:00
|
|
|
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
|
2014-02-08 21:03:05 +00:00
|
|
|
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
|