Plate Posted May 16, 2013 Share Posted May 16, 2013 Hola tengo una duda se pueden cargar posiciones desde una data base? Link to comment
Sasu Posted May 16, 2013 Share Posted May 16, 2013 Podes cargar todo lo que tu quieras con una base de datos, hasta lo que yo conosco. Creas tres columnas y los guardas ahi. Si hay otra manera, que alguien me corrija. Link to comment
Plate Posted May 16, 2013 Author Share Posted May 16, 2013 pero las que tengo son 4 columnas en la 1 va le nombre del clan en la 2da x 3ro y 4ta z se puede cargar eso? Link to comment
Lucario Posted May 17, 2013 Share Posted May 17, 2013 A que tipo de columnas te refieres? gridlist de un panel? Link to comment
Plate Posted May 17, 2013 Author Share Posted May 17, 2013 A que tipo de columnas te refieres? gridlist de un panel? Data base Link to comment
Lucario Posted May 17, 2013 Share Posted May 17, 2013 A eso aun no llegue yo , si posteas el codigo yo lo puedo arreglar Link to comment
Plate Posted May 17, 2013 Author Share Posted May 17, 2013 A eso aun no llegue yo , si posteas el codigo yo lo puedo arreglar Creo que si no sabes de data base no podes arreglar un code de data base PD: El problema no es el code sino que nose como hacer para cargar 4 posiciones Code: function getClanSpawn( ClanName ) if ( not connection2 ) then return end local query = dbQuery( connection2, "SELECT * FROM Spawns WHERE ClanName=?", tostring ( ClanName ), tostring(spawnX), tostring(spawnY), tostring(spawnZ) ) -- esto nose si esta bien local result, numrows, errmsg = dbPoll ( query, -1 ) if ( type( result ) == "table" and #result == 0 or not result ) then return false else return true end end Link to comment
Lucario Posted May 17, 2013 Share Posted May 17, 2013 A eso aun no llegue yo , si posteas el codigo yo lo puedo arreglar Creo que si no sabes de data base no podes arreglar un code de data base PD: El problema no es el code sino que nose como hacer para cargar 4 posiciones Code: function getClanSpawn( ClanName ) if ( not connection2 ) then return end local query = dbQuery( connection2, "SELECT * FROM Spawns WHERE ClanName=?", tostring ( ClanName ), tostring(spawnX), tostring(spawnY), tostring(spawnZ) ) -- esto nose si esta bien local result, numrows, errmsg = dbPoll ( query, -1 ) if ( type( result ) == "table" and #result == 0 or not result ) then return false else return true end end Ok intentare aprender cuando pueda el database, lo que quieres es tener 3 spawnx spawny y spawnz no? Link to comment
Sasu Posted May 17, 2013 Share Posted May 17, 2013 Puedes intentar esto: function getClanSpawn( ClanName ) if ( not connection2 ) then return end local query = dbQuery( connection2, "SELECT * FROM Spawns WHERE ClanName=?", tostring ( ClanName ) ) local result, numrows, errmsg = dbPoll ( query, -1 ) if result == false then return false end for _, row in pairs ( result ) do local x = row["spawnX"] local y = row["spawnY"] local z = row["spawnZ"] end return x,y,z end Link to comment
Plate Posted May 17, 2013 Author Share Posted May 17, 2013 Sasuke agregame a skype(si tenes): codplate14 terminamos el tema por hay EDIT:No da error pero no funciona Link to comment
Castillo Posted May 17, 2013 Share Posted May 17, 2013 Puedes intentar esto: function getClanSpawn( ClanName ) if ( not connection2 ) then return end local query = dbQuery( connection2, "SELECT * FROM Spawns WHERE ClanName=?", tostring ( ClanName ) ) local result, numrows, errmsg = dbPoll ( query, -1 ) if result == false then return false end for _, row in pairs ( result ) do local x = row["spawnX"] local y = row["spawnY"] local z = row["spawnZ"] end return x,y,z end No hace falta el for-loop. function getClanSpawn ( ClanName ) if ( not connection2 ) then return end local query = dbQuery ( connection2, "SELECT * FROM Spawns WHERE ClanName=?", tostring ( ClanName ) ) -- esto nose si esta bien local result, numrows, errmsg = dbPoll ( query, -1 ) if ( type ( result ) == "table" and #result == 0 or not result ) then return false else return result [ 1 ].spawnX, result [ 1 ].spawnY, result [ 1 ].spawnZ end end P.D: MultiKiller: No postees si no sabes. Link to comment
Plate Posted May 18, 2013 Author Share Posted May 18, 2013 (edited) Puedes intentar esto: function getClanSpawn( ClanName ) if ( not connection2 ) then return end local query = dbQuery( connection2, "SELECT * FROM Spawns WHERE ClanName=?", tostring ( ClanName ) ) local result, numrows, errmsg = dbPoll ( query, -1 ) if result == false then return false end for _, row in pairs ( result ) do local x = row["spawnX"] local y = row["spawnY"] local z = row["spawnZ"] end return x,y,z end No hace falta el for-loop. function getClanSpawn ( ClanName ) if ( not connection2 ) then return end local query = dbQuery ( connection2, "SELECT * FROM Spawns WHERE ClanName=?", tostring ( ClanName ) ) -- esto nose si esta bien local result, numrows, errmsg = dbPoll ( query, -1 ) if ( type ( result ) == "table" and #result == 0 or not result ) then return false else return result [ 1 ].spawnX, result [ 1 ].spawnY, result [ 1 ].spawnZ end end P.D: MultiKiller: No postees si no sabes. Funciona gracias sasuke y Solid EDIT:Funciona con comando pero con edit no Client: function checkClanSpawn() local row, col = guiGridListGetSelectedItem ( CSGrid ) if ( row and col and row ~= -1 and col ~= -1 ) then local ClanName = guiGridListGetItemText ( CSGrid, row, 1 ) triggerServerEvent("onAdminCheckClanSpawn", localPlayer, ClanName) end end addEventHandler("onClientGUIClick", getSpawn, checkClanSpawn, false) server: function checkClanSpawn(ClanName) local x, y, z = getClanSpawnInfo(ClanName) triggerClientEvent("onClientClanSpawn", getRootElement(), x, y ,z) end addEvent("onAdminCheckClanSpawn", true) addEventHandler("onAdminCheckClanSpawn ", getRootElement(), checkClanSpawn) client: function checked(x, y ,z) guiSetText(SpawnX, tonumber(x)) guiSetText(SpawnY, tonumber(y)) guiSetText(SpawnZ, tonumber(z)) end addEvent("onClientClanSpawn", true) addEventHandler("onClientClanSpawn", getRootElement(), checked) Edited May 18, 2013 by Guest Link to comment
Plate Posted May 18, 2013 Author Share Posted May 18, 2013 Lee mi edit porfavor PD: Ni idea por que no anda no da error Link to comment
Castillo Posted May 18, 2013 Share Posted May 18, 2013 Fijate que devuelve "x", "y", "z" al enviarlo al client side. Link to comment
Sasu Posted May 18, 2013 Share Posted May 18, 2013 Eso es porque guiSetText solo acepta string's. function checked(x, y ,z) guiSetText(SpawnX, tostring(x)) guiSetText(SpawnY, tostring(y)) guiSetText(SpawnZ, tostring(z)) end addEvent("onClientClanSpawn", true) addEventHandler("onClientClanSpawn", getRootElement(), checked) Link to comment
Plate Posted May 18, 2013 Author Share Posted May 18, 2013 Eso es porque guiSetText solo acepta string's. function checked(x, y ,z) guiSetText(SpawnX, tostring(x)) guiSetText(SpawnY, tostring(y)) guiSetText(SpawnZ, tostring(z)) end addEvent("onClientClanSpawn", true) addEventHandler("onClientClanSpawn", getRootElement(), checked) No no funciona nose por que tampoco da error Link to comment
Plate Posted May 18, 2013 Author Share Posted May 18, 2013 Hiciste lo que yo te dije? Ah perdon no lo abia leido Bueno checkee usando outputChatBox(para saber si pasaba lo que tenia que pasar) no obtiene las posiciones nose por que Link to comment
Castillo Posted May 18, 2013 Share Posted May 18, 2013 function checkClanSpawn(ClanName) outputChatBOx ( ClanName ) local x, y, z = getClanSpawnInfo(ClanName) triggerClientEvent("onClientClanSpawn", getRootElement(), x, y ,z) end addEvent("onAdminCheckClanSpawn", true) addEventHandler("onAdminCheckClanSpawn ", getRootElement(), checkClanSpawn) Fijate que dice en el chat. Link to comment
Plate Posted May 18, 2013 Author Share Posted May 18, 2013 ya lo arregle finalmente gracias Solidsnake y Sasuke Link to comment
Plate Posted May 18, 2013 Author Share Posted May 18, 2013 Creo que el primer trigger o el addEvent de serverside Link to comment
Recommended Posts