Jump to content

Table WTF :P


Recommended Posts

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 :P 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 by Guest
Link to comment

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 ) 

Link to comment

Thanks man :D 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 :/

Link to comment

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

Link to comment

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 :D

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