Hey,
Recently had a thought if the create item and create monster talkactions could have the option to spawn multiple items/monsters at once. As standard to spawn multiple with the command the ids/names would be seperated by a comma. Additionally for the create monster talkaction to also contain the "count" option.
E.g. "/m demon, rat, cat, dog" etc. same with "/i demon helmet, demon armor, demon legs"
E.g "/m demon (5), rat (3), cat (10), dog (2)" "/i demon helmet (2), demon armor (2), demon legs (2)"
How heavy of an edit would this be? Is it possible? I imagine these days it wouldn't cause any server issues or would it? Anyone willing to spend their time to do it?
Here's the default code for both. FYI these are the revscriptsys versions. TFS 1.3.
create monster:
create item:
Let me know your thoughts!
Recently had a thought if the create item and create monster talkactions could have the option to spawn multiple items/monsters at once. As standard to spawn multiple with the command the ids/names would be seperated by a comma. Additionally for the create monster talkaction to also contain the "count" option.
E.g. "/m demon, rat, cat, dog" etc. same with "/i demon helmet, demon armor, demon legs"
E.g "/m demon (5), rat (3), cat (10), dog (2)" "/i demon helmet (2), demon armor (2), demon legs (2)"
How heavy of an edit would this be? Is it possible? I imagine these days it wouldn't cause any server issues or would it? Anyone willing to spend their time to do it?
Here's the default code for both. FYI these are the revscriptsys versions. TFS 1.3.
create monster:
Lua:
local createMonster = TalkAction("/m")
function createMonster.onSay(player, words, param)
if not player:getGroup():getAccess() or player:getAccountType() < ACCOUNT_TYPE_GOD then
return true
end
if param == "" then
player:sendCancelMessage("Command param required.")
return false
end
local position = player:getPosition()
local monster = Game.createMonster(param, position)
if monster then
monster:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
position:sendMagicEffect(CONST_ME_MAGIC_RED)
else
player:sendCancelMessage("There is not enough room.")
position:sendMagicEffect(CONST_ME_POFF)
end
return false
end
createMonster:separator(" ")
createMonster:register()
create item:
Lua:
local invalidIds = {
1, 2, 3, 4, 5, 6, 7, 10, 11, 13, 14, 15, 19, 21, 26, 27, 28, 35, 43
}
local createItem = TalkAction("/i")
function createItem.onSay(player, words, param)
if not player:getGroup():getAccess() or player:getAccountType() < ACCOUNT_TYPE_GOD then
return true
end
local split = param:split(",")
local itemType = ItemType(split[1])
if itemType:getId() == 0 then
itemType = ItemType(tonumber(split[1]))
if not tonumber(split[1]) or itemType:getId() == 0 then
player:sendCancelMessage("There is no item with that id or name.")
return false
end
end
if table.contains(invalidIds, itemType:getId()) then
return false
end
local count = tonumber(split[2])
if count then
if itemType:isStackable() then
count = math.min(10000, math.max(1, count))
elseif not itemType:isFluidContainer() then
count = math.min(100, math.max(1, count))
else
count = math.max(0, count)
end
else
if not itemType:isFluidContainer() then
count = 1
else
count = 0
end
end
local result = player:addItem(itemType:getId(), count)
if result then
if not itemType:isStackable() then
if type(result) == "table" then
for _, item in ipairs(result) do
item:decay()
end
else
result:decay()
end
end
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
end
return false
end
createItem:separator(" ")
createItem:register()
Let me know your thoughts!
Last edited: