Jump to content

fromJSON


Recommended Posts

Posted

Hello! When i type

local rank = fromJSON(f.ranks)

outputChatBox(rank)

where f.ranks is text from database and its equals [{"1":"Szeregowy", "2":"Test"}] it give me a error:

bad argument outputChatBox [exepcted string at argument 1 got nil]

Why?

Posted

This system fractions and is 85 lines, not the entire required. Paste the most important passage:

  
local f = exports.DB2:pobierzWyniki("SELECT * FROM `prs_frakcje` WHERE `id` = "..getElementData(source, "fid")) 
                local u = exports.DB2:pobierzWyniki("SELECT * FROM `prs_frakcje_players` WHERE `uid` = "..getElementData(plr, "auth:id")) 
  
                setElementData(plr, "f.name", f.nazwa) 
                setElementData(plr, "f.id", f.id) 
local rank = fromJSON(f.ranks) 
outputChatBox(#rank) -- !!!! prints 0 
  
  

Posted

try sth like this

    local check = exports.DB2:pobierzWyniki("SELECT * FROM `prs_frakcje` WHERE `id` = "..getElementData(source, "fid")) 
    if type(check) ~= "table" or #check ~= 0 or check then 
    local rank = fromJSON(check[1]["ranks"]) 
    -- Your code 
end  

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...