Jump to content

[Help]Grid list


3B00DG4MER

Recommended Posts

Posted

Hello,Today i made skin shop

How do i detect if player is not selected Any Row ?

i tried that

if ( SelectedSkin ~= nil  ) then 

SAF/SAO - 30%

Skype: Themerzoug2020

in-game name:3B00DG4MER

xOG7h1J.png

Posted

Compare the value with -1.

Returns

Returns the row and column indexes of the selected item if the specified grid list is valid and has a selected item, (-1, -1) if no item is selected, false otherwise.

Developer @ MYVAL

Posted
Compare the value with -1.
Returns

Returns the row and column indexes of the selected item if the specified grid list is valid and has a selected item, (-1, -1) if no item is selected, false otherwise.

Thanks i'll try

SAF/SAO - 30%

Skype: Themerzoug2020

in-game name:3B00DG4MER

xOG7h1J.png

Posted
YAW ^^

not work :'(

Can you post the code?

Maybe:

  
Selected = guiGridListGetSelectedItem(grid) 
if ( type ( Selected ) ~= number) then 
  
end 
  

My ingame nick is ~HyPeX~

BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager

gKhdyRJ.png

Posted
YAW ^^

not work :'(

Can you post the code?

        addEventHandler("onClientGUIClick",GUIEditor.window[1], 
            function(b) 
                if b == "left" then 
                if source == GUIEditor.button[2] then 
                guiSetVisible(GUIEditor.window[1],false) 
                showCursor(false) 
                elseif source == GUIEditor.button[1] then 
                local SelectedSkin = guiGridListGetItemText ( GUIEditor.gridlist[1], guiGridListGetSelectedItem ( GUIEditor.gridlist[1] ), 1 ) 
                if ( SelectedSkin ~= -1  ) then 
                if getElementModel(localPlayer) ~= tonumber(SelectedSkin) then 
                guiSetVisible(GUIEditor.window[1],false) 
                showCursor(false) 
                triggerServerEvent("onBuy",localPlayer,tonumber(SelectedSkin)) 
                else 
                exports["TopBarChat"]:sendClientMessage  ("#0000FF* #FF0000You already have that skin !",255,255,255,true) 
                end 
                else 
                exports["TopBarChat"]:sendClientMessage  ("#0000FF* #FF0000You must select a skin first !",255,255,255,true) 
                end 
            end 
            end 
            end 
            ) 

SAF/SAO - 30%

Skype: Themerzoug2020

in-game name:3B00DG4MER

xOG7h1J.png

Posted
addEventHandler("onClientGUIClick",GUIEditor.window[1], 
    function(b) 
        if b == "left" then 
            if source == GUIEditor.button[2] then 
                guiSetVisible(GUIEditor.window[1],false) 
                showCursor(false) 
            elseif source == GUIEditor.button[1] then 
                local selected = guiGridListGetSelectedItem ( GUIEditor.gridlist[1] ) 
                if ( selected  ) then 
                    local SelectedSkin = guiGridListGetItemText ( GUIEditor.gridlist[1], selected, 1 ) 
                    if getElementModel(localPlayer) ~= tonumber(SelectedSkin) then 
                        guiSetVisible(GUIEditor.window[1],false) 
                        showCursor(false) 
                        triggerServerEvent("onBuy",localPlayer,tonumber(SelectedSkin)) 
                    else 
                        exports["TopBarChat"]:sendClientMessage  ("#0000FF* #FF0000You already have that skin !",255,255,255,true) 
                    end 
                else 
                    exports["TopBarChat"]:sendClientMessage  ("#0000FF* #FF0000You must select a skin first !",255,255,255,true) 
                end 
            end 
        end 
    end 
) 

Returns the row and column indexes of the selected item if the specified grid list is valid and has a selected item, (-1, -1) if no item is selected, false otherwise.
Posted
addEventHandler("onClientGUIClick",GUIEditor.window[1], 
    function(b) 
        if b == "left" then 
            if source == GUIEditor.button[2] then 
                guiSetVisible(GUIEditor.window[1],false) 
                showCursor(false) 
            elseif source == GUIEditor.button[1] then 
                local selected = guiGridListGetSelectedItem ( GUIEditor.gridlist[1] ) 
                if ( selected  ) then 
                    local SelectedSkin = guiGridListGetItemText ( GUIEditor.gridlist[1], selected, 1 ) 
                    if getElementModel(localPlayer) ~= tonumber(SelectedSkin) then 
                        guiSetVisible(GUIEditor.window[1],false) 
                        showCursor(false) 
                        triggerServerEvent("onBuy",localPlayer,tonumber(SelectedSkin)) 
                    else 
                        exports["TopBarChat"]:sendClientMessage  ("#0000FF* #FF0000You already have that skin !",255,255,255,true) 
                    end 
                else 
                    exports["TopBarChat"]:sendClientMessage  ("#0000FF* #FF0000You must select a skin first !",255,255,255,true) 
                end 
            end 
        end 
    end 
) 

Returns the row and column indexes of the selected item if the specified grid list is valid and has a selected item, (-1, -1) if no item is selected, false otherwise.

Not work !! :x

SAF/SAO - 30%

Skype: Themerzoug2020

in-game name:3B00DG4MER

xOG7h1J.png

Posted (edited)

it's because the event handler is linked to the window, the source would always be the window and the event would only trigger if you click on the window.

Try this:

      addEventHandler("onClientGUIClick",guiRoot,function(b) 
            if b ~= "left" then return end 
            if source == GUIEditor.button[2] then 
                guiSetVisible(GUIEditor.window[1],false) 
                showCursor(false) 
            elseif source == GUIEditor.button[1] then 
                local row,column = guiGridListGetSelectedItem ( GUIEditor.gridlist[1] ) 
                local SelectedSkin = guiGridListGetItemText ( GUIEditor.gridlist[1],row , 1 ) 
                if row == -1 then 
                    exports["TopBarChat"]:sendClientMessage  ("#0000FF* #FF0000You must select a skin first !",255,255,255,true) 
                    return 
                end 
                if getElementModel(localPlayer) ~= tonumber(SelectedSkin) then 
                    guiSetVisible(GUIEditor.window[1],false) 
                    showCursor(false) 
                    triggerServerEvent("onBuy",localPlayer,tonumber(SelectedSkin)) 
                else 
                    exports["TopBarChat"]:sendClientMessage  ("#0000FF* #FF0000You already have that skin !",255,255,255,true) 
                end 
            end 
        end) 

Edited by Guest

My in-game name: Jaysds1

Retired CMG Scripter

World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode

Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/

 

sE5Qm.png

TiV3C.png

img.php?id=0&text=Lua%20Scripter

Posted
it's because the event handler is linked to the window, the source would always be the window and the event would only trigger if you click on the window.

Try this:

       addEventHandler("onClientGUIClick",guiRoot,function(b) 
            if b ~= "left" then return end 
            if source == GUIEditor.button[2] then 
                guiSetVisible(GUIEditor.window[1],false) 
                showCursor(false) 
            elseif source == GUIEditor.button[1] then 
                local SelectedSkin = guiGridListGetItemText ( GUIEditor.gridlist[1], guiGridListGetSelectedItem ( GUIEditor.gridlist[1] ), 1 ) 
                if ( SelectedSkin ~= -1  ) then 
                    if getElementModel(localPlayer) ~= tonumber(SelectedSkin) then 
                        guiSetVisible(GUIEditor.window[1],false) 
                        showCursor(false) 
                        triggerServerEvent("onBuy",localPlayer,tonumber(SelectedSkin)) 
                    else 
                        exports["TopBarChat"]:sendClientMessage  ("#0000FF* #FF0000You already have that skin !",255,255,255,true) 
                    end 
                else 
                    exports["TopBarChat"]:sendClientMessage  ("#0000FF* #FF0000You must select a skin first !",255,255,255,true) 
                end 
            end 
        end) 

i tried not work :(

SAF/SAO - 30%

Skype: Themerzoug2020

in-game name:3B00DG4MER

xOG7h1J.png

Posted
Oh, I misread your code.

You were checking if the text is -1 not if the selected row is -1.

Try my code again.

Not work!!

No one KNOW !!

SAF/SAO - 30%

Skype: Themerzoug2020

in-game name:3B00DG4MER

xOG7h1J.png

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