enzoDs Posted March 28, 2020 Posted March 28, 2020 Hello i need convert string to table and table to string! Thanks With de toJson o other metod
The_GTA Posted March 28, 2020 Posted March 28, 2020 6 minutes ago, enzoDs said: Hello i need convert string to table and table to string! Thanks With de toJson o other metod Hello enzoDs, you seem to know about the functions toJSON and fromJSON, don't you? If you have any problems with using these functions then please explain and we will help you 1
enzoDs Posted March 28, 2020 Author Posted March 28, 2020 defaultPuestos = { [1] = "Jefe", [2] = "Jefe", [3] = "500", [4] = "Lider", [5] = "Lider", [6] = "400", [7] = "Empleado", [8] = "Empleado", [9] = "107", [10] = "7", [11] = "Empleado", [12] = "106", [13] = "6", [14] = "Empleado", [15] = "105", [16] = "5", [17] = "Empleado", [18] = "104", [19] = "4", [20] = "Empleado", [21] = "103", [22] = "3", [23] = "Empleado", [24] = "102", [25] = "2", [26] = "Empleado", [27] = "101", [28] = "1", [29] = "Empleado", [30] = "100", } stringTable = toJson(defaultPuestos ) defautPuestos2 = fromJson(stringTable) In this case defautPuestos2 would be a table value?
The_GTA Posted March 28, 2020 Posted March 28, 2020 15 minutes ago, enzoDs said: In this case defautPuestos2 would be a table value? Yes, I see no problem in the code. 1
enzoDs Posted March 29, 2020 Author Posted March 29, 2020 function crearEmpresa ( stringNombre, stringEmpresa ) aclCreateGroup ( tostring((stringEmpresa):gsub(" ", "-")) ) aclGroupAddObject ( aclGetGroup(tostring((stringEmpresa):gsub(" ", "-"))), "user."..getAccountName(getPlayerAccount(getPlayerFromName(stringNombre)) )) setAccountData ( getPlayerAccount(getPlayerFromName(stringNombre)), "Empresa", tostring((stringEmpresa):gsub(" ", "-")) ) outputChatBox("(( EMPRESAS: "..stringNombre.." creo un empresa llamada "..stringEmpresa.." ))") addAccount ( tostring((stringEmpresa):gsub(" ", "-")), "*******" ) a = setAccountData ( getAccount(tostring((stringEmpresa):gsub(" ", "-"))), "Puestos", toJSON(defaultPuestos) ) outputChatBox(tostring(stringTabla)) end addEvent( "crearEmpresa", true ) addEventHandler( "crearEmpresa", resourceRoot, crearEmpresa ) --outputChatBox(tostring(("Hola XD"):gsub(" ", "-"))) function TablaEmpresa (jugador) empresajugador = getAccountData(getPlayerAccount(getPlayerFromName(jugador)), "Empresa") tabla = aclGroupListObjects(aclGetGroup(empresajugador)) dataPuestos = getAccountData ( getAccount(tostring((empresajugador):gsub(" ", "-"))), "Puestos" ) outputChatBox(dataPuestos) triggerClientEvent ( getPlayerFromName(jugador), "onPanelAbierto", getPlayerFromName(jugador), tabla,dataPuestos ) end addEvent( "onPanelAbierto", true ) addEventHandler( "onPanelAbierto", resourceRoot, TablaEmpresa ) function llenarGrid (tablaEmpleados,dataPuesto) dataPuestos = fromJSON(dataPuesto) DGS:dgsGridListClear( Egrid ) outputChatBox(unpack(dataPuestos,1)) for objects,name in pairs(tablaEmpleados)do local row = DGS:dgsGridListAddRow ( Egrid ) DGS:dgsGridListSetItemText ( Egrid, row, 1, tostring((name):gsub("user.", ""))) end end addEvent( "onPanelAbierto", true ) addEventHandler( "onPanelAbierto", localPlayer, llenarGrid ) [21:13:55] WARNING: Empresas\server.Lua:71: Bad argument @ 'toJSON' [Expected bool at argument 2, got string 'none'] i cant unpack the table
enzoDs Posted March 29, 2020 Author Posted March 29, 2020 WARNING: Empresas/client.Lua:71: Bad argument @ "outputChatBox" [Expected string ar argument 1, got none] I solve it, thanks! 1
The_GTA Posted March 29, 2020 Posted March 29, 2020 8 hours ago, enzoDs said: WARNING: Empresas/client.Lua:71: Bad argument @ "outputChatBox" [Expected string ar argument 1, got none] I solve it, thanks! Glad to hear that you got it solved. I was sleeping at that time so I could not respond quickly enough. 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now