FlyingSpoon Posted November 30, 2014 Share Posted November 30, 2014 Well, what I would like to do is that when I click on my Army Skin 1, it would set me to Skin ID 30, you can look at my code, I never used Grid List before, I thought I would try it! If anyone can help me I would appreciate it! Client Side wPanel = guiCreateWindow(14, 203, 176, 130, "ZA 1.0 - Panel", false) guiWindowSetSizable(wPanel, false) btnChar = guiCreateButton(14, 35, 150, 25, "Characters", false, wPanel) btnVeh = guiCreateButton(14, 86, 150, 25, "Vehicles", false, wPanel) wChar = guiCreateWindow(234, 178, 386, 170, "ZA 1.0 - Characters", false) btnClose = guiCreateButton(306, 134, 70, 26, "Close", false, wChar) guiWindowSetSizable(wChar, false) cGrid = guiCreateGridList(9, 23, 369, 104, false, wChar) guiGridListAddColumn(cGrid, "Characters", 0.9) for i = 1, 4 do guiGridListAddRow(cGrid) end guiGridListSetItemText(cGrid, 0, 1, "Army Skin 1", false, false) guiGridListSetItemText(cGrid, 1, 1, "Army Skin 2", false, false) guiGridListSetItemText(cGrid, 2, 1, "Army Skin 3", false, false) guiGridListSetItemText(cGrid, 3, 1, "Army Skin 5", false, false) guiSetVisible( wChar, false) guiSetVisible(wPanel, false) showCursor(false) bindKey('f1','down', function() guiSetVisible(wPanel, not guiGetVisible(wPanel)) showCursor(not isCursorShowing()) end ) function btnChars() if source == btnChar then guiSetVisible( wChar, true ) else if source == btnClose then guiSetVisible( wChar, false) end end end addEventHandler("onClientGUIClick", getRootElement(), btnChars) function setSkin() local row, col = guiGridListGetSelectedItem(cGrid) if ( row == 0 ) and ( col == 1) then setElementModel(source, 30) end end addEventHandler("onClientGUIClick", getRootElement(), setSkin) So if I click, Army Skin 1 then it would set my skin to ID 30. Link to comment
novo Posted November 30, 2014 Share Posted November 30, 2014 setElementModel(source, 30) onClientGUIClick - The source of this event is the GUI element that was clicked. You should've used "localPlayer" instead of 'source' there. Link to comment
FlyingSpoon Posted November 30, 2014 Author Share Posted November 30, 2014 So how can I fix it? Link to comment
novo Posted November 30, 2014 Share Posted November 30, 2014 Well, as I told you above, you should do the following: setElementData(localPlayer, 30) -- wPanel = guiCreateWindow(14, 203, 176, 130, "ZA 1.0 - Panel", false) guiWindowSetSizable(wPanel, false) btnChar = guiCreateButton(14, 35, 150, 25, "Characters", false, wPanel) btnVeh = guiCreateButton(14, 86, 150, 25, "Vehicles", false, wPanel) wChar = guiCreateWindow(234, 178, 386, 170, "ZA 1.0 - Characters", false) btnClose = guiCreateButton(306, 134, 70, 26, "Close", false, wChar) guiWindowSetSizable(wChar, false) cGrid = guiCreateGridList(9, 23, 369, 104, false, wChar) guiGridListAddColumn(cGrid, "Characters", 0.9) for i = 1, 4 do guiGridListAddRow(cGrid) end guiGridListSetItemText(cGrid, 0, 1, "Army Skin 1", false, false) guiGridListSetItemText(cGrid, 1, 1, "Army Skin 2", false, false) guiGridListSetItemText(cGrid, 2, 1, "Army Skin 3", false, false) guiGridListSetItemText(cGrid, 3, 1, "Army Skin 5", false, false) guiSetVisible( wChar, false) guiSetVisible(wPanel, false) showCursor(false) bindKey('f1','down', function() guiSetVisible(wPanel, not guiGetVisible(wPanel)) showCursor(not isCursorShowing()) end ) function btnChars() if source == btnChar then guiSetVisible( wChar, true ) else if source == btnClose then guiSetVisible( wChar, false) end end end addEventHandler("onClientGUIClick", getRootElement(), btnChars) function setSkin() local row, col = guiGridListGetSelectedItem(cGrid) if ( row == 0 ) and ( col == 1) then setElementModel(localPlayer, 30) end end addEventHandler("onClientGUIClick", getRootElement(), setSkin) Link to comment
FlyingSpoon Posted November 30, 2014 Author Share Posted November 30, 2014 Thanks, I am very noobish at gridlist Thanks +1 Link to comment
novo Posted November 30, 2014 Share Posted November 30, 2014 You're welcome, either way make sure to be aware of 'sources' you're using from now on. Link to comment
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