Matevsz Posted May 29, 2016 Share Posted May 29, 2016 Hello, I am trying to close the gridlist using the "backspace" when pressed nothing happens addEventHandler("onClientResourceStart", resourceRoot, function() gridlist = guiCreateGridList(1350, 383, 236, 293, false) guiSetVisible(gridlist, false) end) function CloseGUI(keyState) if keyState == "down" then showCursor(false) guiSetVisible(gridlist, false) setCameraTarget(getLocalPlayer(), getLocalPlayer()) end end bindKey("backspace", "down", CloseGUI) It is part of the code. Link to comment
[iMr]-W[i]Fi,.! Posted May 29, 2016 Share Posted May 29, 2016 gridlist = guiCreateGridList(1350, 383, 236, 293, false) guiSetVisible(gridlist,true) function CloseGUI(keyState) if keyState == "down" then showCursor(false) guiSetVisible(gridlist, false) setCameraTarget(getLocalPlayer(), getLocalPlayer()) end end bindKey("backspace", "down", CloseGUI) Link to comment
Moderators Citizen Posted May 29, 2016 Moderators Share Posted May 29, 2016 gridlist = guiCreateGridList(1350, 383, 236, 293, false) guiSetVisible(gridlist,true) function CloseGUI(keyState) if keyState == "down" then showCursor(false) guiSetVisible(gridlist, false) setCameraTarget(getLocalPlayer(), getLocalPlayer()) end end bindKey("backspace", "down", CloseGUI) This code has the exact same behavior, you changed nothing ...____________________________________________________________________________________ @Matevsz: The 1st argument your bound function receive is not the keyState but the name of the key you pressed (here your "keyState" value will be "backspace"). Naming the 1st argument keyState won't make it get the keyState value, only the position matters. Fixed code (I only modified line 7): addEventHandler("onClientResourceStart", resourceRoot, function() gridlist = guiCreateGridList(1350, 383, 236, 293, false) guiSetVisible(gridlist, false) end) function CloseGUI(key, keyState) if keyState == "down" then showCursor(false) guiSetVisible(gridlist, false) setCameraTarget(getLocalPlayer(), getLocalPlayer()) end end bindKey("backspace", "down", CloseGUI) PS: Also please indent your code correctly so it's easier for us to read your code (and especially for you if you need to read that code later). Regards, Citizen Link to comment
Matevsz Posted May 29, 2016 Author Share Posted May 29, 2016 wow, thanks, I have another problem, because I have created ped, and it is changing skins, if you push "backspace" I used to "destroyElement (ped) and how once I enter the marker is no longer a Link to comment
Moderators Citizen Posted May 29, 2016 Moderators Share Posted May 29, 2016 I don't understand, can you explain it better ? Link to comment
Matevsz Posted May 29, 2016 Author Share Posted May 29, 2016 local ped = createPed(0, 0,0,0, 87.9990844) setElementInterior(ped, 18) addEventHandler("onClientResourceStart", resourceRoot, function() gridlist = guiCreateGridList(1350, 383, 236, 293, false) guiSetVisible(gridlist, false) end) function ShowGUI(hitPlayer) if hitPlayer == localPlayer then showCursor(true) guiSetVisible(gridlist, true) setElementPosition(ped, 180.10000610352, -88.199996948242, 1002) setCameraMatrix(174.46969604492, -88.212097167969, 1003.6256713867, 175.40690612793, -88.209663391113, 1003.2769165039) end end addEventHandler("onClientMarkerHit", markerKupnaSkina2, ShowGUI) function CloseGUI(key, keyState) if keyState == "down" then showCursor(false) guiSetVisible(gridlist, false) setCameraTarget(getLocalPlayer(), getLocalPlayer()) destroyElement(ped) end end bindKey("backspace", "down", CloseGUI) How Depress the "backspace" and I go back to that marker (ped) is no longer I used the wrong "destroyElement (ped)"? Link to comment
Moderators Citizen Posted May 29, 2016 Moderators Share Posted May 29, 2016 Your english doesn't let me understand what you are trying to do with the ped. Maybe you should ask your question into your regional sub-forum: Poland / Polski Calling destroyElement on the ped will make it disapear for ever. You should probably do this ?: setElementPosition(ped, 0, 0, 0) Link to comment
Matevsz Posted May 29, 2016 Author Share Posted May 29, 2016 Sorry, for my English Thanks, now the last thing buying a skin. function ChangeSkin(state) if state == "left" then local skin = guiGridListGetItemText(gridlist, guiGridListGetSelectedItem(gridlist), 2) setElementModel(ped, skin) end end addEventHandler("onClientGUIClick", getRootElement(getThisResource), ChangeSkin) function BuySkin(key, keyState) if keyState == "down" then showCursor(false) guiSetVisible(gridlist, false) setCameraTarget(getLocalPlayer(), getLocalPlayer()) setElementPosition(ped, 0, 0, 0) setElementModel(localPlayer, skin) end end bindKey("enter", "down", BuySkin) something like this? 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