Prat Posted July 31, 2013 Share Posted July 31, 2013 Hello guys , today i i tried to make a gui that has 2 buttons 1 button to get 200 health costs 3k , and other to close the GUI, activating this will be through "onMarkerHit" furthermore , you can tell me what is the wrong with this and fix it Client side : GUIEditor = { button = {}, window = {}, label = {} } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(537, 244, 298, 234, "buy Health", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.button[1] = guiCreateButton(9, 154, 129, 70, "Buy Health\n($3.000)", false, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFAAAAAA") GUIEditor.button[2] = guiCreateButton(159, 154, 129, 70, "Close", false, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FFAAAAAA") GUIEditor.label[1] = guiCreateLabel(16, 25, 262, 115, "You can buy 200 health from here.\n\n200 HP costs $3.000", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[1], "default-bold-small") guiLabelSetColor(GUIEditor.label[1], 41, 255, 0) end ) addEventHandler ( "onClientGUIClick",root, function () HealthBuy = guiCreateButton(9, 154, 129, 70, "Buy Health\n($3.000)", false, GUIEditor.window[1]) ttriggerServerEvent ( "onHealth", localPlayer ) function OpenWin() healmarker = createMarker ( 2024.6821289063, -1411.6774902344, 16.9921875,) if guiGetVisible ( GUIEditor.window[1] ) then guiSetVisible ( GUIEditor.window[1], false ) showCursor(false) else guiSetVisible ( GUIEditor.window[1], true ) showCursor(true) end end BindKey ("F2", "down", OpenWin) server side : addEvent ("onHealth", true) addEventHandler ("onHealth", getRootElement(), function() local = getPlayerAccount ( source ) setPedStat(source, 24, 1000) setElementHealth ( source, 200 ) end some reason stopping it from working , and hope you guys help me out on this. Thank you for reading this Link to comment
EstrategiaGTA Posted July 31, 2013 Share Posted July 31, 2013 Hello, try this. Client: addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(537, 244, 298, 234, "buy Health", false) guiWindowSetSizable(GUIEditor.window[1], false) guiSetVisible(GUIEditor.window[1], false) GUIEditor.button[1] = guiCreateButton(9, 154, 129, 70, "Buy Health\n($3.000)", false, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFAAAAAA") GUIEditor.button[2] = guiCreateButton(159, 154, 129, 70, "Close", false, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FFAAAAAA") GUIEditor.label[1] = guiCreateLabel(16, 25, 262, 115, "You can buy 200 health from here.\n\n200 HP costs $3.000", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[1], "default-bold-small") guiLabelSetColor(GUIEditor.label[1], 41, 255, 0) end ) function ff () triggerServerEvent ( "onHealth", localPlayer ) end addEventHandler ( "onClientGUIClick", GUIEditor.button[1], ff) addEvent("show",true) addEventHandler("show", localPlayer, function () if not guiGetVisible ( GUIEditor.window[1] ) then guiSetVisible ( GUIEditor.window[1], true ) showCursor(true) end end ) Server: addEvent ("onHealth", true) addEventHandler ("onHealth", getRootElement(), function() setPedStat(source, 24, 1000) setElementHealth ( source, 200 ) end ) themarker = createMarker ( 2024.6821289063, -1411.6774902344, 16.9921875, "cylinder", 2, 255, 0, 0 ) function lol ( ) triggerClientEvent("show", source) end addEventHandler("onMarkerHit", themarker, lol) I deleted the bindKey and put "onMarkerHit" event, because you said you want it like that. Try it. Link to comment
DNL291 Posted August 1, 2013 Share Posted August 1, 2013 Try this: Client GUIEditor = { button = {}, window = {}, label = {} } local healmarker = createMarker( 2024.6821, -1411.6774, 16.9921, "cylinder", 2, 0, 255, 0) addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(537, 244, 298, 234, "buy Health", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.button[1] = guiCreateButton(9, 154, 129, 70, "Buy Health\n($3.000)", false, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFAAAAAA") GUIEditor.button[2] = guiCreateButton(159, 154, 129, 70, "Close", false, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FFAAAAAA") GUIEditor.label[1] = guiCreateLabel(16, 25, 262, 115, "You can buy 200 health from here.\n\n200 HP costs $3.000", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[1], "default-bold-small") guiLabelSetColor(GUIEditor.label[1], 41, 255, 0) addEventHandler( "onClientGUIClick", GUIEditor.button[1], buyHealth, false ) addEventHandler( "onClientGUIClick", GUIEditor.button[2], closeWindow, false ) addEventHandler( "onClientMarkerHit", healmarker, onMarkerHit ) end ) function buyHealth() triggerServerEvent( "onHealth", localPlayer ) end function closeWindow() guiSetVisible( GUIEditor.window[1], false ) showCursor(false) end function onMarkerHit() guiSetVisible( GUIEditor.window[1], true ) showCursor(true) end Server addEvent ("onHealth", true) addEventHandler ("onHealth", getRootElement(), function() setPedStat(source, 24, 999) setElementHealth ( source, 200 ) end ) Link to comment
Prat Posted August 1, 2013 Author Share Posted August 1, 2013 @EstrategiaGTA Thanks for your help but it didn't work. @DNL291 it works perfectly thanks to you , i really appreciate it bro. but one more thing , i need to take 3000$ from the player who clicks "buy" the health. i will appreciate that you helped me alot Link to comment
xXMADEXx Posted August 1, 2013 Share Posted August 1, 2013 use: addEvent addEventHandler triggerServerEvent takePlayerMoney Link to comment
Prat Posted August 1, 2013 Author Share Posted August 1, 2013 use: addEvent addEventHandler triggerServerEvent takePlayerMoney excuse me , i'm beginner and i cant understand what you said. i tried those functions above but didn't work, so i need explain on this. Thank you. Link to comment
aim-killer Posted August 1, 2013 Share Posted August 1, 2013 excuse me , i'm beginner and i cant understand what you said. i tried those functions above but didn't work, so i need explain on this. Thank you. you need to create an event that takes money on serverside which has to be triggered when you click the button addEvent -- create event addEventHandler -- addEventHandler for the event created triggerServerEvent -- when button clicked trigger server event takePlayerMoney -- take money (serverside funtion) you can see exampled on wiki Link to comment
EstrategiaGTA Posted August 1, 2013 Share Posted August 1, 2013 Use: if getPlayerMoney takePlayerMoney Link to comment
Prat Posted August 1, 2013 Author Share Posted August 1, 2013 Ok thanks guys, i will try it now. 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