2021-01-18 13:34:00 -05:00
|
|
|
-----------------------------------
|
2016-07-29 08:35:15 -06:00
|
|
|
-- func: addeffect
|
2016-01-16 01:26:33 -05:00
|
|
|
-- desc: Adds the given effect to the given player.
|
2021-01-18 13:34:00 -05:00
|
|
|
-----------------------------------
|
2024-08-25 10:54:45 -04:00
|
|
|
---@type TCommand
|
2023-09-02 07:01:35 -04:00
|
|
|
local commandObj = {}
|
2016-05-04 22:32:43 +01:00
|
|
|
|
2023-09-02 07:01:35 -04:00
|
|
|
commandObj.cmdprops =
|
2016-01-16 01:26:33 -05:00
|
|
|
{
|
|
|
|
|
permission = 1,
|
2023-08-28 21:02:28 -04:00
|
|
|
parameters = 'ssssss'
|
2020-02-19 21:40:57 -08:00
|
|
|
}
|
2016-01-16 01:26:33 -05:00
|
|
|
|
2023-09-02 07:01:35 -04:00
|
|
|
local function error(player, msg)
|
2023-12-09 23:54:00 +00:00
|
|
|
player:printToPlayer(msg)
|
|
|
|
|
player:printToPlayer('!addeffect (player) <effect> (power) (duration) (subid) (subPower)')
|
2020-02-19 21:40:57 -08:00
|
|
|
end
|
2017-08-02 14:42:02 -04:00
|
|
|
|
2023-09-02 07:01:35 -04:00
|
|
|
commandObj.onTrigger = function(player, arg1, arg2, arg3, arg4, arg5, arg6)
|
2020-02-19 21:40:57 -08:00
|
|
|
local targ
|
|
|
|
|
local id
|
|
|
|
|
local power
|
|
|
|
|
local duration
|
|
|
|
|
local subId
|
|
|
|
|
local subPower
|
2017-08-02 14:42:02 -04:00
|
|
|
|
2022-11-04 10:44:34 -04:00
|
|
|
if arg1 == nil then
|
2023-08-28 21:02:28 -04:00
|
|
|
error(player, 'Invalid effect.')
|
2020-02-19 21:40:57 -08:00
|
|
|
return
|
2016-01-16 01:26:33 -05:00
|
|
|
else
|
2021-01-09 08:01:35 +02:00
|
|
|
targ = GetPlayerByName(arg1)
|
2022-10-30 09:13:30 -04:00
|
|
|
if targ == nil then
|
2017-08-02 14:42:02 -04:00
|
|
|
-- no valid target given. shift arguments by one.
|
2020-02-19 21:40:57 -08:00
|
|
|
targ = player
|
|
|
|
|
id = arg1
|
|
|
|
|
power = tonumber(arg2) or 1
|
|
|
|
|
duration = tonumber(arg3) or 60
|
|
|
|
|
subId = tonumber(arg4) or 0
|
|
|
|
|
subPower = tonumber(arg5) or 0
|
2016-01-16 01:26:33 -05:00
|
|
|
else
|
2017-08-02 14:42:02 -04:00
|
|
|
-- valid target found. assign arguments as usual
|
2020-02-19 21:40:57 -08:00
|
|
|
id = arg2
|
|
|
|
|
power = tonumber(arg3) or 1
|
|
|
|
|
duration = tonumber(arg4) or 60
|
|
|
|
|
subId = tonumber(arg5) or 0
|
|
|
|
|
subPower = tonumber(arg6) or 0
|
2016-01-16 01:26:33 -05:00
|
|
|
end
|
2017-08-02 14:42:02 -04:00
|
|
|
end
|
2016-01-16 01:26:33 -05:00
|
|
|
|
2017-08-02 14:42:02 -04:00
|
|
|
-- validate effect
|
2022-11-02 15:41:32 -04:00
|
|
|
if id == nil then
|
2023-08-28 21:02:28 -04:00
|
|
|
error(player, 'Invalid effect.')
|
2020-02-19 21:40:57 -08:00
|
|
|
return
|
2017-08-02 14:42:02 -04:00
|
|
|
else
|
2021-04-01 15:10:15 -04:00
|
|
|
id = tonumber(id) or xi.effect[string.upper(id)]
|
2022-11-02 15:41:32 -04:00
|
|
|
if id == nil then
|
2023-08-28 21:02:28 -04:00
|
|
|
error(player, 'Invalid player or effect.')
|
2020-02-19 21:40:57 -08:00
|
|
|
return
|
2016-01-16 01:26:33 -05:00
|
|
|
end
|
2017-08-02 14:42:02 -04:00
|
|
|
end
|
2018-04-02 06:21:47 -04:00
|
|
|
|
2017-08-02 14:42:02 -04:00
|
|
|
-- validate power
|
2022-11-02 15:41:32 -04:00
|
|
|
if power < 0 then
|
2023-08-28 21:02:28 -04:00
|
|
|
error(player, 'Invalid power.')
|
2020-02-19 21:40:57 -08:00
|
|
|
return
|
2017-08-02 14:42:02 -04:00
|
|
|
end
|
2018-04-02 06:21:47 -04:00
|
|
|
|
2017-08-02 14:42:02 -04:00
|
|
|
-- validate duration
|
2022-11-02 15:41:32 -04:00
|
|
|
if duration < 0 then
|
2023-08-28 21:02:28 -04:00
|
|
|
error(player, 'Invalid duration.')
|
2020-02-19 21:40:57 -08:00
|
|
|
return
|
2017-08-02 14:42:02 -04:00
|
|
|
end
|
2016-01-16 01:26:33 -05:00
|
|
|
|
2017-08-02 14:42:02 -04:00
|
|
|
-- validate subId
|
2022-11-02 15:41:32 -04:00
|
|
|
if subId < 0 then
|
2023-08-28 21:02:28 -04:00
|
|
|
error(player, 'Invalid subId.')
|
2020-02-19 21:40:57 -08:00
|
|
|
return
|
2017-08-02 14:42:02 -04:00
|
|
|
end
|
2016-01-16 01:26:33 -05:00
|
|
|
|
2017-08-02 14:42:02 -04:00
|
|
|
-- validate subPower
|
2022-11-02 15:41:32 -04:00
|
|
|
if subPower < 0 then
|
2023-08-28 21:02:28 -04:00
|
|
|
error(player, 'Invalid subPower.')
|
2020-02-19 21:40:57 -08:00
|
|
|
return
|
2016-01-16 01:26:33 -05:00
|
|
|
end
|
|
|
|
|
|
2017-08-02 14:42:02 -04:00
|
|
|
-- add effect
|
2026-02-19 22:48:02 -07:00
|
|
|
if targ:addStatusEffect(id, { power = power, duration = duration, origin = player, tick = 3, subType = subId, subPower = subPower }) then
|
2020-02-19 21:40:57 -08:00
|
|
|
targ:messagePublic(280, targ, id, id)
|
2016-01-16 01:26:33 -05:00
|
|
|
else
|
2020-02-19 21:40:57 -08:00
|
|
|
targ:messagePublic(283, targ, id)
|
2016-01-16 01:26:33 -05:00
|
|
|
end
|
2020-03-19 18:41:42 -07:00
|
|
|
end
|
2023-09-02 07:01:35 -04:00
|
|
|
|
|
|
|
|
return commandObj
|