Jump to content

Panel Problem


GerardWay

Recommended Posts

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

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 by Guest
Link to comment

--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

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
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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...