3B00DG4MER Posted March 29, 2014 Posted March 29, 2014 Hello,Today i made skin shop How do i detect if player is not selected Any Row ? i tried that if ( SelectedSkin ~= nil ) then
Alexs Posted March 29, 2014 Posted March 29, 2014 Compare the value with -1. ReturnsReturns 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.
3B00DG4MER Posted March 29, 2014 Author Posted March 29, 2014 Compare the value with -1. ReturnsReturns 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
.:HyPeX:. Posted March 30, 2014 Posted March 30, 2014 YAW ^^ not work Can you post the code? Maybe: Selected = guiGridListGetSelectedItem(grid) if ( type ( Selected ) ~= number) then end
3B00DG4MER Posted March 30, 2014 Author Posted March 30, 2014 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 )
WhoAmI Posted March 30, 2014 Posted March 30, 2014 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.
3B00DG4MER Posted March 30, 2014 Author Posted March 30, 2014 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 !!
Jaysds1 Posted March 30, 2014 Posted March 30, 2014 (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 March 30, 2014 by Guest
3B00DG4MER Posted March 30, 2014 Author Posted March 30, 2014 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
Jaysds1 Posted March 30, 2014 Posted March 30, 2014 Oh, I misread your code. You were checking if the text is -1 not if the selected row is -1. Try my code again.
3B00DG4MER Posted March 30, 2014 Author Posted March 30, 2014 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 !!
3B00DG4MER Posted March 30, 2014 Author Posted March 30, 2014 i have fixed thanks to all i tried that if tonumber(SelectedSkin) then
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