Jump to content

GUI help


mint3d

Recommended Posts

Posted

I have a car spawner script but when i walk into the marker no gui shows up help

    Wnd = guiCreateWindow(550,100,382,450,"Vehicle System",false) 
    guiSetAlpha( Wnd, 1 ) 
    guiWindowSetMovable(Wnd,true) 
    guiWindowSetSizable(Wnd,false) 
      
    button = guiCreateButton(36,400,110,47,"Exit",false,Wnd) 
    button2 = guiCreateButton(249,400,110,47,"Spawn",false,Wnd) 
      
    label2 = guiCreateLabel(127,47,242,15,'',false,Wnd) 
    label = guiCreateLabel(127,34,242,15,"Click on the vehicle you want",false,Wnd) 
    guiLabelSetVerticalAlign(label2,"center") 
    guiLabelSetHorizontalAlign(label2,"center",false) 
    showCursor(false) 
    guiSetVisible( Wnd, false ) 
      
        vehicles =( 
                 
               ("Infernus", 411)             
          
        grid = guiCreateGridList(36,78,300,300,false,Wnd) 
        guiGridListAddColumn(grid, "Vehicles", 0.85) 
         
          
        for i,veh in ipairs(vehicles) do 
             row = guiGridListAddRow(grid) 
             ) 
             guiGridListSetItemText(grid, row, 1, tostring(veh[1]), false, false 
             guiGridListSetItemData(grid, row, 1, tostring(veh[2])) 
        end 
         
        function use2() 
             local row, col = guiGridListGetSelectedItem(grid)   
             if (row and col and row ~= -1 and col ~= -1) then 
                  local model = tonumber(guiGridListGetItemData(grid, row, 1)) 
                  if model ~= "" then 
                  --takePlayerMoney (thePlayer, 1000) 
                  --takePlayerMoney (player, 1000) 
                       triggerServerEvent("CreVehice", localPlayer, model) 
                  end 
             end 
        end 
        addEventHandler("onClientGUIClick", button2, use2, false) 
         
        function close2() 
        if (source == button2) then 
        --takePlayerMoney (localPlayer, 1000) 
        guiSetVisible(Wnd,false) 
        showCursor(false) 
        end 
        end 
        addEventHandler("onClientGUIClick", button2, close2) 
         
        
        function close() 
        if (source == button) then 
        guiSetVisible(Wnd,false) 
        showCursor(false) 
        end 
        end 
        addEventHandler("onClientGUIClick", button, close) 
        
    function showGUI2(hitElement) 
    if getElementType(hitElement) == "player" and (hitElement == localPlayer) then  
    guiSetVisible(Wnd,true) 
    showCursor(true) 
    end 
    end 
    addEvent("showGUI2",true) 
    addEventHandler("showGUI2", getRootElement(), showGUI2) 

Skype: Jordan_Nymph

Posted

Post the server side part.

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
     f = createMarker( x,y,z, "cylinder", 2, 0, 100, 255, 100 ) 
  
    local vehicles = {} 
      
    function spawnVeh(id) 
        local x, y, z = getElementPosition(source) 
        if isElement(vehicles[source]) then destroyElement(vehicles[source]) end 
        vehicles[source] = createVehicle(id, x + 3, y, z) 
        warpPedIntoVehicle ( source, vehicles[source] )  
    end 
    addEvent("CreVehice",true) 
    addEventHandler("CreVehice", root, spawnVeh) 
      
    addEventHandler("onPlayerQuit", root, 
    function() 
         if isElement(vehicles[source]) then 
              destroyElement(vehicles[source]) 
              vehicles[source] = nil 
         end 
    end) 
  
    
function showGUI(hitPlayer) 
  
triggerClientEvent (hitPlayer,"showGUI2",getRootElement(),hitPlayer) 
end 
addEventHandler("onMarkerHit",t,showGUI) 
  
  
  

Skype: Jordan_Nymph

Posted
addEventHandler("onMarkerHit",t,showGUI) 

You are using the variable "t", but your marker variable is "f".

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 changed what I mentioned?

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
function showGUI2(hitElement) 
    guiSetVisible(Wnd,true) 
    showCursor(true) 
    end  

Try it whitout the if. Just a idea

Sorry for lot of questions and thanks for the answers! :)

Posted (edited)
addEventHandler("showGUI2", getLocalPlayer(), showGUI2)  

oops.I want to write this in my last comment too,just delet this line by mistake

Edited by Guest

Sorry for lot of questions and thanks for the answers! :)

Posted

No sorry don't delete just replace the 2. argument to getLocalPlayer()

(I'm writing from mobile it's hard. :( i edited my fail post)

Sorry for lot of questions and thanks for the answers! :)

Posted

-- client side:

function showGUI2 ( ) 
    guiSetVisible ( Wnd, true ) 
    showCursor ( true ) 
end 
addEvent ( "showGUI2", true ) 
addEventHandler ( "showGUI2", getRootElement(), showGUI2 ) 

-- server side:

function showGUI ( hitPlayer ) 
    if ( getElementType ( hitPlayer ) == "player" ) then 
        triggerClientEvent ( hitPlayer, "showGUI2", hitPlayer ) 
    end 
end 
addEventHandler ( "onMarkerHit", f, showGUI ) 

P.S: Stop double-triple posting, use the "EDIT" 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

try this :

addEvent("showGUI2",true) 
function open() 
        guiSetVisible(Wnd, true) 
        showCursor(true) 
end 
addEventHandler("showGUI2", getRootElement(),open) 

-- Server

function showGUI2(player) 
                triggerClientEvent(player,"showGUI2", player) 
end 
addEventHandler("onMarkerHit",f,showGUI2) 

Sha67 سابقاً

Posted

That's because the problem is not on that part, you have another script errors on the client side.

Wnd = guiCreateWindow(550,100,382,450,"Vehicle System",false) 
guiSetAlpha( Wnd, 1 ) 
guiWindowSetMovable(Wnd,true) 
guiWindowSetSizable(Wnd,false) 
button = guiCreateButton(36,400,110,47,"Exit",false,Wnd) 
button2 = guiCreateButton(249,400,110,47,"Spawn",false,Wnd) 
label2 = guiCreateLabel(127,47,242,15,'',false,Wnd) 
label = guiCreateLabel(127,34,242,15,"Click on the vehicle you want",false,Wnd) 
guiLabelSetVerticalAlign(label2,"center") 
guiLabelSetHorizontalAlign(label2,"center",false) 
showCursor(false) 
guiSetVisible( Wnd, false ) 
  
vehicles = 
    { 
        { "Infernus", 411 } 
    } 
  
grid = guiCreateGridList(36,78,300,300,false,Wnd) 
guiGridListAddColumn(grid, "Vehicles", 0.85) 
  
for i,veh in ipairs(vehicles) do 
    row = guiGridListAddRow(grid) 
    guiGridListSetItemText(grid, row, 1, tostring(veh[1]), false, false) 
    guiGridListSetItemData(grid, row, 1, tostring(veh[2])) 
end 
  
function use2() 
    local row, col = guiGridListGetSelectedItem(grid)   
    if (row and col and row ~= -1 and col ~= -1) then 
        local model = tonumber(guiGridListGetItemData(grid, row, 1)) 
        if model ~= "" then 
            triggerServerEvent("CreVehice", localPlayer, model) 
        end 
    end 
end 
addEventHandler("onClientGUIClick", button2, use2, false) 
  
function close2() 
    if (source == button2) then 
        guiSetVisible(Wnd,false) 
        showCursor(false) 
    end 
end 
addEventHandler("onClientGUIClick", button2, close2) 
  
function close() 
    if (source == button) then 
        guiSetVisible(Wnd,false) 
        showCursor(false) 
    end 
end 
addEventHandler("onClientGUIClick", button, close) 
  
function showGUI2 ( ) 
    guiSetVisible ( Wnd, true ) 
    showCursor ( true ) 
end 
addEvent ( "showGUI2", true ) 
addEventHandler ( "showGUI2", getRootElement(), showGUI2 ) 

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
That's because the problem is not on that part, you have another script errors on the client side.
Wnd = guiCreateWindow(550,100,382,450,"Vehicle System",false) 
guiSetAlpha( Wnd, 1 ) 
guiWindowSetMovable(Wnd,true) 
guiWindowSetSizable(Wnd,false) 
button = guiCreateButton(36,400,110,47,"Exit",false,Wnd) 
button2 = guiCreateButton(249,400,110,47,"Spawn",false,Wnd) 
label2 = guiCreateLabel(127,47,242,15,'',false,Wnd) 
label = guiCreateLabel(127,34,242,15,"Click on the vehicle you want",false,Wnd) 
guiLabelSetVerticalAlign(label2,"center") 
guiLabelSetHorizontalAlign(label2,"center",false) 
showCursor(false) 
guiSetVisible( Wnd, false ) 
  
vehicles = 
    { 
        { "Infernus", 411 } 
    } 
  
grid = guiCreateGridList(36,78,300,300,false,Wnd) 
guiGridListAddColumn(grid, "Vehicles", 0.85) 
  
for i,veh in ipairs(vehicles) do 
    row = guiGridListAddRow(grid) 
    guiGridListSetItemText(grid, row, 1, tostring(veh[1]), false, false) 
    guiGridListSetItemData(grid, row, 1, tostring(veh[2])) 
end 
  
function use2() 
    local row, col = guiGridListGetSelectedItem(grid)   
    if (row and col and row ~= -1 and col ~= -1) then 
        local model = tonumber(guiGridListGetItemData(grid, row, 1)) 
        if model ~= "" then 
            triggerServerEvent("CreVehice", localPlayer, model) 
        end 
    end 
end 
addEventHandler("onClientGUIClick", button2, use2, false) 
  
function close2() 
    if (source == button2) then 
        guiSetVisible(Wnd,false) 
        showCursor(false) 
    end 
end 
addEventHandler("onClientGUIClick", button2, close2) 
  
function close() 
    if (source == button) then 
        guiSetVisible(Wnd,false) 
        showCursor(false) 
    end 
end 
addEventHandler("onClientGUIClick", button, close) 
  
function showGUI2 ( ) 
    guiSetVisible ( Wnd, true ) 
    showCursor ( true ) 
end 
addEvent ( "showGUI2", true ) 
addEventHandler ( "showGUI2", getRootElement(), showGUI2 ) 

Line 45 and 53 , why you wrote name of the button and you already difend this.

Sha67 سابقاً

Posted
That's because the problem is not on that part, you have another script errors on the client side.
Wnd = guiCreateWindow(550,100,382,450,"Vehicle System",false) 
guiSetAlpha( Wnd, 1 ) 
guiWindowSetMovable(Wnd,true) 
guiWindowSetSizable(Wnd,false) 
button = guiCreateButton(36,400,110,47,"Exit",false,Wnd) 
button2 = guiCreateButton(249,400,110,47,"Spawn",false,Wnd) 
label2 = guiCreateLabel(127,47,242,15,'',false,Wnd) 
label = guiCreateLabel(127,34,242,15,"Click on the vehicle you want",false,Wnd) 
guiLabelSetVerticalAlign(label2,"center") 
guiLabelSetHorizontalAlign(label2,"center",false) 
showCursor(false) 
guiSetVisible( Wnd, false ) 
  
vehicles = 
    { 
        { "Infernus", 411 } 
    } 
  
grid = guiCreateGridList(36,78,300,300,false,Wnd) 
guiGridListAddColumn(grid, "Vehicles", 0.85) 
  
for i,veh in ipairs(vehicles) do 
    row = guiGridListAddRow(grid) 
    guiGridListSetItemText(grid, row, 1, tostring(veh[1]), false, false) 
    guiGridListSetItemData(grid, row, 1, tostring(veh[2])) 
end 
  
function use2() 
    local row, col = guiGridListGetSelectedItem(grid)   
    if (row and col and row ~= -1 and col ~= -1) then 
        local model = tonumber(guiGridListGetItemData(grid, row, 1)) 
        if model ~= "" then 
            triggerServerEvent("CreVehice", localPlayer, model) 
        end 
    end 
end 
addEventHandler("onClientGUIClick", button2, use2, false) 
  
function close2() 
    if (source == button2) then 
        guiSetVisible(Wnd,false) 
        showCursor(false) 
    end 
end 
addEventHandler("onClientGUIClick", button2, close2) 
  
function close() 
    if (source == button) then 
        guiSetVisible(Wnd,false) 
        showCursor(false) 
    end 
end 
addEventHandler("onClientGUIClick", button, close) 
  
function showGUI2 ( ) 
    guiSetVisible ( Wnd, true ) 
    showCursor ( true ) 
end 
addEvent ( "showGUI2", true ) 
addEventHandler ( "showGUI2", getRootElement(), showGUI2 ) 

Line 45 and 53 , why you wrote name of the button and you already difend this.

I didn't change how he wrote it, I just fixed the script errors.

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

"SWAT" team? if so use:

getPlayerTeam + getTeamName 

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.

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