Jump to content

SQL _ GridList


Recommended Posts

Posted (edited)

how I wil use this with sql lite

im suck with gridlist this is Image for the mode

im trying to make it's

3F55w.png

help please.

-------------------------------------

how did I wil put the player name that's one I want to know it's !

Edited by Guest

Try a little harder to be a little better

I Can Made To You Any Script For $

Skype : alhajarii-mtasa

Posted
You can use :
executeSQLQuery 

SQL Lite .

yea I know .

put my proplem how wil put the table sql into grid list .

Try a little harder to be a little better

I Can Made To You Any Script For $

Skype : alhajarii-mtasa

Posted
You can use :
executeSQLQuery 

SQL Lite .

yea I know .

put my proplem how wil put the table sql into grid list .

triggerClientEvent 
guiGridListSetItemText 

  

Posted
You can use :
executeSQLQuery 

SQL Lite .

yea I know .

put my proplem how wil put the table sql into grid list .

triggerClientEvent 
guiGridListSetItemText 

it's be with xml folder when I put

name in him ??

Try a little harder to be a little better

I Can Made To You Any Script For $

Skype : alhajarii-mtasa

Posted
No, You're using sql there's no need for xml .

is getPlayerName work

because I want name put in grid list thos name's in table

name = { 
  
"Alone", 
"BH", 
"KSA" 
  
} 
  
  
addEventHandler('onResourceStart',resourceRoot, 
  
    function () 
  
           local Tabel = executeSQLQuery("CREATE TABLE IF NOT EXISTS xAlhajarii ( name)") 
                         
            if ( Tabel ) then 
             
            outputDebugString( "Create Table xAlhajarii done") 
             
            local Results = executeSQLQuery("SELECT * FROM `xAlhajarii` WHERE PlayerName=?",name  ) 
             
            if ( Results == "table" and #Results == 0 or not Results  ) then 
             
             executeSQLQuery ( "INSERT INTO `xAlhajarii` ( PlayerName ) VALUES(?,?,?,?)",name) 
             
            else 
             
            executeSQLQuery('UPDATE `xAlhajarii` SET  PlayerName =?',name) 
             
           triggerClientEvent ("CallSQLPUT", getRootElement()) 
  
    end 
   end 
   end 
) 
  
  

Try a little harder to be a little better

I Can Made To You Any Script For $

Skype : alhajarii-mtasa

Posted

You're getting the results on start :/ Bad idea when you show the gui you should get it also if you want to set a grid text use it client side i mean the table ( name ) .

  

Posted
You're getting the results on start :/ Bad idea when you show the gui you should get it also if you want to set a grid text use it client side i mean the table ( name ) .

so I wil put results in event PlayerJoin ?

and take it when player open the gui window with the bindkey

trigger to results ?

Try a little harder to be a little better

I Can Made To You Any Script For $

Skype : alhajarii-mtasa

Posted
You're getting the results on start :/ Bad idea when you show the gui you should get it also if you want to set a grid text use it client side i mean the table ( name ) .

so I wil put results in event PlayerJoin ?

and take it when player open the gui window with the bindkey

trigger to results ?

Insert the results when a player press the button and get the results when a player show a gui .

  

Posted
You're getting the results on start :/ Bad idea when you show the gui you should get it also if you want to set a grid text use it client side i mean the table ( name ) .

so I wil put results in event PlayerJoin ?

and take it when player open the gui window with the bindkey

trigger to results ?

Insert the results when a player press the button and get the results when a player show a gui .

Server :

function Results() 
    local Results = executeSQLQuery("SELECT * FROM `xAlhajarii` WHERE PlayerName=?",getPlayerName ( name ) ) 
             
            if ( Results == "table" and #Results == 0 or not Results  ) then 
             
             executeSQLQuery ( "INSERT INTO `xAlhajarii` ( PlayerName ) VALUES(?,?,?,?)",getPlayerName(name)) 
             
            else 
             
            executeSQLQuery('UPDATE `xAlhajarii` SET  PlayerName =?',getPlayerName(name)) 
             
            end 
            end 
addEvent("gResults",true) 
addEventHandler("gResults",root,Results) 
------------------------------------------------------------------------------------------------------------------ 
addEvent("AreYouOpen?",true) 
addEventHandler("AreYouOpen?",root, 
function() 
Results() 
end 

Client :

  
  name = { 
  
"Alone", 
"BH", 
"KSA" 
  
} 
  
addEventHandler("onClientGUIClick",root, 
  function() 
   
  if ( source == vote) then 
   
  triggerServerEvent("gResults",gPlayer) --- i make it gPlayer for i made ( local gPlayer == getLocalPlayer() ) 
  
 end 
       end 
 ) 
--------------------------------------------------------- 
  
bindKey(Key,"down", 
  
function () 
    
   guiSetVisible( wnd , not guiGetVisible(wnd)) 
    
   showCursor(guiGetVisible(wnd)) 
              
    triggerServerEvent("AreYouOpen?",gPlayer) 
     
             end 
end 
     ) 

?

how I wil trigger table name from client to server ?

Try a little harder to be a little better

I Can Made To You Any Script For $

Skype : alhajarii-mtasa

Posted

This is a simple on how to send/add to gridlist the content of a table:

-- client side:

addEventHandler ( "onClientResourceStart", resourceRoot, 
    function ( ) 
        myGridList = guiCreateGridList ( 50, 50, 100, 100, false ) -- Create a GUI gridlist 
        triggerServerEvent ( "getTableContent", localPlayer ) -- Trigger a server side event to get the data 
    end 
) 
  
addEvent ( "returnTableContent", true ) 
addEventHandler ( "returnTableContent", root, 
    function ( content ) 
        for _, text in ipairs ( content ) do -- Loop the items from the 'content' table sent from the server side. 
            guiGridListSetItemText ( myGridList, guiGridListAddRow ( myGridList ), 1, text, false, false ) -- Add it to the gridlist. 
        end 
    end 
) 

-- server side:

myTable = -- Define the table. 
    { 
        "Hello", 
        "World" 
    } 
  
addEvent ( "getTableContent", true ) 
addEventHandler ( "getTableContent", root, 
    function ( ) 
        triggerClientEvent ( client, "returnTableContent", client, myTable ) -- Send the 'myTable' content to the client side. 
    end 
) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted (edited)
This is a simple on how to send/add to gridlist the content of a table:

-- client side:

addEventHandler ( "onClientResourceStart", resourceRoot, 
    function ( ) 
        myGridList = guiCreateGridList ( 50, 50, 100, 100, false ) -- Create a GUI gridlist 
        triggerServerEvent ( "getTableContent", localPlayer ) -- Trigger a server side event to get the data 
    end 
) 
  
addEvent ( "returnTableContent", true ) 
addEventHandler ( "returnTableContent", root, 
    function ( content ) 
        for _, text in ipairs ( content ) do -- Loop the items from the 'content' table sent from the server side. 
            guiGridListSetItemText ( myGridList, guiGridListAddRow ( myGridList ), 1, text, false, false ) -- Add it to the gridlist. 
        end 
    end 
) 

-- server side:

myTable = -- Define the table. 
    { 
        "Hello", 
        "World" 
    } 
  
addEvent ( "getTableContent", true ) 
addEventHandler ( "getTableContent", root, 
    function ( ) 
        triggerClientEvent ( client, "returnTableContent", client, myTable ) -- Send the 'myTable' content to the client side. 
    end 
) 

Client :

------------------------------------------------------- 
addEventHandler("onClientGUIClick",root, 
  function() 
   
  if ( source == vote) then 
   
  triggerServerEvent("gResults",gPlayer) --- i make it gPlayer for i made ( local gPlayer == getLocalPlayer() ) 
  
 end 
       end 
 ) 
--------------------------------------------------------- 
local Key = "F5" 
  
bindKey(Key,"down", 
  
function () 
    
   guiSetVisible( wnd , not guiGetVisible(wnd)) 
    
   showCursor(guiGetVisible(wnd)) 
              
    triggerServerEvent("AreYouOpen?",gPlayer) 
     
             end 
end 
     ) 
  
      
------------------------------------------------------------- 
  
  
  
addEvent ( "returnTableContent", true ) 
  
addEventHandler ( "returnTableContent", root, 
  
    function ( content ) 
  
        for _, text in ipairs ( content ) do -- Loop the items from the 'content' table sent from the server side. 
  
            guiGridListSetItemText ( GridList, guiGridListAddRow ( GridList ), 1, text, false, false ) -- Add it to the gridlist. 
  
        end 
  
    end 
) 
  

Server :

name = { 
  
"Alone", 
"BH", 
"KSA" 
  
} 
  
  
addEvent ( "getTableContent", true ) 
  
addEventHandler ( "getTableContent", root, 
  
    function ( ) 
  
        triggerClientEvent ( client, "returnTableContent", client, name ) -- Send the 'myTable' content to the client side. 
  
    end 
  
) 
  
local root = getRootElement() 
  
addEventHandler('onResourceStart',resourceRoot, 
  
    function () 
  
           local Tabel = executeSQLQuery("CREATE TABLE IF NOT EXISTS xAlhajarii ( name )") 
  
            if ( Tabel ) then 
             
            outputDebugString( "Create Table xAlhajarii done") 
    end 
   end 
   end 
) 
------------------------------------------------------------------------------------------------------------ 
  
function Results() 
    local Results = executeSQLQuery("SELECT * FROM `xAlhajarii` WHERE PlayerName=?",getPlayerName ( name ) ) 
             
            if ( Results == "table" and #Results == 0 or not Results  ) then 
             
             executeSQLQuery ( "INSERT INTO `xAlhajarii` ( PlayerName ) VALUES(?,?,?,?)",getPlayerName(name)) 
             
            else 
             
            executeSQLQuery('UPDATE `xAlhajarii` SET  PlayerName =?',getPlayerName(name)) 
             
            end 
            end 
addEvent("gResults",true) 
addEventHandler("gResults",root,Results) 
------------------------------------------------------------------------------------------------------------------ 
addEvent("AreYouOpen?",true) 
addEventHandler("AreYouOpen?",root, 
function() 
Results() 
end) 
  

?

Edited by Guest

Try a little harder to be a little better

I Can Made To You Any Script For $

Skype : alhajarii-mtasa

Posted

No, you just mixed my code with yours, it's just an example, you must study it.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
No, you just mixed my code with yours, it's just an example, you must study it.

so my code all wrong ?

Try a little harder to be a little better

I Can Made To You Any Script For $

Skype : alhajarii-mtasa

Posted

Most of it, yes.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Yes, you are using column names which doesn't exist.

Eg: "PlayerName", but your column is "name".

Also, you are inserting for 4 columns, but your table has just one.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
Yes, you are using column names which doesn't exist.

Eg: "PlayerName", but your column is "name".

Also, you are inserting for 4 columns, but your table has just one.

but I need just 1 column

Never say i will not learn if you said that you're in the wrong section .

P.S : Good tut : https://forum.multitheftauto.com/viewtopic.php?f=148&t=38203.

bro in this example there is function for sql are canceled

I learn it but I can't to take column 1 just or I wil put like this ?

local Tabel = executeSQLQuery("CREATE TABLE IF NOT EXISTS xAlhajarii ( PlayerName ,? ,? )") 

Try a little harder to be a little better

I Can Made To You Any Script For $

Skype : alhajarii-mtasa

Posted

Doesn't matter it's both .

addEventHandler('onResourceStart',getResourceRootElement ( getThisResource (    )   ), 
    function (      ) 
        executeSQLQuery ( 'CREATE TABLE IF NOT EXISTS `Like UnLike System` ( MyCoulmn[1],MyCoulmn[2],MyCoulmn[3] )' ) 
    end 
) 

You can add \ remove column .

  

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