Jump to content

Need help with triggering


papam77

Recommended Posts

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

Link to comment

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.

Link to comment

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 
) 

Link to comment

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

Link to comment

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?

Link to comment

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) 
  

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