Jump to content

[HELP] Index local 'result' a nil value


..:D&G:..

Recommended Posts

Hello guys, when I open up my server and try to login I keep getting this error: attempt to index local 'results' a nil value on line 17.

--[[ 
    Server - Login 
]] 
  
  
Login = {} 
  
--[[ 
            [function] Login.callBack(result) 
     
            * Callback  * 
     
            Return: nil 
]] 
function Login.callBack(result, player) 
    if(result ~= "ERROR")then 
        if(result['error'])then 
            Login.doError(result['error'], player); 
        else 
            if(result['success'] == "ok")then 
                if(getElementType(player) == "player")then 
                    setElementData(player, "userdata", result['data']); 
                    setElementData(player, "connected", true); 
                    Login.doSuccess(player); 
                end 
            else 
                Login.doError("Auth. server problem", player) 
            end 
        end 
    else 
        Login.doError("Couldn't access the auth. server", player); 
    end 
end 
  
--[[ 
            [function] Login.doLogin(email, password) 
     
            * Connecte l'utilisateur * 
     
            Return: nil 
]] 
function Login.doLogin(email, password) 
    if email and password then 
        outputChatBox("Email:"..email..' -'.." Password:"..password) 
        callRemote("http://127.0.0.1/controller/api/getUserInformations", Login.callBack, client, email, password); 
    else 
        return false; 
    end 
end 
  
--[[ 
            [function] Login.doError(string message, element player) 
     
            * Affiche une erreur * 
     
            Return: nil 
]] 
function Login.doError(message, player) 
    if message and player then 
        triggerClientEvent(player, "Login.doError", player, message); 
    else 
        return false; 
    end 
end 
  
--[[ 
            [function] Login.doSuccess(element player) 
     
            * Utilisateur connecté, on ferme * 
     
            Return: nil 
]] 
function Login.doSuccess(player) 
    if player then 
        outputChatBox("DONE"); 
        triggerClientEvent(player, "Login.doSuccess", player); 
    end 
end 
  
  
--[[ 
    Event Handlers 
]] 
addEvent("Login.doLogin", true); 
addEventHandler("Login.doLogin", getRootElement(), Login.doLogin); 

I really don't know what's the problem here, does any one know how to fix it?

Link to comment

Somewhere here:

--[[ 
    Interface - Login
 
    Description: Interface de connexion au serveur
]]
 
 
Login = {}
 
Login.elements = {}
Login.elements.circle = {}
Login.elements.circle.x = 0.3*screenX;
Login.elements.circle.y = 0.6*screenY;
Login.elements.circle.alpha = 255;
Login.elements.background = {}
Login.elements.background.x = Login.elements.circle.x+(0.18*screenX/2);
Login.elements.background.y = 0.6*screenY;
Login.elements.background.alpha = 255;
Login.elements.emailInput = {}
Login.elements.emailInput.x = Login.elements.background.x + 0.28*Login.elements.background.x;
Login.elements.emailInput.y = Login.elements.background.y + 0.1*Login.elements.background.y;
Login.elements.emailInput.width = 0.3*screenX;
Login.elements.emailInput.height = 0.03*screenX;
Login.elements.emailInput.alpha = 255;
Login.elements.emailInput.content = "test@test.com";
Login.elements.emailInput.options = {}
Login.elements.emailText = {}
Login.elements.emailText.x = Login.elements.background.x + 0.28*Login.elements.background.x;
Login.elements.emailText.y = Login.elements.background.y + 0.03*Login.elements.background.y;
Login.elements.emailText.alpha = 255;
Login.elements.passwordInput = {}
Login.elements.passwordInput.x = Login.elements.background.x + 0.28*Login.elements.background.x;
Login.elements.passwordInput.y = Login.elements.background.y + 0.3*Login.elements.background.y;
Login.elements.passwordInput.width = 0.3*screenX;
Login.elements.passwordInput.height = 0.03*screenX;
Login.elements.passwordInput.alpha = 255;
Login.elements.passwordInput.content = "";
Login.elements.passwordInput.value = "test";
Login.elements.passwordInput.masked = true;
Login.elements.passwordInput.options = {}
Login.elements.passwordText = {}
Login.elements.passwordText.x = Login.elements.background.x + 0.28*Login.elements.background.x;
Login.elements.passwordText.y = Login.elements.background.y + 0.23*Login.elements.background.y;
Login.elements.passwordText.alpha = 255;
Login.elements.button = {}
Login.elements.button.x = Login.elements.background.x + 1.1*Login.elements.background.x;
Login.elements.button.y = Login.elements.background.y + 0.1*Login.elements.background.y;
Login.elements.button.w = 0.15*screenX;
Login.elements.button.h = 50;
Login.elements.button.alpha = 255;
Login.elements.button.disabled = false;
Login.elements.button.options = {}
--[[
    ErrorDiv
]]
Login.elements.errorDiv = {}
Login.elements.errorDiv.x = 0.5*screenX;
Login.elements.errorDiv.y = 0.6*screenY;
Login.elements.errorDiv.width = 0.3*screenX;
Login.elements.errorDiv.height = 0.2*screenY;
Login.elements.errorDiv.alpha = 255;
Login.elements.errorDiv.visible = false;
Login.elements.errorDiv.text = "";
--[[
    Loading
]]
Login.elements.loading = {}
Login.elements.loading.x = Login.elements.background.x + 0.5*Login.elements.background.x;
Login.elements.loading.y = Login.elements.background.y + 0.1*Login.elements.background.y;
Login.elements.loading.w = 100;
Login.elements.loading.h = 100;
Login.elements.loading.rotation = 360;
Login.elements.loading.alpha = 255;
Login.elements.loading.enabled = false;
 
Login.elements.inputs = {}
Login.elements.inputs.email = {}
Login.elements.inputs.email.element = Login.elements.emailInput;
Login.elements.inputs.email.gotFocus = false;
Login.elements.inputs.password = {}
Login.elements.inputs.password.element = Login.elements.passwordInput;
Login.elements.inputs.password.gotFocus = false;
 
Login.elements.buttons = {}
Login.elements.buttons.login = {}
Login.elements.buttons.login.element = Login.elements.button;
Login.elements.buttons.login.functionToCall = "Login_doLogin";
 
Login.rendering = true;
 
--[[
            [function] Login.init()
   
            * Initialise l'interface de connexion *
   
            Return: nill
]]
function Login.init()
 
    addEventHandler("onClientClick", getRootElement(), Login.click);
    addEventHandler("onClientRender", getRootElement(), Login.render);
    addEventHandler("onClientRender", getRootElement(), Login.mouseHover);
    addEventHandler("onClientCharacter", getRootElement(), Login.onCharacter);
    addEventHandler("onClientKey", getRootElement(), Login.onKey);
 
    -- we create te dashboard before the cursor, so, the cursor is hover the dashboard
    Dashboard.init();
 
    Cursor.init();
    Cursor.setCursor("normal");
    Cursor.setFixe(true);
end
 
function Login.quit()
    removeEventHandler("onClientClick", getRootElement(), Login.click);
    removeEventHandler("onClientRender", getRootElement(), Login.render);
    removeEventHandler("onClientRender", getRootElement(), Login.mouseHover);
    removeEventHandler("onClientCharacter", getRootElement(), Login.onCharacter);
    removeEventHandler("onClientKey", getRootElement(), Login.onKey);
 
    Downloading.quit();
 
    -- create the town around
    call ( getResourceFromName ( "worldgen" ), "TownInit" )
 
    Player.init();
    Mouvement.init();
    Interaction.init();
    Camera.init();
    -- we enable it
    Dashboard.enable();
 
    Cursor.setFixe(false);
 
    --
end
 
--[[
            [function] Login.render()
   
            * Render *
   
]]
function Login.render()
    if Login.rendering then
 
        --[[
            Error div
        ]]
        if Login.elements.errorDiv.visible then
            if Login.elements.errorDiv.opening then
                aX, aY = Misc.interpolateBetween(Login.elements.errorDiv.x, Login.elements.errorDiv.y, 0,Login.elements.errorDiv.x, Login.elements.errorDiv.y-0.07*screenX,0, Login.elements.errorDiv.startTick, 2000, "OutBounce");
            else
                aX, aY = Misc.interpolateBetween(Login.elements.errorDiv.x, Login.elements.errorDiv.y-0.07*screenX, 0,Login.elements.errorDiv.x, Login.elements.errorDiv.y,0, Login.elements.errorDiv.startTick, 2000, "OutBounce");
            end
 
            UI.radiusRectangle(aX, aY, Login.elements.errorDiv.width, Login.elements.errorDiv.height, Login.elements.errorDiv.alpha);
            dxDrawText(Login.elements.errorDiv.text, aX + 0.15*aX, aY + 0.12*aY,0,0, tocolor(255,255,255,255));
            dxDrawImage(aX + 0.05*aX, aY + 0.1*aY, 30,30,"client/files/check_no.png", 0,0,0, tocolor(255,255,255,255));
        end
 
 
        --[[
            Login panel
        ]]
        -- background
        dxDrawRectangle(Login.elements.background.x, Login.elements.background.y, screenX, 0.18*screenX, tocolor(0,109,180,Login.elements.background.alpha));
        -- input
        dxDrawText("Adresse email:", Login.elements.emailText.x, Login.elements.emailText.y, 0.3*screenX, 0.03*screenX, tocolor(255,255,255,Login.elements.emailText.alpha), 1.4);
        UI.input(Login.elements.emailInput.x, Login.elements.emailInput.y, Login.elements.emailInput.width, Login.elements.emailInput.height, Login.elements.emailInput.content, Login.elements.emailInput.alpha, Login.elements.emailInput.options);
 
        -- input
        dxDrawText("Mot de passe:", Login.elements.passwordText.x, Login.elements.passwordText.y, 0.3*screenX, 0.03*screenX, tocolor(255,255,255,Login.elements.passwordText.alpha), 1.4);
        UI.input(Login.elements.passwordInput.x, Login.elements.passwordInput.y, 0.3*screenX, 0.03*screenX, Login.elements.passwordInput.content, Login.elements.passwordInput.alpha, Login.elements.passwordInput.options);
 
        UI.normalButton(Login.elements.button.x, Login.elements.button.y, Login.elements.button.w, Login.elements.button.h, "Connexion", Login.elements.button.alpha, Login.elements.button.options);
        dxDrawText("Register on thesimsmta.com", Login.elements.button.x, Login.elements.button.y+Login.elements.button.h+10, Login.elements.button.x+Login.elements.button.w, (Login.elements.button.y+Login.elements.button.h+10)*2, tocolor(255,255,255,255));
 
        -- waiting
        if(Login.elements.loading.enabled)then
            local rectAlpha = 150;
            if Login.elements.loading.opening then
                Login.elements.loading.alpha, _ = Misc.interpolateBetween(0,0,0,255,0,0,Login.elements.loading.startTick, 1000, "InQuad");
                rectAlpha, _ = Misc.interpolateBetween(0,0,0,150,0,0,Login.elements.loading.startTick, 1000, "InQuad");
            else
                Login.elements.loading.alpha, _ = Misc.interpolateBetween(255,0,0,0,0,0,Login.elements.loading.startTick, 1000, "InQuad");
                rectAlpha, _ = Misc.interpolateBetween(150,0,0,0,0,0,Login.elements.loading.startTick, 1000, "InQuad");
            end
            dxDrawRectangle(Login.elements.background.x, Login.elements.background.y, screenX, 0.18*screenX, tocolor(0,109,180,rectAlpha));
 
            if(Login.elements.loading.rotation <= 0)then
                Login.elements.loading.rotation = 360;
            end
            Login.elements.loading.rotation = Login.elements.loading.rotation - 15;
            dxDrawImage(Login.elements.loading.x, Login.elements.loading.y, Login.elements.loading.w, Login.elements.loading.h, "client/files/loading.png", Login.elements.loading.rotation,0,0, tocolor(255,255,255,Login.elements.loading.alpha));
        end
 
        --circle & avatar
        dxDrawImage(Login.elements.circle.x, Login.elements.circle.y, 0.18*screenX, 0.18*screenX, "client/files/ui-circle.png", 0,0,0,tocolor(255,255,255, Login.elements.circle.alpha));
        dxDrawImage(Login.elements.circle.x+10, Login.elements.circle.y+10, 0.18*screenX-20, 0.18*screenX-20, "client/files/sample.png", 0,0,0,tocolor(255,255,255,Login.elements.circle.alpha));
    end
end
 
--[[
            [function] Login.mouseHover()
   
            *  *
   
            Return: nill
]]
function Login.mouseHover()
    local cursorX, cursorY, _, _, _  = getCursorPosition();
    cursorX = cursorX*screenX;
    cursorY = cursorY*screenY;
    if(cursorX >= Login.elements.button.x and cursorX <= Login.elements.button.x+Login.elements.button.w and cursorY >= Login.elements.button.y and cursorY <= Login.elements.button.y + Login.elements.button.h)then
        Login.elements.button.options['hover'] = true;
    else
        Login.elements.button.options['hover'] = false;
    end
end
 
--[[
            [function] Login.click(button, state, x, y)
   
            * Quand l'utilisateur clique sur l'ecran *
   
            Return: nill
]]
function Login.click(button, state, x, y)
    if(button == "left" and state == "up")then
        -- inputs
        for i, v in pairs(Login.elements.inputs)do
            if(x >= v.element.x and x <= v.element.x + v.element.width and y >= v.element.y and y <= v.element.y + v.element.height)then
                v.gotFocus = true;
                v.element.options['focus'] = true;
                guiSetInputEnabled(true);
            else
                v.gotFocus = false;
                v.element.options['focus'] = false;
               
                -- vérifie l'input
                --[[for i, t in pairs(Login.elements.inputs)do
                    if t ~= v then
                        Login.checkInput(t);
                    end
                end]]
            end
        end
        -- buttons
       
Link to comment

You misunderstood me. You called Login.callBack function, but you don't use Login.callBack function's arguements.

callRemote("http://127.0.0.1/controller/api/getUserInformations", Login.callBack, client, email, password); 

It should be as follows:

callRemote("http://127.0.0.1/controller/api/getUserInformations", Login.callBack(arg1, arg2), client, email, password); 

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