Is there a talkaction script for gods to add items inside player's bp ?
tfs 1.3
TalkAction {
words = "/additem",
separator = " ",
onSay = function (player, words, param)
if not player:getGroup():getAccess() then
return true
end
local split = param:split(",")
local target = Player(split[1])
if not target then
player:sendCancelMessage("Player does not exist.")
return false
end
local itemType = ItemType(split[2])
if itemType then
if itemType:getId() == 0 or itemType:getName() == "" then
itemType = ItemType(tonumber(split[2]))
if itemType:getId() == 0 or itemType:getName() == "" then
player:sendCancelMessage("This item does not exist.")
return false
end
end
end
local count = 1
if split[3] then
count = tonumber(split[3])
end
local item = Game.createItem(itemType:getId(), count)
if item then
target:addItemEx(item)
player:sendCancelMessage(string.format("The player %s has receive %u %s.", split[1], count, itemType:getName()))
end
return false
end,
register = true
}
not working , no errorsYou can also use: data/scripts/talkactions/additem.lua
Lua:TalkAction { words = "/additem", separator = " ", onSay = function (player, words, param) if not player:getGroup():getAccess() then return true end local split = param:split(",") local target = Player(split[1]) if not target then player:sendCancelMessage("Player does not exist.") return false end local itemType = ItemType(split[2]) if itemType then if itemType:getId() == 0 or itemType:getName() == "" then itemType = ItemType(tonumber(split[2])) if itemType:getId() == 0 or itemType:getName() == "" then player:sendCancelMessage("This item does not exist.") return false end end end local count = 1 if split[3] then count = tonumber(split[3]) end local item = Game.createItem(itemType:getId(), count) if item then target:addItemEx(item) player:sendCancelMessage(string.format("The player %s has receive %u %s.", split[1], count, itemType:getName())) end return false end, register = true }
not workingView attachment 43800
Lua:/additem name,itemid,cout ----------------------------- /additem Seleny,2160,100
Excuse me, forget to mention that you must have these changes: Better Revscripts Constructors by infernumx · Pull Request #2746 · otland/forgottenserver (https://github.com/otland/forgottenserver/pull/2746)not working
no errors
local addItemTalk = TalkAction("/additem")
addItemTalk.onSay = function (player, words, param)
if not player:getGroup():getAccess() then
return true
end
local split = param:split(",")
local target = Player(split[1])
if not target then
player:sendCancelMessage("Player does not exist.")
return false
end
local itemType = ItemType(split[2])
if itemType then
if itemType:getId() == 0 or itemType:getName() == "" then
itemType = ItemType(tonumber(split[2]))
if itemType:getId() == 0 or itemType:getName() == "" then
player:sendCancelMessage("This item does not exist.")
return false
end
end
end
local count = 1
if split[3] then
count = tonumber(split[3])
end
local item = Game.createItem(itemType:getId(), count)
if item then
target:addItemEx(item)
player:sendCancelMessage(string.format("The player %s has receive %u %s.", split[1], count, itemType:getName()))
end
return false
end
addItemTalk:separator(" ")
addItemTalk:register()
it gives me the message player has received but i don't receive anything , tried with different items?Excuse me, forget to mention that you must have these changes: Better Revscripts Constructors by infernumx · Pull Request #2746 · otland/forgottenserver (https://github.com/otland/forgottenserver/pull/2746)
if you don't want to use those changes then use this script:and remember to use the command with GodLua:local addItemTalk = TalkAction("/additem") addItemTalk.onSay = function (player, words, param) if not player:getGroup():getAccess() then return true end local split = param:split(",") local target = Player(split[1]) if not target then player:sendCancelMessage("Player does not exist.") return false end local itemType = ItemType(split[2]) if itemType then if itemType:getId() == 0 or itemType:getName() == "" then itemType = ItemType(tonumber(split[2])) if itemType:getId() == 0 or itemType:getName() == "" then player:sendCancelMessage("This item does not exist.") return false end end end local count = 1 if split[3] then count = tonumber(split[3]) end local item = Game.createItem(itemType:getId(), count) if item then target:addItemEx(item) player:sendCancelMessage(string.format("The player %s has receive %u %s.", split[1], count, itemType:getName())) end return false end addItemTalk:separator(" ") addItemTalk:register()