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

Lua If players online X

Blade33711

Member
Joined
Aug 6, 2012
Messages
133
Solutions
1
Reaction score
5
Location
Poland
Why it didn't work? How to do it? :(
Lua:
function onThink(interval, lastExecution)
    for i, pid in pairs(getPlayersOnline()) do
        if isPlayer(pid) then
            ppls = i
        end
    end
    for k, v in pairs(tabela) do
        if k == ppls then
            SCRIPT
        else
        return true
        end
    end
return true
end
 
Solution
Still the same. No message if I add.
Thanks for your help!
Code:
<config name="exp_config"><![CDATA[tabela = {
[2] = {x = 2}
}
amount = 0
]]></config>

<globalevent name="test" interval="1000" event="script"><![CDATA[
domodlib('exp_config')
function onThink(interval, lastExecution)
    for _, pid in pairs(getPlayersOnline()) do
        amount = amount + 1
    end

    for k, v in pairs(tabela) do
        if k == amount  then
            doBroadcastMessage("Test", MESSAGE_EVENT_ADVANCE)
        else
        return true
        end
    end
return true
end
]]></globalevent>
</mod>

Ehm?
Lua:
<globalevent name="test" interval="1000" event="script"><![CDATA[
    local amount = 0
    function onThink(interval, lastExecution)
        for...
Why it didn't work? How to do it? :(
Lua:
function onThink(interval, lastExecution)
    for i, pid in pairs(getPlayersOnline()) do
        if isPlayer(pid) then
            ppls = i
        end
    end
    for k, v in pairs(tabela) do
        if k == ppls then
            SCRIPT
        else
        return true
        end
    end
return true
end



Not sure what you are trying to do, but I guess this will solve your problems;
Lua:
function onThink(interval, lastExecution)
    local amount = 0
    for _, pid in pairs(getPlayersOnline()) do
        amount = amount + 1
    end

    if amount >= 1 then
        SCRIPT
    end

    return true
end

If there is more then 1 player online SCRIPT will be executed.

And in the future please read the rules; Rules for the Support board
Especially rule #5 and IMO #1
 
Still the same. No message if I add.
Thanks for your help!
Code:
<config name="exp_config"><![CDATA[tabela = {
[2] = {x = 2}
}
amount = 0
]]></config>

<globalevent name="test" interval="1000" event="script"><![CDATA[
domodlib('exp_config')
function onThink(interval, lastExecution)
    for _, pid in pairs(getPlayersOnline()) do
        amount = amount + 1
    end

    for k, v in pairs(tabela) do
        if k == amount  then
            doBroadcastMessage("Test", MESSAGE_EVENT_ADVANCE)
        else
        return true
        end
    end
return true
end
]]></globalevent>
</mod>
 
Still the same. No message if I add.
Thanks for your help!
Code:
<config name="exp_config"><![CDATA[tabela = {
[2] = {x = 2}
}
amount = 0
]]></config>

<globalevent name="test" interval="1000" event="script"><![CDATA[
domodlib('exp_config')
function onThink(interval, lastExecution)
    for _, pid in pairs(getPlayersOnline()) do
        amount = amount + 1
    end

    for k, v in pairs(tabela) do
        if k == amount  then
            doBroadcastMessage("Test", MESSAGE_EVENT_ADVANCE)
        else
        return true
        end
    end
return true
end
]]></globalevent>
</mod>

Ehm?
Lua:
<globalevent name="test" interval="1000" event="script"><![CDATA[
    local amount = 0
    function onThink(interval, lastExecution)
        for _, pid in pairs(getPlayersOnline()) do
            amount = amount + 1
        end

        if amount >= config.amount then
            doBroadcastMessage("Test", MESSAGE_EVENT_ADVANCE)
        end

        return true
    end
]]></globalevent>
</mod>
 
Solution
Back
Top