FWCentral Posted May 15, 2012 Posted May 15, 2012 (edited) Hey im trying to create a SQLite table; function ontStart (r) if r == getThisResource() then executeSQLCreateTable ( "Groups", "name TEXT, type TEXT, level NUMBER") -- creates this fine. executeSQLCreateTable ( "Groups_members", "name TEXT, group TEXT, rank TEXT") else end end addEventHandler ( "onResourceStart", getRootElement(), ontStart ) It shows the table Groups in the SQLite browser but not Groups_members, Although in the console it says it has been created, Will it still be there? Edit: No it isn't there what is the problem? it creates the other fine even when i remove Groups from the script and just try create the other it doesn't Edited May 15, 2012 by Guest
TAPL Posted May 15, 2012 Posted May 15, 2012 i don't see any error you can create it using Query executeSQLQuery("CREATE TABLE IF NOT EXISTS Groups_members (name TEXT, group TEXT, rank TEXT)")
FWCentral Posted May 15, 2012 Author Posted May 15, 2012 I get an error when i tried that: database query failed near "group": syntax error
Castillo Posted May 15, 2012 Posted May 15, 2012 I executed the query manually and it said: Database query failed: near "group": syntax error I changed it to "groupName" and now it works. function ontStart ( ) executeSQLCreateTable ( "Groups", "name TEXT, type TEXT, level NUMBER" ) executeSQLCreateTable ( "Groups_members", "name TEXT, groupName TEXT, rank TEXT" ) end addEventHandler ( "onResourceStart", resourceRoot, ontStart )
FWCentral Posted May 15, 2012 Author Posted May 15, 2012 Yeah that worked Solidsnake thanks, I don't know what the problem was
Castillo Posted May 15, 2012 Posted May 15, 2012 I'd a quick search on google and and I found this: When table name or column name is the same as SQL keywords (such as GROUP), errors are generated P.S: You're welcome.
FWCentral Posted May 15, 2012 Author Posted May 15, 2012 Thanks man i got another problem, I want to send the name and the rank from Group_members but how can i loop 2 things at once? I tried this: local member = executeSQLQuery("SELECT name FROM Groups_members WHERE groupName = ?",tostring(name)) local prank = executeSQLQuery("SELECT rank FROM Groups_members WHERE name = ?",tostring(member)) local member = executeSQLQuery("SELECT name,rank FROM Groups_members WHERE name = ?",tostring(name)) for i, plname in ipairs(member,prank) do triggerClientEvent("addName", source,plname.name,plname.rank) I didn't get any error but it didn't work
TAPL Posted May 15, 2012 Posted May 15, 2012 you have two same variable name local member = executeSQLQuery("SELECT name FROM Groups_members WHERE groupName = ?",tostring(name)) local member = executeSQLQuery("SELECT name,rank FROM Groups_members WHERE name = ?",tostring(name)) i think do the loop in client is better
FWCentral Posted May 15, 2012 Author Posted May 15, 2012 Ok ill explain more mate, there is a gridlist in the GUI that i created and it is to show all the members in the group. I need to send the data "name" and "rank" from the server to the client. local member = executeSQLQuery("SELECT name FROM Groups_members WHERE groupName = ?",tostring(name))-- This is to get the member ( tostring(name) is the name of the groupName in Groups_members ) local prank = executeSQLQuery("SELECT rank FROM Groups_members WHERE name = ?",tostring(member)) -- then get the rank of that player local member = executeSQLQuery("SELECT name,rank FROM Groups_members WHERE name = ?",tostring(name))-- ok now im confused i dont know why ive done this. Anyway i want to trigger to the client with the each players rank and name like: triggerClientEvent("addName", source,name,rank) Edit Nevermind guys it works now i just needed to do this: local member = executeSQLQuery("SELECT name,rank FROM Groups_members WHERE groupName = ?",tostring(name)) for i, plname in ipairs(member) do triggerClientEvent("addName", source,plname.name,plname.rank) Thanks guys
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