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

Solved /additem 2160,100 for give item to all players online excet MC

Mdcrf

New Member
Joined
Mar 2, 2014
Messages
18
Reaction score
1
Hi.
As a title said, i want this talkaction give item for all players online but not MC players... my server have 100+ online and any players have a 2-20 players online at the same time (MultiClient) ... i never give a good item because any players win 2-20 reward at once.
sry for bad english.

Anyone change this talkaction for reward only 1 player per ip?
Code:
function onSay(cid, words, param, channel)
local t = string.explode(param, ",")
if t[1] ~= nil and t[2] ~= nil then
doBroadcastMessage(getPlayerName(cid) .. " give: " .. t[2] .." ".. getItemNameById(t[1]) .. " for all players online!")
local list = {}
for i, tid in ipairs(getPlayersOnline()) do
    list[i] = tid
end
for i = 1, #list do
doPlayerAddItem(list[i],t[1],t[2])
end
else
doPlayerPopupFYI(cid, "No param...\nSend:\n /itemadd itemid,how_much_items\nexample:\n /itemadd 2160,10")
end
return true
end
 
Code:
function onSay(cid, words, param, channel)
    local t = string.explode(param, ",")
    if t[1] ~= nil and t[2] ~= nil then
        doBroadcastMessage(getPlayerName(cid) .. " give: " .. t[2] .." ".. getItemNameById(t[1]) .. " for all players online!")
        local list = {}
        for i, player in ipairs(getPlayersOnline()) do
            local playerIp = getPlayerIp(player)
            if not list[tostring(playerIp)] then
                list[tostring(playerIp)] = player
            end
        end
        if next(list) then
            for ip, pid pairs(list) do
                if isPlayer(pid) then
                    doPlayerAddItem(pid, t[1], t[2])
                end
            end
        end
    else
        doPlayerPopupFYI(cid, "No param...\nSend:\n /itemadd itemid,how_much_items\nexample:\n /itemadd 2160,10")
    end
    return true
end
 
Code:
function onSay(cid, words, param, channel)
    local t = string.explode(param, ",")
    if t[1] ~= nil and t[2] ~= nil then
        doBroadcastMessage(getPlayerName(cid) .. " give: " .. t[2] .." ".. getItemNameById(t[1]) .. " for all players online!")
        local list = {}
        for i, player in ipairs(getPlayersOnline()) do
            local playerIp = getPlayerIp(player)
            if not list[tostring(playerIp)] then
                list[tostring(playerIp)] = player
            end
        end
        if next(list) then
            for ip, pid pairs(list) do
                if isPlayer(pid) then
                    doPlayerAddItem(pid, t[1], t[2])
                end
            end
        end
    else
        doPlayerPopupFYI(cid, "No param...\nSend:\n /itemadd itemid,how_much_items\nexample:\n /itemadd 2160,10")
    end
    return true
end

Thanks but i find a error in console

[18/2/2016 2:40:33] [Error - LuaInterface::loadFile] data/talkactions/scripts/item_online.lua:13: 'in' expected near 'pairs'
[18/2/2016 2:40:33] [Error - Event::checkScript] Cannot load script (data/talkactions/scripts/item_online.lua)
[18/2/2016 2:40:33] data/talkactions/scripts/item_online.lua:13: 'in' expected near 'pairs'
 
Code:
function onSay(cid, words, param, channel)
    local t = string.explode(param, ",")
    if t[1] ~= nil and t[2] ~= nil then
        doBroadcastMessage(getPlayerName(cid) .. " give: " .. t[2] .." ".. getItemNameById(t[1]) .. " for all players online!")
        local list = {}
        for i, player in ipairs(getPlayersOnline()) do
            local playerIp = getPlayerIp(player)
            if not list[tostring(playerIp)] then
                list[tostring(playerIp)] = player
            end
        end
        if next(list) then
            for ip, pid in pairs(list) do
                if isPlayer(pid) then
                    doPlayerAddItem(pid, t[1], t[2])
                end
            end
        end
    else
        doPlayerPopupFYI(cid, "No param...\nSend:\n /itemadd itemid,how_much_items\nexample:\n /itemadd 2160,10")
    end
    return true
end
 
Back
Top