Jump to content

Storing table


ahmedo01

Recommended Posts

Hello All,

I am working on a new system but i need this.

server code:

function getPunishments(player) 
    local playeraccount = getPlayerAccount( player ) 
    local accname = getAccountName( playeraccount ) 
    local mypunishments = mysql_query ( db, "SELECT * FROM `punishments` WHERE `accountname` = '"..accname.."'" ) 
    local result,row = mysql_rows(mypunishments) 
     
    local set = setElementData(player,"CGC.punishmentsdata",toJSON(row)) 
  
  
end 
addEvent("CGC.getPunishments",true) 
addEventHandler( "CGC.getPunishments", getRootElement(  ), getPunishments) 

here is client side:

local row = getElementData(getLocalPlayer(  ),"CGC.punishmentsdata") 

and

for row1 in fromJSON(row) do 
            outputChatBox(row1[1]..row1[2]) 
        end 

but don't working.I want get informations from database to client side but how?

It gives error in debugscript

couldn't convert userdata argument to JSON, only valid resources can be included for this function.

Link to comment

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...