Jump to content

[SOLVED]GUI help is needed


SpecT

Recommended Posts

Posted (edited)

Hello guys!

So I'm working on an account management panel. I have made the interface with GUI - window,gridlist,buttons.

The problem is that that I don't get it how I should make the table of accounts which has to have exp, cash and IP address.

It is a big window with a gridlist - 4x columns - account name, exp, cash, ip address.

I should collect the data (accounts, exp, cash and ip address) into a table and send it to the client but I have no idea how to make that ... So could you guys help me?

Here is what I have done:

CLIENT

accountMng = { 
    accountList = {}, 
    window = {}, 
    button = {} 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        accountMng.window[1] = guiCreateWindow(0.22, 0.20, 0.55, 0.62, "Account Management", true) 
        guiWindowSetMovable(accountMng.window[1], false) 
        guiWindowSetSizable(accountMng.window[1], false) 
        guiSetAlpha(accountMng.window[1], 1.00) 
  
        accountMng.accountList[1] = guiCreateGridList(44, 45, 961, 515, false, accountMng.window[1]) 
                                    guiGridListAddColumn(accountMng.accountList[1], "Account name", 0.3) 
                                    guiGridListAddColumn(accountMng.accountList[1], "EXP", 0.2) 
                                    guiGridListAddColumn(accountMng.accountList[1], "Cash", 0.2) 
                                    guiGridListAddColumn(accountMng.accountList[1], "IP", 0.2) 
  
        accountMng.button[2] = guiCreateButton(443, 591, 169, 43, "Delete account", false, accountMng.window[1]) 
        guiSetProperty(accountMng.button[2], "NormalTextColour", "FFAAAAAA") 
        accountMng.button[3] = guiCreateButton(942, 623, 103, 35, "Close", false, accountMng.window[1]) 
        guiSetProperty(accountMng.button[2], "NormalTextColour", "FFAAAAAA") 
  
        showCursor(true) 
    end 
) 

Edited by Guest
Posted
use
getAccounts () 

Yeah, but that won't help me. I don't want just to get the accounts... Please read what I wrote. I will get all the accounts but how to make it show the data I mentioned above on the same row?

Posted

:3 example

-- Server side

function checkAccountsData() 
    newTable = {} 
        for k,v in ipairs(getAccounts()) do 
        -- Example account name , cash etc ... 
        local accname = getAccountName(v)  
        local exp = -- account data here  
        local cash = -- the same here  
            table.insert(newTable,{accname,exp,cash})  
        end 
    triggerClientEvent(client, "accounts.showGUI", client, newTable) 
end 
-- add your event handler  

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted
:3 example

-- Server side

function checkAccountsData() 
    newTable = {} 
        for k,v in ipairs(getAccounts()) do 
        local acc = v 
        -- Example account name , cash etc ... 
        local name = getAccountName(v)  
        local exp = -- account data here  
        local cash = -- the same here  
            table.insert(newTable,{name,exp,cash})  
        end 
    triggerClientEvent(client, "accounts.showGUI", client, newTable) 
end 
-- add your event handler  

Ow ... that's exactly what I needed! Thanks mate ;3

If I have any problems I will write again here so I won't mark it as solved.

Posted

Pfff I can't now insert all the data in the gridlist ... :x

I have never worked with the GUI and now ..

Could you just show me how to insert the values from the table in the gridlist and columns ?

Posted
Pfff I can't now insert all the data in the gridlist ... :x

I have never worked with the GUI and now ..

Could you just show me how to insert the values from the table in the gridlist and columns ?

No i will never help you like that try to do it by yourself then post your code here , and i will help you

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted

Your table looks liek that

table = { 
{ name, exp, cash }, 
{ name, exp, cash}, 
... 
} 

It's easy to loop table and show it's values.

for _, v in pairs ( table ) do 
local name, exp, cash = unpack ( v ) 
-- now you have 3 values, you have to insert it to gridlist using guiGridListAddRow 
end 

Posted

-- Server side

Example with Command

function checkAccountsData(player) 
    newTable = {} 
        for k,v in ipairs(getAccounts()) do 
        -- Example account name , cash etc ... 
        local name = getAccountName(v)  
        local exp = -- account data here  
        local cash = -- the same here  
            table.insert(newTable,{name,exp,cash})  
        end 
    triggerClientEvent(player, "accounts.showGUI",player, newTable) 
end  
addCommandHandler("accounts",checkAccountsData) 

-- Client side

accountMng = { 
    accountList = {}, 
    window = {}, 
    button = {} 
} 
  
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        accountMng.window[1] = guiCreateWindow(0.22, 0.20, 0.55, 0.62, "Account Management", true) 
        guiWindowSetMovable(accountMng.window[1], false) 
        guiWindowSetSizable(accountMng.window[1], false) 
        guiSetAlpha(accountMng.window[1], 1.00) 
        guiSetVisible(accountMng.window[1],false) 
        accountMng.accountList[1] = guiCreateGridList(44, 45, 961, 515, false, accountMng.window[1]) 
        guiGridListAddColumn(accountMng.accountList[1], "Account name", 0.3) 
        guiGridListAddColumn(accountMng.accountList[1], "EXP", 0.2) 
        guiGridListAddColumn(accountMng.accountList[1], "Cash", 0.2) 
        guiGridListAddColumn(accountMng.accountList[1], "IP", 0.2) 
        accountMng.button[2] = guiCreateButton(443, 591, 169, 43, "Delete account", false, accountMng.window[1]) 
        guiSetProperty(accountMng.button[2], "NormalTextColour", "FFAAAAAA") 
        accountMng.button[3] = guiCreateButton(942, 623, 103, 35, "Close", false, accountMng.window[1]) 
        guiSetProperty(accountMng.button[2], "NormalTextColour", "FFAAAAAA") 
    end 
) 
  
  
function AccountsData(Thetable) 
    guiSetVisible(accountMng.window[1], not guiGetVisible(accountMng.window[1])) 
    showCursor(guiGetVisible(accountMng.window[1])) 
    guiGridListClear(accountMng.accountList[1]) 
    for k,v in pairs(Thetable) do 
        local row = guiGridListAddRow(accountMng.accountList[1]) 
        guiGridListSetItemText(accountMng.accountList[1], row,1, tostring(v[1]), false, false) -- Column 1 
        guiGridListSetItemText(accountMng.accountList[1], row,2, tostring(v[2]), false, false) -- Column 1 
        guiGridListSetItemText(accountMng.accountList[1], row,2, tostring(v[3]), false, false) -- Column 1 
    end 
end 
addEvent("accounts.showGUI", true) 
addEventHandler('accounts.showGUI',root,AccountsData) 

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted
-- Server side

Example with Command

function checkAccountsData(player) 
    newTable = {} 
        for k,v in ipairs(getAccounts()) do 
        -- Example account name , cash etc ... 
        local name = getAccountName(v)  
        local exp = -- account data here  
        local cash = -- the same here  
            table.insert(newTable,{name,exp,cash})  
        end 
    triggerClientEvent(player, "accounts.showGUI",player, newTable) 
end  
addCommandHandler("accounts",checkAccountsData) 

-- Client side

accountMng = { 
    accountList = {}, 
    window = {}, 
    button = {} 
} 
  
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        accountMng.window[1] = guiCreateWindow(0.22, 0.20, 0.55, 0.62, "Account Management", true) 
        guiWindowSetMovable(accountMng.window[1], false) 
        guiWindowSetSizable(accountMng.window[1], false) 
        guiSetAlpha(accountMng.window[1], 1.00) 
        guiSetVisible(accountMng.window[1],false) 
        accountMng.accountList[1] = guiCreateGridList(44, 45, 961, 515, false, accountMng.window[1]) 
        guiGridListAddColumn(accountMng.accountList[1], "Account name", 0.3) 
        guiGridListAddColumn(accountMng.accountList[1], "EXP", 0.2) 
        guiGridListAddColumn(accountMng.accountList[1], "Cash", 0.2) 
        guiGridListAddColumn(accountMng.accountList[1], "IP", 0.2) 
        accountMng.button[2] = guiCreateButton(443, 591, 169, 43, "Delete account", false, accountMng.window[1]) 
        guiSetProperty(accountMng.button[2], "NormalTextColour", "FFAAAAAA") 
        accountMng.button[3] = guiCreateButton(942, 623, 103, 35, "Close", false, accountMng.window[1]) 
        guiSetProperty(accountMng.button[2], "NormalTextColour", "FFAAAAAA") 
    end 
) 
  
  
function AccountsData(Thetable) 
    guiSetVisible(accountMng.window[1], not guiGetVisible(accountMng.window[1])) 
    showCursor(guiGetVisible(accountMng.window[1])) 
    guiGridListClear(accountMng.accountList[1]) 
    for k,v in pairs(Thetable) do 
        local row = guiGridListAddRow(accountMng.accountList[1]) 
        guiGridListSetItemText(accountMng.accountList[1], row,1, tostring(v[1]), false, false) -- Column 1 
        guiGridListSetItemText(accountMng.accountList[1], row,2, tostring(v[2]), false, false) -- Column 1 
        guiGridListSetItemText(accountMng.accountList[1], row,2, tostring(v[3]), false, false) -- Column 1 
    end 
end 
addEvent("accounts.showGUI", true) 
addEventHandler('accounts.showGUI',root,AccountsData) 

I tried something similar but I get errors "table expected, got userdata". And when I check for the type of the table that was sent from the server it says it's userdata.

Posted

I tried something similar but I get errors "table expected, got userdata". And when I check for the type of the table that was sent from the server it says it's userdata.

try to use my code

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted

I tried something similar but I get errors "table expected, got userdata". And when I check for the type of the table that was sent from the server it says it's userdata.

try to use my code

I found my mistake ... Thanks again guys, especially Walid for the spent time.

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