Lloyd Logan Posted January 12, 2013 Posted January 12, 2013 Hey, so i created a a script so that when you enter a marker the gui comes up and you can buy a veh! The problem is that the GUI is always there and nothing happens when you click "BUY" Thanks! GUIEditor = { button = {}, label = {}, window = {}, } addEventHandler("onClientResourceStart", resourceRoot, function() Window = guiCreateWindow(385, 158, 478, 385, "Buy A Vehicle", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.label[1] = guiCreateLabel(26, 98, 326, 34, "Infernous : $30000", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[1], "sa-header") GUIEditor.button[1] = guiCreateButton(373, 108, 86, 29, "BUY", false, GUIEditor.window[1]) end ) local buyVeh = createMarker(1940.5185546875, -1707.1162109375, 13.3828125, "cylinder", 1.5, 255, 255, 0, 170) function visibleGui(thePlayer) guiSetVisible(Window, true) showCursor ( true ) end addEventHandler("onMarkerHit", buyVeh, visibleGui) function onClickBtn ( button, state ) if (source == GUIEditor.button[1]) then local x, y, z = getElementPosition(thePlayer) createVehicle(411, x + 2, y, z) utputChatBox("You Have successfully bought an Infernous!", thePlayer) takePlayerMoney ( thePlayer, 30000) end end If you need an Intermediate scripter feel free to PM me as I will accept "almost" any job, STATUS: UNAVAILABLE SCOTLAND, my hometown, and the Home of GTA!
Lloyd Logan Posted January 12, 2013 Author Posted January 12, 2013 You forgot the event onClientGUIClick So, function onClickBtn ( button, state ) if (source == GUIEditor.button[1]) then local x, y, z = getElementPosition(thePlayer) createVehicle(411, x + 2, y, z) outputChatBox("You Have successfully bought an Infernous!", thePlayer) takePlayerMoney ( thePlayer, 30000) end end Is wrong :L I'm not too sure If you need an Intermediate scripter feel free to PM me as I will accept "almost" any job, STATUS: UNAVAILABLE SCOTLAND, my hometown, and the Home of GTA!
Castillo Posted January 13, 2013 Posted January 13, 2013 When you take money client side, it won't sync with the server side, so it won't really take it, it has to be server side. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Lloyd Logan Posted January 13, 2013 Author Posted January 13, 2013 When you take money client side, it won't sync with the server side, so it won't really take it, it has to be server side. Okay, so will i create a server side event for the money, then trigger it server side? If you need an Intermediate scripter feel free to PM me as I will accept "almost" any job, STATUS: UNAVAILABLE SCOTLAND, my hometown, and the Home of GTA!
Castillo Posted January 13, 2013 Posted January 13, 2013 Create an event server side, then trigger it from the client. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Lloyd Logan Posted January 13, 2013 Author Posted January 13, 2013 Create an event server side, then trigger it from the client. That's what i meant, sorry! If you need an Intermediate scripter feel free to PM me as I will accept "almost" any job, STATUS: UNAVAILABLE SCOTLAND, my hometown, and the Home of GTA!
MR.S3D Posted January 13, 2013 Posted January 13, 2013 use this in server side createVehicle(411, x + 2, y, z) Because in client side local player only See the car Welcom to my server Q.5 Current game type in my server Drift my Email : [email protected] Programming level: 90%
Lloyd Logan Posted January 13, 2013 Author Posted January 13, 2013 Okay, i'll put aside everything apart from the GUI itself, how do make this appear when Marker is hit? Clien: GUIEditor = { button = {}, label = {}, window = {}, } addEventHandler("onClientResourceStart", resourceRoot, function() Window = guiCreateWindow(385, 158, 478, 385, "Buy A Vehicle", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.label[1] = guiCreateLabel(26, 98, 326, 34, "Infernous : $30000", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[1], "sa-header") bBuy = guiCreateButton(373, 108, 86, 29, "BUY", false, GUIEditor.window[1]) end ) local buyVeh = createMarker(1940.5185546875, -1707.1162109375, 13.3828125, "cylinder", 1.5, 255, 255, 0, 170) function showGUII() guiSetVisible(Window,true) showCursor(true) end addEvent("showGUII",true) addEventHandler("showGUII", getRootElement(), showGUII) Server: function showGUIp(hitPlayer) setElementFrozen(source, true) triggerClientEvent (hitPlayer,"showGUII") end addEventHandler("onClientMarkerHit", buyMark, showGUIp) If you need an Intermediate scripter feel free to PM me as I will accept "almost" any job, STATUS: UNAVAILABLE SCOTLAND, my hometown, and the Home of GTA!
Castillo Posted January 13, 2013 Posted January 13, 2013 All client side: GUIEditor = { button = {}, label = {}, window = {}, } addEventHandler("onClientResourceStart", resourceRoot, function() Window = guiCreateWindow(385, 158, 478, 385, "Buy A Vehicle", false) guiWindowSetSizable(GUIEditor.window[1], false) guiSetVisible(GUIEditor.window[1], false) GUIEditor.label[1] = guiCreateLabel(26, 98, 326, 34, "Infernous : $30000", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[1], "sa-header") bBuy = guiCreateButton(373, 108, 86, 29, "BUY", false, GUIEditor.window[1]) end ) local buyVeh = createMarker(1940.5185546875, -1707.1162109375, 13.3828125, "cylinder", 1.5, 255, 255, 0, 170) function showGUIp(hitPlayer) if ( hitPlayer == localPlayer ) then setElementFrozen ( localPlayer, true ) guiSetVisible ( Window, true ) showCursor ( true ) end end addEventHandler ( "onClientMarkerHit", buyVeh, showGUIp ) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Lloyd Logan Posted January 13, 2013 Author Posted January 13, 2013 All client side: GUIEditor = { button = {}, label = {}, window = {}, } addEventHandler("onClientResourceStart", resourceRoot, function() Window = guiCreateWindow(385, 158, 478, 385, "Buy A Vehicle", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.label[1] = guiCreateLabel(26, 98, 326, 34, "Infernous : $30000", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[1], "sa-header") bBuy = guiCreateButton(373, 108, 86, 29, "BUY", false, GUIEditor.window[1]) end ) local buyVeh = createMarker(1940.5185546875, -1707.1162109375, 13.3828125, "cylinder", 1.5, 255, 255, 0, 170) function showGUIp(hitPlayer) if ( hitPlayer == localPlayer ) then setElementFrozen ( localPlayer, true ) guiSetVisible ( Window, true ) showCursor ( true ) end end addEventHandler ( "onClientMarkerHit", buyVeh, showGUIp ) The GU is still there when i login? If you need an Intermediate scripter feel free to PM me as I will accept "almost" any job, STATUS: UNAVAILABLE SCOTLAND, my hometown, and the Home of GTA!
Castillo Posted January 13, 2013 Posted January 13, 2013 You had forgot to hide it after create it, copy the code again. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Lloyd Logan Posted January 13, 2013 Author Posted January 13, 2013 You had forgot to hide it after create it, copy the code again. Hats off to you! Thanks If you need an Intermediate scripter feel free to PM me as I will accept "almost" any job, STATUS: UNAVAILABLE SCOTLAND, my hometown, and the Home of GTA!
Castillo Posted January 13, 2013 Posted January 13, 2013 You're welcome. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Lloyd Logan Posted January 13, 2013 Author Posted January 13, 2013 You're welcome. How would i get rid of everything? function initGUI() cButton = guiSetVisible ( Window, false ) cButton = guiSetInputEnabled(false) cButton = showCursor ( false ) end addEventHandler ( "onClientGUIClick", cButton) Or How would i do use destroyElement? Thanks Lloyd If you need an Intermediate scripter feel free to PM me as I will accept "almost" any job, STATUS: UNAVAILABLE SCOTLAND, my hometown, and the Home of GTA!
Castillo Posted January 13, 2013 Posted January 13, 2013 You just need to hide the window. P.S: You put "GUIEditor.window[1]" instead of "Window" as parent. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Lloyd Logan Posted January 13, 2013 Author Posted January 13, 2013 You just need to hide the window.P.S: You put "GUIEditor.window[1]" instead of "Window" as parent. I used this, but it didn't work? function initGUI() cButton = guiSetVisible ( Window, false ) cButton = guiSetInputEnabled(false) cButton = showCursor ( false ) end addEventHandler ( "onClientGUIClick", cButton) If you need an Intermediate scripter feel free to PM me as I will accept "almost" any job, STATUS: UNAVAILABLE SCOTLAND, my hometown, and the Home of GTA!
Castillo Posted January 13, 2013 Posted January 13, 2013 GUIEditor = { button = {}, label = {}, window = {}, } addEventHandler("onClientResourceStart", resourceRoot, function() Window = guiCreateWindow(385, 158, 478, 385, "Buy A Vehicle", false) guiWindowSetSizable(GUIEditor.window[1], false) guiSetVisible(GUIEditor.window[1], false) GUIEditor.label[1] = guiCreateLabel(26, 98, 326, 34, "Infernous : $30000", false, Window) guiSetFont(GUIEditor.label[1], "sa-header") bBuy = guiCreateButton(373, 108, 86, 29, "BUY", false, Window) end ) local buyVeh = createMarker(1940.5185546875, -1707.1162109375, 13.3828125, "cylinder", 1.5, 255, 255, 0, 170) function showGUIp(hitPlayer) if ( hitPlayer == localPlayer ) then setElementFrozen ( localPlayer, true ) guiSetVisible ( Window, true ) showCursor ( true ) end end addEventHandler ( "onClientMarkerHit", buyVeh, showGUIp ) function initGUI ( ) guiSetVisible ( Window, false ) guiSetInputEnabled ( false ) showCursor ( false ) end addEventHandler ( "onClientGUIClick", cButton, initGUI, false ) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Lloyd Logan Posted January 13, 2013 Author Posted January 13, 2013 GUIEditor = { button = {}, label = {}, window = {}, } addEventHandler("onClientResourceStart", resourceRoot, function() Window = guiCreateWindow(385, 158, 478, 385, "Buy A Vehicle", false) guiWindowSetSizable(GUIEditor.window[1], false) guiSetVisible(GUIEditor.window[1], false) GUIEditor.label[1] = guiCreateLabel(26, 98, 326, 34, "Infernous : $30000", false, Window) guiSetFont(GUIEditor.label[1], "sa-header") bBuy = guiCreateButton(373, 108, 86, 29, "BUY", false, Window) end ) local buyVeh = createMarker(1940.5185546875, -1707.1162109375, 13.3828125, "cylinder", 1.5, 255, 255, 0, 170) function showGUIp(hitPlayer) if ( hitPlayer == localPlayer ) then setElementFrozen ( localPlayer, true ) guiSetVisible ( Window, true ) showCursor ( true ) end end addEventHandler ( "onClientMarkerHit", buyVeh, showGUIp ) function initGUI ( ) guiSetVisible ( Window, false ) guiSetInputEnabled ( false ) showCursor ( false ) end addEventHandler ( "onClientGUIClick", cButton, initGUI, false ) Thank you! What does the false do at the very end? If you need an Intermediate scripter feel free to PM me as I will accept "almost" any job, STATUS: UNAVAILABLE SCOTLAND, my hometown, and the Home of GTA!
Castillo Posted January 13, 2013 Posted January 13, 2013 It's the "getPropagated" argument, if you don't set it to false, it'll trigger the function by any other GUI element clicked. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Lloyd Logan Posted January 13, 2013 Author Posted January 13, 2013 It's the "getPropagated" argument, if you don't set it to false, it'll trigger the function by any other GUI element clicked. Sorry, it still doesn't hide? GUIEditor = { button = {}, label = {}, window = {}, } addEventHandler("onClientResourceStart", resourceRoot, function() Window = guiCreateWindow(0, 0, 1279, 715, "Buy A Vehicle", false) guiWindowSetSizable(Window, false) guiSetVisible(Window, false) lInfer = guiCreateLabel(26, 98, 326, 34, "Infernous : $30000", false, GUIEditor.window[1]) guiSetFont(lInfer, "sa-header") guiSetVisible(lInfer, false) bBuy = guiCreateButton(373, 108, 86, 29, "BUY", false, GUIEditor.window[1]) guiSetVisible(bBuy, false) cButton = guiCreateButton(1088, 668, 125, 35, "CLOSE", false, GUIEditor.window[2]) guiSetVisible(GUIEditor.button[3], false) guiSetVisible(cButton, false) end ) local buyVeh = createMarker(1940.5185546875, -1707.1162109375, 12.3828125, "cylinder", 1.5, 255, 255, 0, 170) function showGUIp(hitPlayer) if ( hitPlayer == localPlayer ) then setElementFrozen ( localPlayer, false ) guiSetVisible ( Window, true ) guiSetVisible ( lInfer, true ) guiSetVisible ( bBuy, true ) guiSetVisible (cButton, true) showCursor ( true ) end end addEventHandler ( "onClientMarkerHit", buyVeh, showGUIp ) function initGUI( ) guiSetVisible (Window, false ) guiSetVisible (bBuy, false ) guiSetVisible (lInfer, false ) guiSetVisible (cButton, false ) guiSetInputEnabled ( false ) showCursor ( false ) end addEventHandler ("onClientGUIClick", cButton, initGUI, false ) If you need an Intermediate scripter feel free to PM me as I will accept "almost" any job, STATUS: UNAVAILABLE SCOTLAND, my hometown, and the Home of GTA!
Castillo Posted January 13, 2013 Posted January 13, 2013 Place: addEventHandler ("onClientGUIClick", cButton, initGUI, false ) after you create the button. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Lloyd Logan Posted January 13, 2013 Author Posted January 13, 2013 Place: addEventHandler ("onClientGUIClick", cButton, initGUI, false ) after you create the button. It works! But the button remains there? If you need an Intermediate scripter feel free to PM me as I will accept "almost" any job, STATUS: UNAVAILABLE SCOTLAND, my hometown, and the Home of GTA!
Castillo Posted January 13, 2013 Posted January 13, 2013 cButton = guiCreateButton(1088, 668, 125, 35, "CLOSE", false, GUIEditor.window[2]) Should be: cButton = guiCreateButton(1088, 668, 125, 35, "CLOSE", false, Window) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Blaawee Posted January 13, 2013 Posted January 13, 2013 GUIEditor = { button = {}, label = {}, window = {}, } addEventHandler( "onClientResourceStart", resourceRoot, function( ) GUIEditor.window[ 1 ] = guiCreateWindow( 0, 0, 1279, 715, "Buy A Vehicle", false ); guiWindowSetSizable( GUIEditor.window[ 1 ], false ); guiSetVisible( GUIEditor.window[ 1 ], false ); GUIEditor.label[ 1 ] = guiCreateLabel( 26, 98, 326, 34, "Infernous : $30000", false, GUIEditor.window[ 1 ] ); guiSetFont( GUIEditor.label[ 1 ], "sa-header" ); GUIEditor.button[ 1 ] = guiCreateButton( 373, 108, 86, 29, "BUY", false, GUIEditor.window[ 1 ] ); GUIEditor.button[ 2 ] = guiCreateButton( 1088, 668, 125, 35, "CLOSE", false, GUIEditor.window[ 1 ] ); end ) local buyVeh = createMarker( 1940.5185546875, -1707.1162109375, 12.3828125, "cylinder", 1.5, 255, 255, 0, 170 ); function showGUIp( hitPlayer ) if ( hitPlayer == localPlayer ) then setElementFrozen ( localPlayer, false ); guiSetVisible( GUIEditor.window[ 1 ], not guiGetVisible( GUIEditor.window[ 1 ] ) ); showCursor( guiGetVisible( GUIEditor.window[ 1 ] ) ); end end addEventHandler ( "onClientMarkerHit", buyVeh, showGUIp ) function initGUI( ) guiSetVisible ( GUIEditor.window[ 1 ], not guiGetVisible( GUIEditor.window[ 1 ] ) ); guiSetInputEnabled ( guiGetVisible( GUIEditor.window[ 1 ] ) ); showCursor ( guiGetVisible( GUIEditor.window[ 1 ] ) ); end addEventHandler ("onClientGUIClick", GUIEditor.button[ 2 ], initGUI, false )
Recommended Posts