Jump to content

[HELP] dxRectangle and other Stuff [Login Panel]


=KoG=Rouche

Recommended Posts

Hi all,

I'm creating a Login Panel for my server !

I've a question for u guys :wink:

My Question :

How to delete created rectangle (blue and grey) when the player has logged in ? Cuz it don't work like "Gui" with guiSetVisible(gui, bool).

Here is the Panel :

9o56.png

Here is a part of the Code :

  
function onClientResourceStart(resource) 
    function render() 
        -- Blue Rect 
        rectBlue = dxDrawRectangle((0.30*screenX),(0.35*screenY),(0.40*screenX), (0.30*screenY), tocolor(32, 146, 234, 255)) 
        -- Grey Rect 
        rectGrey = dxDrawRectangle((0.31*screenX),(0.35*screenY),(0.39*screenX), (0.30*screenY), tocolor(58, 58, 58, 255)) 
        -- Text | Welcome on =KoG= Server | 
        txt = dxDrawText("| Welcome on =KoG= Server |", (0.36*screenX), (0.37*screenY),(0.3*screenX), (0.1*screenY), tocolor ( 0, 178, 238, 255 ),1.8,"pricedown") 
    end 
    --[[ Events ]]-- 
    addEventHandler("onClientRender", getRootElement(), render) 
end 
addEventHandler ( "onClientResourceStart", getRootElement (), onClientResourceStart ) 
  

Thanks for your help 8)

Edited by Guest
Link to comment

I assume so. guiSetVisible() is only useful (in my eyes) for temporary GUI-text storing. Like, you fill in a field with text and do guiSetVisible(field,false), the field dissapears. But after a while you want to open that field again with guiSetVisible(field,true) and it shows the text you put in there.

Link to comment

I found a way to do what i want, working with flags ! If you need help for that just ask me "pm".

Last Problem :

When a player join the server the panel is displayed ! then ...

# if the player press a panel button before spawning on the map the panel works fine and disappear. OK

OR

# if the player use a panel button after spawning on the map, the GUI element are not destroyed .. i don't understand why :-/

(when the map start, the Login Panel seems to have some fast flash "Appear ... Disappear ... Appear ... Disappear ... Appear")

Thanks for your help ;-)

Link to comment

I've another problem.

When there is already 1 player on the server the GUI are never displayed until the next map is loaded !

So the dx elements are displayed without gui elements and the newcomer has to wait for the next map.

Maybe i can work with the state of the player ? ... Waiting, Ready ... ? What is the clientEvent ?

It's anoying :-/

Any idea ?

Link to comment

I think my problem is that serverside 'll trigger the clienside of all player and make panel bug.

How to trigger from serverside to 1 clientside only ? (The client which must be triggered is the newcomer, you if you just join the server)

Serverside :

  
addEvent("onRegister",true) 
addEventHandler("onRegister",root, 
    function ( player, user, pass ) 
        -- Here is the register function 
    end 
) 
  
addEvent("onLogin",true) 
addEventHandler("onLogin",getRootElement(), 
    function (player, user, pass) 
        -- here is the login function 
    end 
) 
  
-- Here is the first function called 
function goToCreateGUI() 
    triggerClientEvent("guiCreateClientside",getRootElement()) 
end 
addEventHandler("onResourceStart",getRootElement(),goToCreateGUI) 
  

Clientside :

  
-- ScreenSize 
screenX, screenY = guiGetScreenSize(); 
-- ... 
flag = 0 
  
-- Buttons Functions 
function clientLogin(button,state) 
    if button == "left" and state == "up" then 
    triggerServerEvent("onLogin",getRootElement(),getLocalPlayer(),guiGetText(loginBox),guiGetText(passwordBox)) 
    flag = 1 
    hideLoginPanel() 
    end 
end 
  
function clientRegister(button,state) 
    if button == "left" and state == "up" then 
    triggerServerEvent("onRegister",getRootElement(),getLocalPlayer(),guiGetText(loginBox),guiGetText(passwordBox)) 
    flag = 1 
    hideLoginPanel() 
    end 
end 
  
function clientGuest(button,state) 
    if button == "left" and state == "up" then 
    flag = 1 
    hideLoginPanel() 
    end 
end 
  
function render() 
    if (flag == 0) then 
        -- Red Rect 
        rectRed = dxDrawRectangle(HereIsMyArgs) 
        -- All dx element are created here ... 
    else 
        hideLoginPanel() 
    end 
end 
  
function CreateGUI() 
    if (flag == 0) then 
         -- Buttons 
        buttonL = guiCreateButton(HereIsMyArgs) 
        buttonR = guiCreateButton(HereIsMyArgs) 
        buttonG = guiCreateButton(HereIsMyArgs) 
        -- EditBox 
        loginBox = guiCreateEdit(HereIsMyArgs) 
        passwordBox = guiCreateEdit(HereIsMyArgs) 
        guiEditSetMaxLength(HereIsMyArgs) 
        guiEditSetMaxLength(HereIsMyArgs) 
        guiEditSetMasked(HereIsMyArgs) 
        addEventHandler("onClientGUIClick",buttonL,clientLogin) 
        addEventHandler("onClientGUIClick",buttonR,clientRegister) 
        addEventHandler("onClientGUIClick",buttonG,clientGuest) 
    else 
        hideLoginPanel() 
    end 
end 
addEvent("guiCreateClientside", true) 
addEventHandler("guiCreateClientside", getRootElement(), CreateGUI) 
  
-- Hide the Login Panel 
function hideLoginPanel() 
    if(flag == 1) then 
        removeEventHandler("onClientRender",getRootElement(),render) 
        destroyElement(buttonL) 
        destroyElement(buttonR) 
        destroyElement(buttonG) 
        destroyElement(loginBox) 
        destroyElement(passwordBox) 
        showCursor(false) 
    end 
end 
addEvent("onHide", true) 
addEventHandler("onHide", getRootElement(), hideLoginPanel) 
  
function onClientJoin() 
    CreateGUI() 
    outputChatBox("Passer CreateGUI()") 
end 
addEventHandler("onClientPlayerJoin",getRootElement(),onClientJoin) 
  
if(flag == 1) then 
    removeEventHandler("onClientRender",getRootElement(),render) 
else 
    addEventHandler("onClientRender",getRootElement(),render) 
end 
  

Link to comment

New Problem with the script.

Now the problem when ppl join or quit when someone is using the login panel is fixed but ...

If there is nobody on the server ... i press a button on the panel and only the dx elements disappear. All the GUI elements stay displayed !

I think the panel generate two times the GUI element. I don't know why :-/

Cuz when i join server i begin to type my nickname in loginEdit and when tha map is loaded, the loginEdit and passwordEdit are back to default text ... when i close the panel by pressing a button i can see the old loginEdit and passwordEdit with my nickname i was writting a few seconds ago.

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