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

[Talkaction] Advanced Looping (Scores)

Tufte

Member
Joined
Nov 19, 2007
Messages
652
Reaction score
24
Location
Norway
I need a function for my script. I have a sql table, and i've made a function that prints all names insterted in this table. What I want to do with this table, is:

When you say !scores, you will get a textbox with Player Name, storage1, storage2. Ive made everything, but I can only get it to print the names, because i've yet to learn how to use inpairs/ipars in looping.

This is a pure example of how I want the loop to be outputed:

PHP:
Scores:

Faen 1   7
Lol    2   3
Noob  3   10
Ron    1   6

Thanks for the help.
 
erm.. it should work:

Code:
local list = db.getResult("SELECT `name`, `storage1`, `storage2` FROM `your_table` WHERE `your_table`.`something` = 'another_thing';")
if(list:getID() ~= -1) then
    local message = "Scores:"
    while(true) do
        local name = list:getDataInt("name")
        local storage1 = list:getDataInt("storage1")
        local storage2 = list:getDataInt("storage2")
        local message = message .. "\n" .. name .. " - " .. storage1 .. " - " .. storage2
        if not(list:next()) then
            break
        end
    end
    list:free()
    doPlayerPopupFYI(cid, message)
end

for tfs 0.3, ofc.
 
Back
Top