Jump to content

Gui Not Working


Lloyd Logan

Recommended Posts

Posted

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!

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

Posted

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.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

Posted

Create an event server side, then trigger it from the client.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
Create an event server side, then trigger it from the client.

That's what i meant, sorry! :oops:

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!

Posted

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

350x20_FFFFFF_FFFFFF_000000_000000.png

my Email : [email protected]

Programming level: 90%

Posted

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!

Posted

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.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

Posted

You had forgot to hide it after create it, copy the code again.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

Posted

You're welcome.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

Posted

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.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

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

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

Posted

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.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

Posted

Place:

addEventHandler ("onClientGUIClick", cButton, initGUI, false ) 

after you create the button.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

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

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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