Jump to content

[Solucionado] Como hago para "logIn" desde el panel? [vD]


Recommended Posts

vDscript [ Build 107 ]

Estaba haciendo un panel de login, pero me dice el siguiente error que no se como solucionarlo, por lo que si alguien me lo podria explicar y/o solucionar, estaria agradecido. :) , me da que este tema va a dar para mucho

Error

[2014-06-28 11:00:31] vDscript build: 107 
[2014-06-28 11:00:32] WARNING: vDscript\gamemode\lS.lua:2: Bad argument @ 'logIn' [Expected player at argument 1, got resource] 
[2014-06-28 11:00:34] WARNING: vDscript\gamemode\lS.lua:2: Bad argument @ 'logIn' [Expected player at argument 1, got resource] 
[2014-06-28 11:00:39] WARNING: vDscript\gamemode\lS.lua:2: Bad argument @ 'logIn' [Expected player at argument 1, got resource] 

Client

  
GUIEditor = { 
    label = {} 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        ventana = guiCreateWindow(143, 92, 554, 355, "Login Panel - vDserver", false) 
        guiWindowSetMovable(ventana, false) 
        guiWindowSetSizable(ventana, false) 
        guiSetAlpha(ventana, 1.00) 
        guiSetProperty(ventana, "CaptionColour", "FF00E5FA") 
        username = guiCreateEdit(10, 84, 217, 27, "", false, ventana) 
        guiEditSetMaxLength(username, 15) 
        GUIEditor.label[1] = guiCreateLabel(35, 53, 172, 31, "Tu nombre de usuario", false, ventana) 
        guiSetFont(GUIEditor.label[1], "default-bold-small") 
        guiLabelSetHorizontalAlign(GUIEditor.label[1], "center", false) 
        guiLabelSetVerticalAlign(GUIEditor.label[1], "center") 
        contra = guiCreateEdit(10, 164, 217, 27, "", false, ventana) 
        guiEditSetMasked(contra, true) 
        guiEditSetMaxLength(contra, 16) 
        GUIEditor.label[2] = guiCreateLabel(35, 133, 172, 31, "Tu contraseña", false, ventana) 
        guiSetFont(GUIEditor.label[2], "default-bold-small") 
        guiLabelSetHorizontalAlign(GUIEditor.label[2], "center", false) 
        guiLabelSetVerticalAlign(GUIEditor.label[2], "center") 
        GUIEditor.label[3] = guiCreateLabel(227, 80, 172, 31, "Maximo: 15 caracteres", false, ventana) 
        guiSetFont(GUIEditor.label[3], "default-bold-small") 
        guiLabelSetHorizontalAlign(GUIEditor.label[3], "center", false) 
        guiLabelSetVerticalAlign(GUIEditor.label[3], "center") 
        GUIEditor.label[4] = guiCreateLabel(223, 160, 172, 31, "Maximo: 16 caracteres", false, ventana) 
        guiSetFont(GUIEditor.label[4], "default-bold-small") 
        guiLabelSetHorizontalAlign(GUIEditor.label[4], "center", false) 
        guiLabelSetVerticalAlign(GUIEditor.label[4], "center") 
        botonLogin = guiCreateButton(10, 201, 156, 39, "Login", false, ventana) 
        addEventHandler("onClientGUIClick", botonLogin, loginFunc) 
        guiSetProperty(botonLogin, "NormalTextColour", "FFAAAAAA") 
        botonRegister = guiCreateButton(176, 201, 156, 39, "register", false, ventana) 
        addEventHandler("onClientGUIClick", botonRegister, registerFunc) 
        guiSetProperty(botonRegister, "NormalTextColour", "FFAAAAAA") 
        showCursor(true) 
    end 
) 
function loginFunc () 
    if botonLogin == source then 
    getterLogin = guiGetText (username) 
    getterPass = guiGetText(contra) 
    outputChatBox(getterLogin,localPlayer,255,0,255,true) 
    triggerServerEvent("onPlayerLoginInPanel",resourceRoot,getterLogin,getterPass) 
    end 
end 

Server

function loginFormUsername (username, password) 
        los = logIn(source,username,password) 
            if los == true then 
                outputChatBox("suc",source,255,255,255,true) 
            else 
                outputChatBox("error",source,255,255,255,true) 
            end 
end 
addEvent("onPlayerLoginInPanel",true) 
addEventHandler("onPlayerLoginInPanel",root,loginFormUsername) 

no se mucho de "triggers"...

Estoy obligado a usar "xmlNode..." para hacer esto?

Como soluciono el error de "got resource"?

------------------------------------------------------------------------------------------------

vDscript [ Build 108 ]

Nuevo server.lua

function loginFormUsername (username, password) 
        los = logIn(username,password) 
            if los == true then 
                outputChatBox("suc") 
            else 
                outputChatBox("error") 
            end 
end 
addEvent("onPlayerLoginInPanel",true) 
addEventHandler("onPlayerLoginInPanel",root,loginFormUsername) 

error:

WARNING: vDscript\gamemode\lS.lua:2: Bad argument @ 'logIn' [Expected player at argument 1, got string 'venadHD'] 

Como quito una string y lo convierto en un float?

Edited by Guest
Link to comment
  • MTA Team
Hidden

A ver, repasemos las variables del 'logIn' :

bool logIn ( player thePlayer, account theAccount, string thePassword ) 

Claramente el primer argumento es un 'player' entonces porque estas transfiriendo el username cuando eso es un string que no tiene nada que ver?

Además en client estabas pasando el source como resourceRoot, claramente de ahí tu primer error y el porque de que source se define mal client-side.

Client:

  
GUIEditor = { 
    label = {} 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        ventana = guiCreateWindow(143, 92, 554, 355, "Login Panel - vDserver", false) 
        guiWindowSetMovable(ventana, false) 
        guiWindowSetSizable(ventana, false) 
        guiSetAlpha(ventana, 1.00) 
        guiSetProperty(ventana, "CaptionColour", "FF00E5FA") 
        username = guiCreateEdit(10, 84, 217, 27, "", false, ventana) 
        guiEditSetMaxLength(username, 15) 
        GUIEditor.label[1] = guiCreateLabel(35, 53, 172, 31, "Tu nombre de usuario", false, ventana) 
        guiSetFont(GUIEditor.label[1], "default-bold-small") 
        guiLabelSetHorizontalAlign(GUIEditor.label[1], "center", false) 
        guiLabelSetVerticalAlign(GUIEditor.label[1], "center") 
        contra = guiCreateEdit(10, 164, 217, 27, "", false, ventana) 
        guiEditSetMasked(contra, true) 
        guiEditSetMaxLength(contra, 16) 
        GUIEditor.label[2] = guiCreateLabel(35, 133, 172, 31, "Tu contraseña", false, ventana) 
        guiSetFont(GUIEditor.label[2], "default-bold-small") 
        guiLabelSetHorizontalAlign(GUIEditor.label[2], "center", false) 
        guiLabelSetVerticalAlign(GUIEditor.label[2], "center") 
        GUIEditor.label[3] = guiCreateLabel(227, 80, 172, 31, "Maximo: 15 caracteres", false, ventana) 
        guiSetFont(GUIEditor.label[3], "default-bold-small") 
        guiLabelSetHorizontalAlign(GUIEditor.label[3], "center", false) 
        guiLabelSetVerticalAlign(GUIEditor.label[3], "center") 
        GUIEditor.label[4] = guiCreateLabel(223, 160, 172, 31, "Maximo: 16 caracteres", false, ventana) 
        guiSetFont(GUIEditor.label[4], "default-bold-small") 
        guiLabelSetHorizontalAlign(GUIEditor.label[4], "center", false) 
        guiLabelSetVerticalAlign(GUIEditor.label[4], "center") 
        botonLogin = guiCreateButton(10, 201, 156, 39, "Login", false, ventana) 
        addEventHandler("onClientGUIClick", botonLogin, loginFunc) 
        guiSetProperty(botonLogin, "NormalTextColour", "FFAAAAAA") 
        botonRegister = guiCreateButton(176, 201, 156, 39, "register", false, ventana) 
        addEventHandler("onClientGUIClick", botonRegister, registerFunc) 
        guiSetProperty(botonRegister, "NormalTextColour", "FFAAAAAA") 
        showCursor(true) 
    end 
) 
function loginFunc () 
    if botonLogin == source then 
    getterLogin = guiGetText (username) 
    getterPass = guiGetText(contra) 
    outputChatBox(getterLogin,localPlayer,255,0,255,true) 
    triggerServerEvent("onPlayerLoginInPanel",getLocalPlayer(),getterLogin,getterPass) 
    end 
end 

Server:

function loginFormUsername (username, password) 
        local cuenta = getAccount ( username ) 
        los = logIn(source,cuenta,password) 
            if los == true then 
                outputChatBox("suc") 
            else 
                outputChatBox("error") 
            end 
end 
addEvent("onPlayerLoginInPanel",true) 
addEventHandler("onPlayerLoginInPanel",root,loginFormUsername) 

Link to comment

[ vDscript Build 113 ]

Vale, ahora entendi mi error, estaba haciendo "resourceRoot" por lo tanto llamando al resource en vez de haber puesto "getLocalPlayer()" como has puesto tu para llamar al jugador.

En cuanto al logIn, tambien tuve ese error.

Gracias CiBeR, no me olvidare de incluirte en los creditos (^^)

Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...