Jump to content

GUI wont show


bamby12

Recommended Posts

i want to show a gui when a player logs in but it dosnt work, heres the code:

server:

  
addEvent("showGUI") 
function onlogin(player) 
triggerClientEvent("showGUI", player) 
end 
addEventHandler("onPlayerLogin",getRootElement(),onlogin) 
  

client:

  
addEvent("showGUI") 
function guishow(player) 
guiSetVisible(GUIEditor_Window[1],true) 
end 
addEventHandler("showGUI",getRootElement(),guishow) 
  

Link to comment

because first argument passed by "onPlayerLogin" event is player's previous account, not the player element

player element is the source of the event.

and you're not specifying for which player the event should be triggered.

-- server 
function onlogin() 
  triggerClientEvent(source, "showGUI", source) 
end 
addEventHandler("onPlayerLogin", getRootElement(), onlogin) 

and you dont need (player) in client handler.

Link to comment
i want to show a gui when a player logs in but it dosnt work, heres the code:

server:

  
addEvent("showGUI") 
function onlogin(player) 
triggerClientEvent("showGUI", player) 
end 
addEventHandler("onPlayerLogin",getRootElement(),onlogin) 
  

client:

  
addEvent("showGUI") 
function guishow(player) 
guiSetVisible(GUIEditor_Window[1],true) 
end 
addEventHandler("showGUI",getRootElement(),guishow) 
  

use in Client side

  
function guishow() 
guiSetVisible(GUIEditor_Window[1],true) 
end 
addEventHandler("onClientResourceStart",getRootElement(),guishow) 
  

Link to comment
use in Client side
  
function guishow() 
guiSetVisible(GUIEditor_Window[1],true) 
end 
addEventHandler("onClientResourceStart",getRootElement(),guishow) 
  

1. if you didn't notice, gui is set to show on player login, not on join.

2. your script will show the window every time ANY resource starts.

Link to comment

1 more think i want a button to set a players team but when i click on the button it dosnt do anything and i dont get errors :P

heres the code:

server:

  
function chooseteam(player) 
setPlayerTeam" class="kw6">setPlayerTeam ( player, getTeamFromName("team") )--i dno why it says class = "kw6" here  
end 
addEvent("setteam",true) 
addEventHandler("setteam", resourceRoot, chooseteam) 
  

client:

  
addEventHandler("onClientGUIClick", GUIEditor_Button[1], clickbutton, false) 
function clickbutton(player) 
triggerServerEvent("setteam",getLocalPlayer()) 
guiSetVisible("GUIEditor_Window[1]", false) 
showCursor(false) 
end 
  

Link to comment

In the client file, put the addEventHandler under the function. clickbutton must first be defined before you can assign it to an event ;)

In the server file, you're expecting a player variable, but that will just be nil. The source of your event will be the player, so use "source" instead of "player" in setPlayerTeam. Reason: the second argument in triggerServerEvent will be the source.

(that class kw6 is a bug in the forum with setPlayerTeam)

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