• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Add items inside player's bp

Is there a talkaction script for gods to add items inside player's bp ?
tfs 1.3

And then

!lua Player('nick'):addItem(id)
 
You 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
}
 
You 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 working , no errors
sure it's working for 1.3?
just tell me the command i tried all commands like
/additem , admin , 12512
/additem , 12512 , admin
/additem ,admin,demon helmet
 
not working
no errors
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:
Lua:
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()
and remember to use the command with God
 
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:
Lua:
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()
and remember to use the command with God
it gives me the message player has received but i don't receive anything , tried with different items?
is it possible to send broadcast message to player who received items telling him that had received items from admin name?

EDIT:i guess it works only with items name not id

Another edit: it was my faullt trying to send items to another god chr , it works with both items id,name
 
Back
Top