Jump to content

Small login panel problem


Wisam

Recommended Posts

So i've been working on this login panel script its not mine but i added some stuff, everything is working fine but there is a little problem i faced.. at the bottom function, when i start the resource and join the game i am set to the view of the camera matrix i put in the script but the problem is when i reconnect again i can see black screen, i know its because the event is set to onClientResourceStart , but i tryed onClientPlayerJoin but it didn't work and i didn't even see the login panel when i connected.. so i want the players to see that camera matrix and the ped every time they connect.

function finishlogin() 
  config = xmlLoadFile("fragconf.xml") 
  xmlNodeSetAttribute(config, "username",guiGetText(login_username)) 
  xmlNodeSetAttribute(config, "pass",guiGetText(login_password)) 
  xmlSaveFile(config) 
  guiSetVisible(login_bg,false) 
  guiSetVisible(login_window,false) 
  showCursor(false) 
  guiSetVisible(register_window,false) 
  guiSetVisible(login_window2,false) 
end 
addEvent("onPlayerDoneLogin", true) 
addEventHandler("onPlayerDoneLogin", getRootElement(), finishlogin) 
  
addEventHandler("onClientResourceStart", resourceRoot,  
    function () 
        loginPanel() 
        setPlayerHudComponentVisible ("radar", false )   
        ped = createPed ( 73, -2239.3713378906,-1741.8660888672,480.82662963867, 485,true ) 
        setPedAnimation( ped, "ped", "XPRESSscratch",nil,true,true,false,false) -- "ped", "XPRESSscratch" -- default "ped", endchat_01 
        guiSetInputMode("no_binds_when_editing") 
        fadeCamera (true) 
        setCameraMatrix(-2241.9584960938,-1743.4710693359,481.54472045898, 2659.0986328125, 2728.521484375, 10.774273872375) 
    end 
) 

Link to comment

The code is fine. The only thing that can cause problems is loginPanel() function (may be something is breaking there when you reconnect, did you check debug logs for errors?), though you could put fadeCamera() and setCameraMatrix() before the loginPanel() function and see if it fixes your problem.

Also it is a good practice to put some debug lines of outputChatBox() after every function call inside your onClientResourceStart event to determine where it actually fails when you connect for the 2nd time. Like this:

addEventHandler("onClientResourceStart", resourceRoot, 
    function () 
        loginPanel() 
         
        outputChatBox( "okay, 1" ) 
         
        setPlayerHudComponentVisible ("radar", false )   
        ped = createPed ( 73, -2239.3713378906,-1741.8660888672,480.82662963867, 485,true ) 
        setPedAnimation( ped, "ped", "XPRESSscratch",nil,true,true,false,false) -- "ped", "XPRESSscratch" -- default "ped", endchat_01 
        guiSetInputMode("no_binds_when_editing") 
         
        outputChatBox( "okay, 2" ) 
         
        fadeCamera (true) 
        setCameraMatrix(-2241.9584960938,-1743.4710693359,481.54472045898, 2659.0986328125, 2728.521484375, 10.774273872375) 
    end 
) 

Link to comment
The code is fine. The only thing that can cause problems is loginPanel() function (may be something is breaking there when you reconnect, did you check debug logs for errors?), though you could put fadeCamera() and setCameraMatrix() before the loginPanel() function and see if it fixes your problem.

Also it is a good practice to put some debug lines of outputChatBox() after every function call inside your onClientResourceStart event to determine where it actually fails when you connect for the 2nd time. Like this:

I added those outputChatBox lines and they both got executed and there was no errors in the debug, tried with the onClientPlayerJoin event but its still the same, blackscreen.

addEventHandler("onClientPlayerJoin", resourceRoot,  
    function () 
        outputChatBox( "okay, 1" ) 
        setPlayerHudComponentVisible ("radar", false )   
        ped = createPed ( 73, -2239.3713378906,-1741.8660888672,480.82662963867, 485,true ) 
        setPedAnimation( ped, "ped", "XPRESSscratch",nil,true,true,false,false) -- "ped", "XPRESSscratch" -- default "ped", endchat_01 
        guiSetInputMode("no_binds_when_editing") 
        fadeCamera (true) 
        setCameraMatrix(-2241.9584960938,-1743.4710693359,481.54472045898, 2659.0986328125, 2728.521484375, 10.774273872375) 
        loginPanel() 
        outputChatBox( "okay, 2" ) 
    end 
) 

Link to comment

Change it back to onClientResourceStart, since onClientPlayerJoin event will not trigger for the player who just joined the server because the script hasn't been downloaded yet to the client cache.

Hmm, I'm out of ideas, may be use a timer:

setTimer( function() 
    fadeCamera (true) 
    setCameraMatrix(-2241.9584960938,-1743.4710693359,481.54472045898, 2659.0986328125, 2728.521484375, 10.774273872375) 
end, 1000, 1) 

Link to comment
Change it back to onClientResourceStart, since onClientPlayerJoin event will not trigger for the player who just joined the server because the script hasn't been downloaded yet to the client cache.

Hmm, I'm out of ideas, may be use a timer:

Holy shit i can't beleive this actually worked xD thanks alot dude

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