mirror of
https://github.com/etlegacy/wolfadmin.git
synced 2024-11-25 05:31:41 +00:00
Implemented /pm and /r for legacymod (refs #46)
This commit is contained in:
parent
99817beb31
commit
3231ea6c74
2 changed files with 90 additions and 33 deletions
|
@ -21,6 +21,8 @@ local commands = require (wolfa_getLuaPath()..".commands.commands")
|
||||||
|
|
||||||
local players = require (wolfa_getLuaPath()..".players.players")
|
local players = require (wolfa_getLuaPath()..".players.players")
|
||||||
|
|
||||||
|
local settings = require (wolfa_getLuaPath()..".util.settings")
|
||||||
|
|
||||||
function commandPersonalMessage(clientId, cmdArguments)
|
function commandPersonalMessage(clientId, cmdArguments)
|
||||||
if #cmdArguments > 1 then
|
if #cmdArguments > 1 then
|
||||||
local cmdClient
|
local cmdClient
|
||||||
|
@ -38,5 +40,56 @@ function commandPersonalMessage(clientId, cmdArguments)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
commands.addclient("pm", commandPersonalMessage, "", "", true)
|
commands.addclient("pm", commandPersonalMessage, "", "", true, (settings.get("fs_game") ~= "legacy"))
|
||||||
commands.addclient("m", commandPersonalMessage, "", "", true)
|
commands.addclient("m", commandPersonalMessage, "", "", true, (settings.get("fs_game") ~= "legacy"))
|
||||||
|
|
||||||
|
function commandPersonalMessage(clientId, cmdArguments)
|
||||||
|
if #cmdArguments == 0 then
|
||||||
|
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^9usage: "..commands.getclient("pm")["syntax"].."\";")
|
||||||
|
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
local cmdClient
|
||||||
|
|
||||||
|
if tonumber(cmdArguments[1]) == nil or tonumber(cmdArguments[1]) > tonumber(et.trap_Cvar_Get("sv_maxclients")) then
|
||||||
|
cmdClient = et.ClientNumberFromString(cmdArguments[1])
|
||||||
|
else
|
||||||
|
cmdClient = tonumber(cmdArguments[1])
|
||||||
|
end
|
||||||
|
|
||||||
|
if cmdClient == -1 or cmdClient == nil then
|
||||||
|
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^9pm: ^7no or multiple matches for '^7"..cmdArguments[1].."^9'.\";")
|
||||||
|
|
||||||
|
return true
|
||||||
|
elseif not et.gentity_get(cmdClient, "pers.netname") then
|
||||||
|
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dpm: ^7no connected player by that name or slot #\";")
|
||||||
|
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
local message, messageConcatenated = {}, ""
|
||||||
|
|
||||||
|
for i = 1, #cmdArguments do
|
||||||
|
message[i] = cmdArguments[i]
|
||||||
|
end
|
||||||
|
|
||||||
|
messageConcatenated = table.concat(message, " ")
|
||||||
|
|
||||||
|
if cmdClient ~= -1 and et.gentity_get(cmdClient, "pers.netname") then
|
||||||
|
players.setLastPMSender(cmdClient, clientId)
|
||||||
|
|
||||||
|
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat "..clientId.." \"^7"..et.gentity_get(clientId, "pers.netname").."^7 -> "..cmdArguments[1].."^7: (1 recipients): ^3"..messageConcatenated.."\";")
|
||||||
|
et.trap_SendConsoleCommand(et.EXEC_APPEND, "playsound "..clientId.." \"sound/misc/pm.wav\";")
|
||||||
|
|
||||||
|
if clientId ~= cmdClient then
|
||||||
|
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat "..cmdClient.." \"^7"..et.gentity_get(clientId, "pers.netname").."^7 -> "..cmdArguments[1].."^7: (1 recipients): ^3"..messageConcatenated.."\";")
|
||||||
|
et.trap_SendConsoleCommand(et.EXEC_APPEND, "playsound "..cmdClient.." \"sound/misc/pm.wav\";")
|
||||||
|
end
|
||||||
|
|
||||||
|
et.trap_SendConsoleCommand(et.EXEC_APPEND, "ccp "..cmdClient.." \"^3private message from "..et.gentity_get(clientId, "pers.netname").."\";")
|
||||||
|
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..cmdClient.." \"^9reply: ^7r [^2message^7]\";")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
commands.addclient("pm", commandPersonalMessage, "", "", true, (settings.get("fs_game") == "legacy"))
|
||||||
|
commands.addclient("m", commandPersonalMessage, "", "", true, (settings.get("fs_game") == "legacy"))
|
||||||
|
|
|
@ -24,35 +24,39 @@ local players = require (wolfa_getLuaPath()..".players.players")
|
||||||
function commandR(clientId, cmdArguments)
|
function commandR(clientId, cmdArguments)
|
||||||
if #cmdArguments == 0 then
|
if #cmdArguments == 0 then
|
||||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^9usage: "..commands.getclient("r")["syntax"].."\";")
|
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^9usage: "..commands.getclient("r")["syntax"].."\";")
|
||||||
else
|
|
||||||
local recipient = players.getLastPMSender(clientId)
|
|
||||||
|
|
||||||
if not (recipient and et.gentity_get(recipient, "pers.netname")) then
|
return true
|
||||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"player not found\";")
|
|
||||||
else
|
|
||||||
local message, messageConcatenated = {}, ""
|
|
||||||
|
|
||||||
for i = 1, #cmdArguments do
|
|
||||||
message[i] = cmdArguments[i]
|
|
||||||
end
|
|
||||||
|
|
||||||
messageConcatenated = table.concat(message, " ")
|
|
||||||
|
|
||||||
players.setLastPMSender(recipient, clientId)
|
|
||||||
|
|
||||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat "..clientId.." \"^7"..et.gentity_get(clientId, "pers.netname").."^7 -> "..recipient..": (1 recipients): ^3"..messageConcatenated.."\";")
|
|
||||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "playsound "..clientId.." \"sound/misc/pm.wav\";")
|
|
||||||
|
|
||||||
if clientId ~= recipient then
|
|
||||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat "..recipient.." \"^7"..et.gentity_get(clientId, "pers.netname").."^7 -> "..recipient..": (1 recipients): ^3"..messageConcatenated.."\";")
|
|
||||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "playsound "..clientId.." \"sound/misc/pm.wav\";")
|
|
||||||
end
|
|
||||||
|
|
||||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "ccp "..recipient.." \"^3private message from "..et.gentity_get(clientId, "pers.netname").."\";")
|
|
||||||
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..recipient.." \"^9reply: ^7r [^2message^7]\";")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local recipient = players.getLastPMSender(clientId)
|
||||||
|
|
||||||
|
if not (recipient and et.gentity_get(recipient, "pers.netname")) then
|
||||||
|
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"player not found\";")
|
||||||
|
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
local message, messageConcatenated = {}, ""
|
||||||
|
|
||||||
|
for i = 1, #cmdArguments do
|
||||||
|
message[i] = cmdArguments[i]
|
||||||
|
end
|
||||||
|
|
||||||
|
messageConcatenated = table.concat(message, " ")
|
||||||
|
|
||||||
|
players.setLastPMSender(recipient, clientId)
|
||||||
|
|
||||||
|
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat "..clientId.." \"^7"..et.gentity_get(clientId, "pers.netname").."^7 -> "..recipient..": (1 recipients): ^3"..messageConcatenated.."\";")
|
||||||
|
et.trap_SendConsoleCommand(et.EXEC_APPEND, "playsound "..clientId.." \"sound/misc/pm.wav\";")
|
||||||
|
|
||||||
|
if clientId ~= recipient then
|
||||||
|
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat "..recipient.." \"^7"..et.gentity_get(clientId, "pers.netname").."^7 -> "..recipient..": (1 recipients): ^3"..messageConcatenated.."\";")
|
||||||
|
et.trap_SendConsoleCommand(et.EXEC_APPEND, "playsound "..recipient.." \"sound/misc/pm.wav\";")
|
||||||
|
end
|
||||||
|
|
||||||
|
et.trap_SendConsoleCommand(et.EXEC_APPEND, "ccp "..recipient.." \"^3private message from "..et.gentity_get(clientId, "pers.netname").."\";")
|
||||||
|
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..recipient.." \"^9reply: ^7r [^2message^7]\";")
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
commands.addclient("r", commandR, "", "[^2message^7]", true)
|
commands.addclient("r", commandR, "", "[^2message^7]", true)
|
||||||
|
|
Loading…
Reference in a new issue