• 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!

need help convert this script to tfs 1.3

robertorb12

New Member
Joined
Jan 15, 2020
Messages
65
Reaction score
3
function onSay(cid, words, param, channel)
local t = string.explode(param, ",")
if t[1] ~= nil and t[2] ~= nil then
local list = {}
for i, tid in ipairs(getPlayersOnline()) do
list = tid
end
for i = 1, #list do
doPlayerAddItem(list,t[1],t[2])
doBroadcastMessage(getPlayerName(cid) .. " Acaba de dar: " .. t[2] .." ".. getItemNameById(t[1]) .. " para todos los players online!")
end
else
doPlayerPopupFYI(cid, "No parm...\nSend:\n /itemadd itemid,how_much_items\nexample:\n /itemadd 2160,10")
end
return true
end

please help make this script functional for tfs 1.3
example: /additem 2160,100
 
Lua:
function onSay(player, words, param)
    local split = param:split(",")
    if not split[1] or not split[2] then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Use /additem 2160, 100')
        return false
    end
    
    local toNumber = tonumber(split[1])
    local toNumber2 = tonumber(split[2])
    if not toNumber or not toNumber2 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Bad parameters, only numbers are accepted, ex. /additem 2160, 100")
        return false
    end

    if player:getItemCount(toNumber) < toNumber2 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You dont have item with ID: "..toNumber..".")
        return false
    end
    
    local players = Game.getPlayers()
    
    if #players < 1 then return false end
    for i = 1, #players do
        Player(players[i]):addItem(toNumber, toNumber2)
        Player(players[i]):sendTextMessage(MESSAGE_EVENT_ADVANCE, ""..player:getName().." acaba de dar: ".. toNumber2 .. " crystal coins para todos los players online!.")
    end
    
    return false
end
 
Lua:
function onSay(player, words, param)
    local split = param:split(",")
    if not split[1] or not split[2] then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Use /additem 2160, 100')
        return false
    end
   
    local toNumber = tonumber(split[1])
    local toNumber2 = tonumber(split[2])
    if not toNumber or not toNumber2 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Bad parameters, only numbers are accepted, ex. /additem 2160, 100")
        return false
    end

    if player:getItemCount(toNumber) < toNumber2 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You dont have item with ID: "..toNumber..".")
        return false
    end
   
    local players = Game.getPlayers()
   
    if #players < 1 then return false end
    for i = 1, #players do
        Player(players[i]):addItem(toNumber, toNumber2)
        Player(players[i]):sendTextMessage(MESSAGE_EVENT_ADVANCE, ""..player:getName().." acaba de dar: ".. toNumber2 .. " crystal coins para todos los players online!.")
    end
   
    return false
end

but that's only for crystal coins, isn't it? I'm looking for all items :D
 
Lua:
local function getEligiblePlayers()
    local list = {}
    local eligiblePlayers = {}
    for k,v in pairs(Game.getPlayers()) do
        local player = Player(v)
        if player then
            local IP = player:getIp()
            if not list[IP] then
                list[IP] = true
                table.insert(eligiblePlayers, player:getName())
            end
        end
    end
    return eligiblePlayers
end
    

function onSay(player, words, param, channel)
    local t = param:split(',')
 
    if not (t[1] and t[2]) then
        player:popupFYI('Incorrect Params:\n/itemadd ITEM_ID,COUNT\n\nExample:\n/itemadd 2160,10')
        return false
    end
 
    local iT = ItemType(tonumber(t[1]))
    if iT:getId() == 0 then
        player:popupFYI('An item by the ID of  --> ' .. t[1] .. ' <-- does not exist.')
        return false
    end

    local count = tonumber(t[2])
    if not count then
        player:popupFYI('Count must be a number: ' .. t[2] .. ' is not a number.')
        return false
    end

    local players = getEligiblePlayers()
    if #players == 0 then
        player:popupFYI('There are not enough eligible players online. [ ' .. #players .. ']')
        return false
    end
 
    for k,v in pairs(players) do
        local p = Player(v)
        if p then
            p:addItem(iT:getId(), count)
        end
    end
 
    Game.broadcastMessage(player:getName() .. ' gifts: ' .. count .. ' ' .. (count > 1 and iT:getPluralName() or iT:getName()) .. ' for all players online.')
  return false
end
 
Back
Top