GerardWay Posted January 24, 2013 Share Posted January 24, 2013 I have just created a V.I.P Panel using the GUI Editor, and I was wondering if anyone could give me an example of how to make one of the functions work, like how I would make the player recieve a hydra when they click a Button on the panel named "Give Hydra". Any help would be great thanks! Code: GUIEditor = { button = {}, window = {}, } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(0, 274, 331, 493, "V.I.P Panel", false) guiWindowSetSizable(GUIEditor.window[1], false) guiSetAlpha(GUIEditor.window[1], 1.00) Turismo = guiCreateButton(17, 80, 130, 59, "Give Turismo", false, GUIEditor.window[1]) Hydra = guiCreateButton(173, 80, 132, 57, "Give Hydra", false, GUIEditor.window[1]) Chainsaw = guiCreateButton(17, 176, 127, 58, "Give Chainsaw", false, GUIEditor.window[1]) RPG = guiCreateButton(163, 176, 138, 53, "Give RPG x20", false, GUIEditor.window[1]) EnableGodmode = guiCreateButton(10, 268, 129, 54, "Enable Godmode", false, GUIEditor.window[1]) DisableGodmode = guiCreateButton(162, 268, 126, 49, "Disable Godmode", false, GUIEditor.window[1]) NRG-500 = guiCreateButton(12, 348, 124, 53, "Give NRG-500", false, GUIEditor.window[1]) Close = guiCreateButton(162, 352, 121, 49, "Close Panel", false, GUIEditor.window[1]) end ) Link to comment
Castillo Posted January 24, 2013 Share Posted January 24, 2013 onClientGUIClick triggerServerEvent addEvent addEventHandler getElementPosition createVehicle warpPedIntoVehicle That's all you need to do it. Link to comment
GerardWay Posted January 24, 2013 Author Share Posted January 24, 2013 Man I still dont get it Can you give an example? please Link to comment
Castillo Posted January 24, 2013 Share Posted January 24, 2013 Try to do it, and if it doesn't work, post your script and I'll help you. Link to comment
Lloyd Logan Posted January 24, 2013 Share Posted January 24, 2013 (edited) CLIENT GUIEditor = { button = {}, window = {}, } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(0, 274, 331, 493, "V.I.P Panel", false) guiWindowSetSizable(GUIEditor.window[1], false) guiSetAlpha(GUIEditor.window[1], 1.00) Turismo = guiCreateButton(17, 80, 130, 59, "Give Turismo", false, GUIEditor.window[1]) Hydra = guiCreateButton(173, 80, 132, 57, "Give Hydra", false, GUIEditor.window[1]) Chainsaw = guiCreateButton(17, 176, 127, 58, "Give Chainsaw", false, GUIEditor.window[1]) RPG = guiCreateButton(163, 176, 138, 53, "Give RPG x20", false, GUIEditor.window[1]) EnableGodmode = guiCreateButton(10, 268, 129, 54, "Enable Godmode", false, GUIEditor.window[1]) DisableGodmode = guiCreateButton(162, 268, 126, 49, "Disable Godmode", false, GUIEditor.window[1]) NRG500 = guiCreateButton(12, 348, 124, 53, "Give NRG-500", false, GUIEditor.window[1]) addEventHandler ("onClientGUIClick", NRG500, buyCar, false ) Close = guiCreateButton(162, 352, 121, 49, "Close Panel", false, GUIEditor.window[1]) function buyCar(thePlayer) triggerServerEvent ( "buyVeh", getLocalPlayer(), "greetingHandler" ) end end ) SERVER function greetingHandler ( thePlayer ) createVehicle(522, 1944.60632, -1706.89270, 13.38281)end addEvent( "buyVeh", true ) addEventHandler( "buyVeh", getRootElement(), greetingHandler ) Edited January 24, 2013 by Guest Link to comment
Castillo Posted January 24, 2013 Share Posted January 24, 2013 That won't work. @Zombie: You can't use "-" character while defining a variable, like here: "NRG-500". Link to comment
Lloyd Logan Posted January 24, 2013 Share Posted January 24, 2013 That won't work.@Zombie: You can't use "-" character while defining a variable, like here: "NRG-500". Edited** Link to comment
iPrestege Posted January 24, 2013 Share Posted January 24, 2013 --Client Side-- GUIEditor = { button = {}, window = {}, } GUIEditor.window[1] = guiCreateWindow(0, 274, 331, 493, "V.I.P Panel", false) guiWindowSetSizable(GUIEditor.window[1], false) guiSetAlpha(GUIEditor.window[1], 1.00) Turismo = guiCreateButton(17, 80, 130, 59, "Give Turismo", false, GUIEditor.window[1]) Hydra = guiCreateButton(173, 80, 132, 57, "Give Hydra", false, GUIEditor.window[1]) Chainsaw = guiCreateButton(17, 176, 127, 58, "Give Chainsaw", false, GUIEditor.window[1]) RPG = guiCreateButton(163, 176, 138, 53, "Give RPG x20", false, GUIEditor.window[1]) EnableGodmode = guiCreateButton(10, 268, 129, 54, "Enable Godmode", false, GUIEditor.window[1]) DisableGodmode = guiCreateButton(162, 268, 126, 49, "Disable Godmode", false, GUIEditor.window[1]) NRG-500 = guiCreateButton(12, 348, 124, 53, "Give NRG-500", false, GUIEditor.window[1]) Close = guiCreateButton(162, 352, 121, 49, "Close Panel", false, GUIEditor.window[1]) addEventHandler("onClientGUIClick", root, function() if source == Turismo then triggerServerEvent("Turismo", localPlayer) elseif source == Hydra then triggerServerEvent("Hydra", localPlayer) elseif source == Chainsaw then triggerServerEvent("Chainsaw", localPlayer) elseif source == NRG-500 then triggerServerEvent("NRG-500", localPlayer) elseif source == Close then guiSetVisible(GUIEditor.window[1], false) showCursor(false) end end ) --Server Side-- addEvent( "Turismo", true) addEventHandler( "Turismo", root, function() x,y,z = getElementPosition ( source ) Vehicle = createVehicle ( id, x, y, z + 2) warpPedIntoVehicle ( source, Vehicle ) end ) addEvent( "Hydra", true) addEventHandler( "Hydra", root, function() x,y,z = getElementPosition ( source ) Vehicle = createVehicle ( id, x, y, z + 2) warpPedIntoVehicle ( source, Vehicle ) end ) addEvent( "NRG-500", true) addEventHandler( "NRG-500", root, function() x,y,z = getElementPosition ( source ) Vehicle = createVehicle ( id, x, y, z + 2) warpPedIntoVehicle ( source, Vehicle ) end ) addEvent( "Chainsaw", true) addEventHandler( "Chainsaw", root, function() x,y,z = getElementPosition ( source ) Vehicle = createVehicle ( id, x, y, z + 2) warpPedIntoVehicle ( source, Vehicle ) end ) i Do The Vehicle Only the others i dont understand it realy! and the close button!Just Change the Vehicle id Link to comment
Anderl Posted January 24, 2013 Share Posted January 24, 2013 You should have read what Solidsnake14 said to Lloyd Logan and also your code should be better organised, it's a lot boring to add multiple if statements for multiple vehicles and to add multiple events for creating each vehicle. You should make ONLY ONE event to create any vehicle and use arrays. Link to comment
iPrestege Posted January 24, 2013 Share Posted January 24, 2013 You should have read what Solidsnake14 said to Lloyd Logan and also your code should be better organised, it's a lot boring to add multiple if statements for multiple vehicles and to add multiple events for creating each vehicle. You should make ONLY ONE event to create any vehicle and use arrays. This will be easier for him as a Beginner! Link to comment
Anderl Posted January 24, 2013 Share Posted January 24, 2013 My way is much easier and faster to do than yours. Also, if he ever needed to change/add vehicles, he would simply add to the array. Link to comment
iPrestege Posted January 24, 2013 Share Posted January 24, 2013 My way is much easier and faster to do than yours. Also, if he ever needed to change/add vehicles, he would simply add to the array. Ok Thanks Any Way ^ . Link to comment
Castillo Posted January 25, 2013 Share Posted January 25, 2013 I really don't understand why did you had to make the code for him at all, is not as helpful as letting him try to do it. Link to comment
iPrestege Posted January 25, 2013 Share Posted January 25, 2013 I really don't understand why did you had to make the code for him at all, is not as helpful as letting him try to do it. it,s just , a simple example and he will know how i do it! and you zombie if you have any question ask me Np!. Link to comment
GerardWay Posted January 25, 2013 Author Share Posted January 25, 2013 The panel isnt even showing now, im guessing that maybe it could be a problem with "GUISetvisible" ? Link to comment
Lloyd Logan Posted January 25, 2013 Share Posted January 25, 2013 The panel isnt even showing now, im guessing that maybe it could be a problem with "GUISetvisible" ? Yes, put in [lua]guiSetVisible(windowhere**, true)[\lua] Link to comment
GerardWay Posted January 25, 2013 Author Share Posted January 25, 2013 addCommandHandler("ovp", Panel, guiSetVisible(Panel, true) I added that and it didnt work Link to comment
Lloyd Logan Posted January 25, 2013 Share Posted January 25, 2013 addCommandHandler("ovp", Panel,guiSetVisible(Panel, true) I added that and it didnt work Post your script Link to comment
Baseplate Posted January 25, 2013 Share Posted January 25, 2013 addCommandHandler("ovp", function() guiSetVisible(GUIEditor.window[1], true) showCursor(true) end ) On another note: if you want to come on skype I can help. Link to comment
GerardWay Posted January 25, 2013 Author Share Posted January 25, 2013 Still doesnt work Link to comment
Lloyd Logan Posted January 25, 2013 Share Posted January 25, 2013 function showit ( ) guiSetVisible( GUIEditor.window[1], true ) showCursor( true ) end addCommandHandler( "showit", showit ) Link to comment
Anderl Posted January 25, 2013 Share Posted January 25, 2013 It's the same code as Samers, just different command name lol Link to comment
Lloyd Logan Posted January 25, 2013 Share Posted January 25, 2013 Remember the command is ovp --CLIENT GUIEditor = { button = {}, window = {}, } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(0, 274, 331, 493, "V.I.P Panel", false) guiWindowSetSizable(GUIEditor.window[1], false) guiSetAlpha(GUIEditor.window[1], 1.00) guiSetVisible( GUIEditor.window[1], false ) Turismo = guiCreateButton(17, 80, 130, 59, "Give Turismo", false, GUIEditor.window[1]) Hydra = guiCreateButton(173, 80, 132, 57, "Give Hydra", false, GUIEditor.window[1]) Chainsaw = guiCreateButton(17, 176, 127, 58, "Give Chainsaw", false, GUIEditor.window[1]) RPG = guiCreateButton(163, 176, 138, 53, "Give RPG x20", false, GUIEditor.window[1]) EnableGodmode = guiCreateButton(10, 268, 129, 54, "Enable Godmode", false, GUIEditor.window[1]) DisableGodmode = guiCreateButton(162, 268, 126, 49, "Disable Godmode", false, GUIEditor.window[1]) NRG500 = guiCreateButton(12, 348, 124, 53, "Give NRG-500", false, GUIEditor.window[1]) Close = guiCreateButton(162, 352, 121, 49, "Close Panel", false, GUIEditor.window[1]) showCursor( false ) function buyCar(thePlayer) triggerServerEvent ( "buyVeh", getLocalPlayer(), "greetingHandler" ) end end ) addEventHandler("onClientGUIClick", root, function() if source == Turismo then triggerServerEvent("Turismo", localPlayer) elseif source == Hydra then triggerServerEvent("Hydra", localPlayer) elseif source == Chainsaw then triggerServerEvent("Chainsaw", localPlayer) elseif source == RPG then triggerServerEvent("RPG", localPlayer) elseif source == NRG500 then triggerServerEvent("NRG500", localPlayer) elseif source == Close then guiSetVisible(GUIEditor.window[1], false) showCursor(false) end end ) function showit ( ) guiSetVisible( GUIEditor.window[1], true ) showCursor( true ) end addCommandHandler( "ovp", showit ) --SERVER addEvent( "Turismo", true) addEventHandler( "Turismo", root, function() x, y, z = getElementPosition ( source ) Vehicle = createVehicle ( 451, x, y, z + 2) warpPedIntoVehicle ( source, Vehicle ) end ) addEvent( "Hydra", true) addEventHandler( "Hydra", root, function() x, y, z = getElementPosition ( source ) Vehicle = createVehicle ( 520, x, y, z + 2) warpPedIntoVehicle ( source, Vehicle ) end ) addEvent( "NRG500", true) addEventHandler( "NRG500", root, function() x, y, z = getElementPosition ( source ) Vehicle = createVehicle ( 522, x, y, z + 2) warpPedIntoVehicle ( source, Vehicle ) end ) addEvent( "RPG", true) addEventHandler( "RPG", root, function() giveWeapon( root, 35, 1, true ) end ) addEvent( "Chainsaw", true) addEventHandler( "Chainsaw", root, function() giveWeapon( root, 9, 1, true ) end ) Link to comment
GerardWay Posted January 25, 2013 Author Share Posted January 25, 2013 Still not freakin working O_O Link to comment
Castillo Posted January 25, 2013 Share Posted January 25, 2013 function buyCar(thePlayer) triggerServerEvent ( "buyVeh", getLocalPlayer(), "greetingHandler" ) end end ) Remove that ")" after the last "end". 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