2021-01-18 13:34:00 -05:00
|
|
|
-----------------------------------
|
2016-08-09 19:05:15 -04:00
|
|
|
-- func: setplayermodel <modelid> <slot> <player>
|
2016-01-16 01:26:33 -05:00
|
|
|
-- desc: Sets the look of the user or target player based on model id offset and slot (for testing).
|
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-01-16 01:26:33 -05: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 = 'iis'
|
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('!setplayermodel <model> <slot> (player)')
|
|
|
|
|
player:printToPlayer('Slots: 0=main 1=sub 2=ranged 3=ammo 4=head 5=body 6=hands 7=legs 8=feet')
|
2020-02-19 21:40:57 -08:00
|
|
|
end
|
2017-08-08 17:23:52 -04:00
|
|
|
|
2023-09-02 07:01:35 -04:00
|
|
|
commandObj.onTrigger = function(player, model, slot, target)
|
2017-08-08 17:23:52 -04:00
|
|
|
-- validate model
|
2022-05-28 14:56:44 -04:00
|
|
|
if model == nil then
|
2023-08-28 21:02:28 -04:00
|
|
|
error(player, 'Invalid model ID.')
|
2020-02-19 21:40:57 -08:00
|
|
|
return
|
2017-08-08 17:23:52 -04:00
|
|
|
end
|
2020-03-19 18:41:42 -07:00
|
|
|
|
2017-08-08 17:23:52 -04:00
|
|
|
-- validate slot
|
2022-05-28 14:56:44 -04:00
|
|
|
if slot == nil or slot < 0 or slot > 8 then
|
2023-08-28 21:02:28 -04:00
|
|
|
error(player, 'Invalid slot ID.')
|
2020-02-19 21:40:57 -08:00
|
|
|
return
|
2016-01-16 01:26:33 -05:00
|
|
|
end
|
|
|
|
|
|
2017-08-08 17:23:52 -04:00
|
|
|
-- validate target
|
2020-02-19 21:40:57 -08:00
|
|
|
local targ
|
2022-05-28 14:56:44 -04:00
|
|
|
if target == nil then
|
2020-02-19 21:40:57 -08:00
|
|
|
targ = player
|
2016-01-16 01:26:33 -05:00
|
|
|
else
|
2021-01-09 08:01:35 +02:00
|
|
|
targ = GetPlayerByName(target)
|
2022-05-28 14:56:44 -04:00
|
|
|
if targ == nil then
|
2023-08-28 21:02:28 -04:00
|
|
|
error(player, string.format('Player named "%s" not found!', target))
|
2020-02-19 21:40:57 -08:00
|
|
|
return
|
2016-01-16 01:26:33 -05:00
|
|
|
end
|
|
|
|
|
end
|
2017-08-08 17:23:52 -04:00
|
|
|
|
2022-05-28 14:56:44 -04:00
|
|
|
local slotNameByNum =
|
|
|
|
|
{
|
2023-08-28 21:02:28 -04:00
|
|
|
[0] = 'main',
|
|
|
|
|
[1] = 'sub',
|
|
|
|
|
[2] = 'ranged',
|
|
|
|
|
[3] = 'ammo',
|
|
|
|
|
[4] = 'head',
|
|
|
|
|
[5] = 'body',
|
|
|
|
|
[6] = 'hands',
|
|
|
|
|
[7] = 'legs',
|
|
|
|
|
[8] = 'feet'
|
2017-08-08 17:23:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-- set model
|
2020-02-19 21:40:57 -08:00
|
|
|
targ:setModelId(model, slot)
|
2023-12-09 23:54:00 +00:00
|
|
|
player:printToPlayer(string.format('Set %s\'s %s slot to model %i.', targ:getName(), slotNameByNum[slot], model))
|
2020-03-19 18:41:42 -07:00
|
|
|
end
|
2023-09-02 07:01:35 -04:00
|
|
|
|
|
|
|
|
return commandObj
|