Jump to content

GUI - Problems


Recommended Posts

What's the problem with this? Any help is appreciated!

Client.lua

function spawnTeamGUI() 
    local sWidth, sHeight = guiGetScreenSize() 
  
    local Width,Height = 180,220 
    local X = (sWidth/2) - (Width/2) 
    local Y = (sHeight/2) - (Height/2) 
  
    LoginTeam = guiCreateWindow(X, Y, Z, Width, Height, 767,"Choose team",false) 
  
        guiWindowSetMovable(helpWindow, false) 
        guiWindowSetSizable(helpWindow, false) 
        guiSetVisible(LoginTeam, false) 
  
          SWAT = guiCreateButton( 18, 63, 125, 35, "SFPD SWAT", false, LoginTeam ) 
          Marines = guiCreateButton( 18, 103, 125, 35, "US Marines", false, LoginTeam ) 
          Army = guiCreateButton( 18, 143, 125, 35, "US Army", false, LoginTeam ) 
          Survivors = guiCreateButton( 18, 183, 125, 35, "Survivors", false, LoginTeam )     
    end 
  
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()),  
    function () 
        createTeleportWindow() 
    end 
) 
  
function showGUI() 
        guiSetVisible(helpWindow, true) 
        showCursor(true) 
        guiSetInputEnabled(true) 
end 
addEventHandler("onClientResourceStart", showGUI) 
  
function setTeam(button,state) 
    if button == "left" and state == "up" then 
        if source == SWAT then 
            triggerServerEvent("Swat", localPlayer) 
            outputChatBox("You have joined SFPD SWAT!") 
                        guiSetVisible ( window, false ) 
                        showCursor ( false ) 
        elseif source == Marines then 
            triggerServerEvent("Usm", localPlayer) 
            outputChatBox("You have joined US Marines") 
                        guiSetVisible ( window, false ) 
                        showCursor ( false )  
                elseif source == Army then 
            triggerServerEvent("Army", localPlayer) 
            outputChatBox("You have joined US Army") 
                        guiSetVisible ( window, false ) 
                        showCursor ( false ) 
                elseif source == Survivors then 
            triggerServerEvent("Survivors", localPlayer) 
            outputChatBox("You have joined Survivors") 
                        guiSetVisible ( window, false ) 
                        showCursor ( false ) 
        end 
    end 
) 
  
addEvent ( "setSpawnVisible", true ) 
addEventHandler ( "setSpawnVisible", root, 
    function ( ) 
        if guiGetVisible ( LoginTeam ) == false then 
            guiSetVisible ( LoginTeam, true ) 
            setTimer( function () showCursor( true ) end, 1000,1 ) 
end 
end 
) 
  

Server.lua

function Swat ( ) 
          spawnPlayer ( source, -1615.8344, 679.9478, 7.2, 90.0, 285 ) 
          Police = createTeam ( "SWAT", 0, 0, 255 ) 
          setPlayerTeam(source, Swat) 
           fadeCamera (source, true) 
    setCameraTarget (source, source) 
end 
addEvent ( "Swat", true ) 
addEventHandler ( "Swat", getRootElement(),Swat ) 
  
function ShowWindow ( ) 
triggerClientEvent ( source, "setSpawnVisible", source ) 
end 
addEventHandler ( "onPlayerLogin", root, ShowWindow ) 
addEventHandler ( "onPlayerWasted", root, ShowWindow )  

Link to comment

1°I suppose that you have 'createTeleportWindow' function.

addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), 
    function () 
        createTeleportWindow() 
    end 
) 

2° You forgot the second argument in addEventHandler.

addEventHandler("onClientResourceStart", showGUI) 

Should be:

addEventHandler("onClientResourceStart", resourceRoot, showGUI) 

Edited by Guest
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...