- 1,788
- 2,141
Описание: обычный sampRegisterChatCommand, но с возможностью регистрации сразу нескольких команд на один обработчик. И то же самое для удаления.
Пример использования:
Lua:
local originalSampRegisterChatCommand = sampRegisterChatCommand
local originalSampUnregisterChatCommand = sampUnregisterChatCommand
function sampRegisterChatCommand(commands, callback)
if type(commands) == "table" then
local all_registered = true
for i, v in ipairs(commands) do
local temp = originalSampRegisterChatCommand(v, callback)
all_registered = all_registered and temp
end
return all_registered
else
return originalSampRegisterChatCommand(commands, callback)
end
end
function sampUnregisterChatCommand(commands)
if type(commands) == "table" then
local all_unregistered = true
for i, v in ipairs(commands) do
local temp = originalSampUnregisterChatCommand(v)
all_unregistered = all_unregistered and temp
end
return all_unregistered
else
return originalSampUnregisterChatCommand(commands)
end
end
Lua:
sampRegisterChatCommand({"command", "cmd", "cm", "comm"}, function()
sampAddChatMessage("Hello world, how are you?", -1)
end)