• 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 MySQL Delete Results Os.time() > result

beenii

Well-Known Member
Joined
Jul 26, 2010
Messages
580
Solutions
1
Reaction score
57
executed:

SELECT `player_id`,`pid`,`sid`,CONVERT(`attributes` USING latin1 ) FROM `player_items` WHERE CONVERT(`attributes` USING latin1 ) LIKE '%timerOnExp%'

and have this results
consulta.png


how delete in lua for tfs 1.2
if timerOnExp < os.time() ?

i try
Code:
local TItoDelete = db.storeQuery("SELECT `player_id`,`pid`,`sid`,CONVERT(`attributes` USING latin1 ) AS `attr` FROM `player_items` WHERE CONVERT(`attributes` USING latin1 ) LIKE '%timerOnExp%'")

    if TItoDelete then -- if the MySQL result is not empty
        repeat
            local attrstring = result.getString(TItoDelete, "attr") -- get the attribute
            local attrnumber = tonumber(string.sub(attrstring, -12, string.len(attrstring)-2)) -- here I try to get only the number (I'm not sure if it will work)
            if (os.time() >= attrnumber) then
        local playerid = result.getNumber(TItoDelete, "player_id")
        local pid      = result.getNumber(TItoDelete, "pid")
                local sid      = result.getNumber(TItoDelete, "sid")
                db.storeQuery("DELETE FROM `player_items` WHERE `player_id`="..playerid.." AND `pid` = "..pid.." AND `sid` ="..sid) -- deletes item
               end
        until not result.next(TItoDelete)
    end

but dont work

bad argument #1 to 'len' <string expected, got boolean)
 
Back
Top