1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. GTA Network forum is now in archive mode.

My friend the CEF

Discussion in 'Archive' started by TheSup, Apr 20, 2017.

  1. TheSup

    TheSup Active Member

    Messages:
    79
    Likes Received:
    10
    Joined:
    Apr 18, 2017
    Hello guys,
    I trying to handle this problem for 6 hours now... But I cant find the solution. So I decided to ask the community 4 help.

    I would like t
    Code:
    var mainBrowser = null;
    
    
    API.onServerEventTrigger.connect(function (eventName) {
            if(eventName == "Eventlgin"){
                var res = API.getScreenResolution(); //Screen res
                mainBrowser = API.createCefBrowser((300), (500), true);
                API.waitUntilCefBrowserInit(mainBrowser);
                API.setCefBrowserPosition(mainBrowser, 810, 290);
                API.loadPageCefBrowser(mainBrowser, "login.html");
                API.showCursor(true);
            }
        
        
    
    });
    
    
    function login(Username, Password)
    {
        API.showCursor(false); //stop showing the cursor
        API.destroyCefBrowser(myBrowser); //destroy the CEF browser
        API.setCanOpenChat(true); //allow the player to use the chat again.
        API.triggerServerEvent("LoginEvent",username, password);
    }
    

    Code:
    API.onPlayerFinishedDownload += API_onPlayerFinishedDownload;           
                
            }
    
            private void API_onPlayerFinishedDownload(Client player)
            {
                API.triggerClientEvent(player, "Eventlgin");
            }
    HTML:
    <!doctype html>
    <script>
            function logPlayer() {
            var username = document.getElementById("username").value;
            var password = document.getElementById("password").value;   
            resourceCall("Login", username, password);
            }
    </script>
    
    <html>
        <head>
            <meta charset="utf-8">
            <meta name="viewport" content="width=device-width, initial-scale=1">
            <style>
            
            body {
                min-height: 100vh;
                margin: 0;
                padding: 0;
            }
            
            #mainform {
                aligin:center;
                width:300px;
                margin:0 auto;
            }
            </style>
        
        </head>
        <body>
            <form id="mainform" action="/" method="post">
    
                <input type="text" id="username" placeholder="username"/>
                <input type="password" id="password" placeholder="password"/>
    
                <button onclick="logPlayer()"class="button button-block"/>Login</button>
    
            </form>
    
        </body>
    </html>
    
    [​IMG]
     
  2. root

    root Well-Known Member

    Messages:
    244
    Likes Received:
    88
    Joined:
    Aug 15, 2016
    You would like a t? Here have it "t"

    No whats the problem?
     
    Hansrutger likes this.
  3. Draex

    Draex Active Member

    Messages:
    64
    Likes Received:
    31
    Joined:
    Apr 2, 2017
    I'm pretty sure he was about to say "tea"

    Make sure that your meta.xml is correcct and post the content of your local error logs (C:\GTANetwork\logs, error & cef)
     
  4. TheSup

    TheSup Active Member

    Messages:
    79
    Likes Received:
    10
    Joined:
    Apr 18, 2017
    Screenshot_2.png [​IMG]

    I dont get any errors in the console.

    Im just wondering why I cant see the content of the html file. I have already read some articles about CEF but it didnt help me.
     
  5. Draex

    Draex Active Member

    Messages:
    64
    Likes Received:
    31
    Joined:
    Apr 2, 2017
    Like I said you should upload your error logs, those errors don't show up in the console.
    We need those logs otherwise it's impossible to tell whats the matter with your code
     
  6. PsychOrange

    PsychOrange Member

    Messages:
    7
    Likes Received:
    1
    Joined:
    Apr 14, 2017
    I'd say that it has trouble loading the HTML, CEF seems to start up properly just has nothing to display!
    Could you upload the contents of your meta.xml aswell ? that file is necessary for GTANet.Work resources to work!

    I assume you have a typo somewhere in the meta.xml..
    And is your html file really called "login.html" and is in the same folder as the file that calls / opens the CEF browser ?
     
  7. Danny

    Danny Member

    Messages:
    12
    Likes Received:
    2
    Joined:
    Mar 22, 2017
    Please try to add
    Code:
    API.sleep(1000);
    after:
    Code:
    API.waitUntilCefBrowserInit(mainBrowser);
    just for a test.
     
  8. PsychOrange

    PsychOrange Member

    Messages:
    7
    Likes Received:
    1
    Joined:
    Apr 14, 2017
    Shouldn't need to do that, as he is using


    API.waitUntilCefBrowserInit(mainBrowser);
     
  9. Danny

    Danny Member

    Messages:
    12
    Likes Received:
    2
    Joined:
    Mar 22, 2017
  10. TheSup

    TheSup Active Member

    Messages:
    79
    Likes Received:
    10
    Joined:
    Apr 18, 2017
    Good evening!
    First of all I'd like to thank u all for your help and advices.
    I have found the solution for my problem. PsychOrange was right the HTML file was not loading because the meta.xml file contained a wrong path.
    Its makes me happy to see that people help each other in this community and give them answer/solutions for their questions/problems. That's awesome!
     
    PsychOrange likes this.
  11. PsychOrange

    PsychOrange Member

    Messages:
    7
    Likes Received:
    1
    Joined:
    Apr 14, 2017
    Glad to heat that we could help you fix it,
    I've messed up some xmls aswell, had the exact same problem a few days ago ^^
     

Share This Page