Jump to content

I need some help w/ this GUI problem.


TheDZetko

Recommended Posts

Hello all,

I have been working on this script using some GUI elements for some time now and I just bumped into one problem. I have set the function to show the window each time a player joins (onPlayerJoin). But when I connect or reconnect, nothing happens (no window shows). What is the problem?

This is my script.lua (client).

window = guiCreateWindow(0.4,0.35,0.25,0.25,"D'n'T Servers | Welcome on my server.", true) 
btnpolice = guiCreateButton(0.03,0.4,0.45,0.55,"Police", true, window) 
btnterrorists = guiCreateButton(0.53,0.4,0.45,0.55,"Terrorists", true, window) 
labelchoose = guiCreateLabel(0.3,0.1,0.5,0.3,"Choose a team to connect to.", true, window) 
guiWindowSetMovable(window,false) 
guiWindowSetSizable(window, false) 
guiSetVisible(window, false) 
showCursor(false) 
  
addEventHandler("onPlayerJoin", getResourceRootElement ( getThisResource ()), 
function() 
guiSetVisible(window, true) 
showCursor(true) 
end 
) 
  
-- function buttonclicked(localPlayer, button) 
   -- if button == "left" and state == "up" then 
      -- setPlayerTeam (localPlayer, "Police") 
    -- else 
      -- setPlayerTeam (localPlayer, "Terrorists") 
    -- end 
    -- guiSetVisible(window, not guiGetVisible(window)) 
    -- showCursor(not isCursorShowing()) 
-- end 
-- addEventHandler("onClientGUIClick", buttonred, redteam, false) 
  
function policeteam(localPlayer, button) 
   local policeteam = getTeamFromName("Police") 
   if button == "left" and state == "up" then 
      if (policeteam) then 
         setPlayerTeam(localPlayer, policeteam) 
      else 
         outputChatBox("We cannot assign you to Police team.", localPlayer) 
      end 
      guiSetVisible(window, false) 
      showCursor(false) 
    end 
end 
addEventHandler("onClientGUIClick", btnpolice, policeteam, false) 
  
function terroriststeam(localPlayer, button) 
   local terroriststeam = getTeamFromName("Terrorists") 
   if button == "left" and state == "up" then 
      if (terroriststeam) then 
         setPlayerTeam(localPlayer, terroriststeam) 
      else 
         outputChatBox("We cannot assign you to Terrorists team.", localPlayer) 
      end 
      guiSetVisible(window, false) 
      showCursor(false) 
    end 
end 
addEventHandler("onClientGUIClick", btnterrorists, terroriststeam, false) 
  

And here is my meta.xml file.

<meta> 
   <script src="script.lua" type="client" /> 
</meta> 

Where is the problem? Please help (me).

Thank you all so much in advance,

TheDZetko :-)

Link to comment
  
window = guiCreateWindow(0.4,0.35,0.25,0.25,"D'n'T Servers | Welcome on my server.", true) 
btnpolice = guiCreateButton(0.03,0.4,0.45,0.55,"Police", true, window) 
btnterrorists = guiCreateButton(0.53,0.4,0.45,0.55,"Terrorists", true, window) 
labelchoose = guiCreateLabel(0.3,0.1,0.5,0.3,"Choose a team to connect to.", true, window) 
guiWindowSetMovable(window,false) 
guiWindowSetSizable(window, false) 
guiSetVisible(window, false) 
showCursor(false) 
  
addEventHandler("onClientPlayerJoin", getResourceRootElement ( getThisResource ()), 
function() 
guiSetVisible(window, true) 
showCursor(true) 
end 
) 
  
-- function buttonclicked(localPlayer, button) 
   -- if button == "left" and state == "up" then 
      -- setPlayerTeam (localPlayer, "Police") 
    -- else 
      -- setPlayerTeam (localPlayer, "Terrorists") 
    -- end 
    -- guiSetVisible(window, not guiGetVisible(window)) 
    -- showCursor(not isCursorShowing()) 
-- end 
-- addEventHandler("onClientGUIClick", buttonred, redteam, false) 
  
function policeteam(localPlayer, button) 
   local policeteam = getTeamFromName("Police") 
   if button == "left" and state == "up" then 
      if (policeteam) then 
         setPlayerTeam(localPlayer, policeteam) 
      else 
         outputChatBox("We cannot assign you to Police team.", localPlayer) 
      end 
      guiSetVisible(window, false) 
      showCursor(false) 
    end 
end 
addEventHandler("onClientGUIClick", btnpolice, policeteam, false) 
  
function terroriststeam(localPlayer, button) 
   local terroriststeam = getTeamFromName("Terrorists") 
   if button == "left" and state == "up" then 
      if (terroriststeam) then 
         setPlayerTeam(localPlayer, terroriststeam) 
      else 
         outputChatBox("We cannot assign you to Terrorists team.", localPlayer) 
      end 
      guiSetVisible(window, false) 
      showCursor(false) 
    end 
end 
addEventHandler("onClientGUIClick", btnterrorists, terroriststeam, false) 
  
  

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