papam77 Posted June 28, 2013 Posted June 28, 2013 Hello i am trying to make login panel, but i need help with triggering. I wanna to make it onPlayerConnect but it is Serverside event and guiCreateStaticImage is Clientside. login_c.lua function login (player) check = guiCreateCheckBox(0.57, 0.54, 0.01, 0.02, "", false, true, panel) panel = guiCreateStaticImage(0.34, 0.28, 0.30, 0.40, "images/pnl.png", true) ID = guiCreateEdit(0.14, 0.25, 0.69, 0.11, "ID", true, panel) PASS = guiCreateEdit(0.14, 0.51, 0.69, 0.11, "PASSWORD", true, panel) end How can trigger it with login_s.lua for onPlayerConnect
xXMADEXx Posted June 28, 2013 Posted June 28, 2013 just use "onClientResourceStart" on the client side.
papam77 Posted June 28, 2013 Author Posted June 28, 2013 But it doesn't show if player connect to server.
xXMADEXx Posted June 28, 2013 Posted June 28, 2013 But it doesn't show if player connect to server. It will show when the resource gets started for them.
papam77 Posted June 28, 2013 Author Posted June 28, 2013 I've tryied this: login_c.lua addEvent("login_c",true) function login_c (player) check = guiCreateCheckBox(0.57, 0.54, 0.01, 0.02, "", false, true, panel) panel = guiCreateStaticImage(0.34, 0.28, 0.30, 0.40, "images/pnl.png", true) ID = guiCreateEdit(0.14, 0.25, 0.69, 0.11, "ID", true, panel) PASS = guiCreateEdit(0.14, 0.51, 0.69, 0.11, "PASSWORD", true, panel) end addEventHandler( "login_c", getRootElement(), login_c ) login_s.lua addEventHandler("onPlayerConnect", root, function() triggerClientEvent("login_c", getRootElement(), source) end) And doesn't work.
PaiN^ Posted June 28, 2013 Posted June 28, 2013 That will not work, Use onClientResourceStart as xXMADEXx told you .
fmj02 Posted June 28, 2013 Posted June 28, 2013 You can't use onPlayerConnect because source of this event isn't player and there's no such parameter, use onPlayerJoin instead. Please be careful with onClientPlayerJoin, because the resources are not fully loaded then for client and it will fail. And it will not work anyway because you're only creating the GUI elements in login function, create them in the file scope(outside the function) and in the body of this function use guiSetVisible to show for specified player. Just like [sRN]xXMADEXx said, you can use onClientResourceStart. panel = guiCreateStaticImage(0.34, 0.28, 0.30, 0.40, "images/pnl.png", true) check = guiCreateCheckBox(0.57, 0.54, 0.01, 0.02, "", false, true, panel) ID = guiCreateEdit(0.14, 0.25, 0.69, 0.11, "ID", true, panel) PASS = guiCreateEdit(0.14, 0.51, 0.69, 0.11, "PASSWORD", true, panel) function showLoginWindow() guiSetVisible(panel, true) end addEventHandler("onClientResourceStart", resourceRoot, function () showLoginWindow() end )
papam77 Posted June 28, 2013 Author Posted June 28, 2013 btw: function login (system2, player) local backo = { ["panel"] = guiCreateStaticImage(0.34, 0.28, 0.30, 0.40, "login/li/pnl.png", true) ["bg"] = guiCreateStaticImage(0.00, 0.00, 1.00, 1.00, "login/li/lobbyBG.png", true) } guiSetEnabled(backo["panel"],false) guiSetEnabled(backo["bg"],false) addCommandHandler("system2",login) What's wrong? Error: '}' expected (to close '{' at line 2) near '=' - Line 4 unexpected symbol near '}' - Line 5 I really don't know why...
fmj02 Posted June 28, 2013 Posted June 28, 2013 New value inserted to the table must be separated by comma. These are syntax errors, commonly encountered problem of beginners, you shouldn't be worried.
papam77 Posted June 28, 2013 Author Posted June 28, 2013 I've fixed it. function login (system2, player) local backo = { ["panel"] = guiCreateStaticImage(0.34, 0.28, 0.30, 0.40, "login/li/pnl.png", true), ["bg"] = guiCreateStaticImage(0.00, 0.00, 1.00, 1.00, "login/li/lobbyBG.png", true), } guiSetEnabled(backo["panel"],false) showCursor (true) end addCommandHandler("system2",login) But why i don't see login table on the up?
fmj02 Posted June 28, 2013 Posted June 28, 2013 guiSetVisible(backo.panel, true) guiSetVisible(backo.bg, true)
fmj02 Posted June 28, 2013 Posted June 28, 2013 It should work, make sure the screen position is correct and the image really exists. function login() local backo = { panel = guiCreateStaticImage(0.34, 0.28, 0.30, 0.40, "login/li/pnl.png", true), bg = guiCreateStaticImage(0.00, 0.00, 1.00, 1.00, "login/li/lobbyBG.png", true) } guiSetVisible(backo.panel, true) guiSetVisible(backo.bg, true) showCursor (true) end addCommandHandler("system2",login)
fmj02 Posted June 28, 2013 Posted June 28, 2013 So just change the order guiSetVisible(backo.bg, true) guiSetVisible(backo.panel, true) guiBringToFront (backo.panel)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now