Jump to content

MTA DAYZ Login


xDavid

Recommended Posts

Hello

i have a Problem,

i am learning lua+mysql and i will test a nice dayZ Script.

But the Login make Problems

[2015-06-23 22:16:04] ERROR: Client (Nerd) triggered serverside event onPlayerDayZRegister, but event is not added serverside

serverside

saves = {} 
local dbConnection = dbConnect("mysql", "dbname=DBNAME;host=127.0.0.1", "Name", "PW","share=1") 
  
if (dbConnection) then 
 outputServerLog("Successfully connected to MySQL!") 
else 
 outputServerLog("Failed to connect to MySQL!") 
end 
  
  
addEvent("checkifRegisteredorleggedIn",true) 
addEventHandler("checkifRegisteredorleggedIn",root,function(player) 
    qr = dbQuery(dbConnection, "SELECT * FROM users") 
    result = dbPoll(qr, -1)  
    for v,k in ipairs(result) do 
    if k['Name'] == getPlayerName(player) then 
        triggerClientEvent("enableLogin",player)     
        return  
        end 
    end 
    triggerClientEvent("enableRegister",player) 
end) 

Link to comment

The debug error was enough clear , the problem is that there isn't any event with the name onPlayerDayZRegister on server-side. Check other server-side files in your resource if there are any, the problem could be a typo in name of event or simply the event is missing.

Link to comment

Hey i found on the clientside this.

local usernamelabel = "Username" 
local passwordlabel = "password" 
canlogin = true 
canreg = true 
  
  
Font = dxCreateFont( "tachoFont.ttf", 33)    
Font1 = guiCreateFont( "tachoFont.ttf", 18)    
Font2 = guiCreateFont( "tachoFont.ttf", 25)    
lp = getLocalPlayer() 
loginkrypt = {} 
loginkrypt["main"] = guiCreateWindow(0.24, 0.21, 0.51, 0.57, "", true) 
guiWindowSetSizable(loginkrypt["main"], false) 
guiWindowSetMovable(loginkrypt["main"], false) 
  
  
loginkrypt["loginuser"] = guiCreateButton(0.04, 0.79, 0.28, 0.14, "Login", true, loginkrypt["main"]) 
guiSetFont(loginkrypt["loginuser"], Font2) 
guiSetProperty(loginkrypt["loginuser"], "NormalTextColour", "FFFFFFFF") 
usereditlogin = guiCreateEdit(0.07, 0.38, 0.26, 0.07, "", true, loginkrypt["main"]) 
username = guiCreateLabel(0.08, 0.30, 0.25, 0.06, usernamelabel.."           ", true, loginkrypt["main"]) 
guiSetText(usereditlogin,getPlayerName(lp)) 
guiSetFont(username, Font1) 
guiEditSetReadOnly (usereditlogin,true) 
guiLabelSetHorizontalAlign(username, "center", false) 
guiLabelSetVerticalAlign(username, "center") 
PwEditLogin = guiCreateEdit(0.07, 0.57, 0.26, 0.07, "", true, loginkrypt["main"]) 
  
rofl = guiCreateLabel(0.08, 0.51, 0.25, 0.06, passwordlabel.."           ", true, loginkrypt["main"]) 
guiSetFont(rofl, Font1)--"default-bold-small") 
guiLabelSetHorizontalAlign(rofl, "center", false) 
guiLabelSetVerticalAlign(rofl, "center") 
  
regbtn = guiCreateButton(0.43, 0.79, 0.29, 0.14, "Register", true, loginkrypt["main"]) 
guiSetProperty(regbtn, "NormalTextColour", "FFAAAAAA") 
guiSetFont(regbtn, Font2)--"default-bold-small") 
loginkrypt["registerusername"] = guiCreateEdit(0.44, 0.37, 0.26, 0.07, "", true, loginkrypt["main"]) 
guiSetText(loginkrypt["registerusername"],getPlayerName(lp)) 
guiEditSetReadOnly (loginkrypt["registerusername"],true) 
useasdsda = guiCreateLabel(0.44, 0.29, 0.25, 0.06, usernamelabel.."           ", true, loginkrypt["main"]) 
guiLabelSetHorizontalAlign(useasdsda, "center", false) 
guiLabelSetVerticalAlign(useasdsda, "center") 
guiSetFont(useasdsda, Font1) 
loginkrypt["registerpassword"] = guiCreateEdit(0.44, 0.57, 0.26, 0.07, "", true, loginkrypt["main"]) 
registerpw = guiCreateLabel(0.44, 0.51, 0.25, 0.06, passwordlabel.."           ", true, loginkrypt["main"]) 
guiLabelSetHorizontalAlign(registerpw, "center", false) 
guiLabelSetVerticalAlign(registerpw, "center") 
guiSetFont(registerpw, Font1) 
guiCreateGridList(0.37, 0.04, 0.04, 0.94, true, loginkrypt["main"]) 
loginkrypt["newsgridlist"] = guiCreateGridList(0.73, 0.04, 0.25, 0.94, true, loginkrypt["main"]) 
loginkrypt["newsgridlistcol"] = guiGridListAddColumn(loginkrypt["newsgridlist"], "News", 0.9) 
--guiSetVisible(loginkrypt["main"],false) 
for i, pos in ipairs(news) do -- Füllt die Liste mit vip.vehicles 
        local row = guiGridListAddRow ( loginkrypt["newsgridlist"] ) 
        guiGridListSetItemText ( loginkrypt["newsgridlist"], row, loginkrypt["newsgridlistcol"], tostring ( pos[1] ), false, false ) 
end 
  
  
rules = {} 
rules["main"] = guiCreateWindow(0.25, 0.11, 0.52, 0.77, "", true) 
guiWindowSetMovable(rules["main"], false) 
guiWindowSetSizable(rules["main"], false) 
rulesacceptbutton = guiCreateButton(0.74, 0.91, 0.24, 0.07, "Close", true, rules["main"]) 
guiSetFont(rulesacceptbutton, "default-bold-small") 
guiSetProperty(rulesacceptbutton, "NormalTextColour", "FFAAAAAA") 
  
rules["checkbox"] = guiCreateCheckBox(0.02, 0.92, 0.71, 0.07, "I Read and Accept the Rules | Ich habe die Regeln gelesen und akzeptiere sie", false, true, rules["main"]) 
guiSetFont(rules["checkbox"], "default-bold-small") 
  
rules["memo"] = guiCreateMemo(0.01, 0.03, 0.98, 0.87, "\n", true, rules["main"]) 
guiMemoSetReadOnly (rules["memo"],true ) 
guiSetVisible(rules["main"],false) 
  
  
  
for i, pos in ipairs(rulestext) do  
        local inhalt = guiGetText(rules["memo"]) 
        guiSetText(rules["memo"],inhalt.."\n"..pos[1].."\n"..pos[2]) 
end 
  
local x,y = guiGetScreenSize() 
addEventHandler("onClientRender", root, 
    function() 
        if (guiGetVisible(loginkrypt["main"]) == true) then 
        dxDrawImage(x/3.8, y/4, 500, 150, "underheader.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) 
        dxDrawImage(x/4.5, y/30/20-40, 813, 379, "header.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) 
        end 
    end 
) 
showCursor(true) 
addEventHandler("onClientPlayerJoin", getLocalPlayer(), 
function () 
guiSetVisible(loginkrypt["main"],true) 
showCursor(true) 
end) 
  
addEvent("enableRegister",true) 
addEventHandler("enableRegister",getRootElement(), 
function () 
canlogin = false 
canreg = true 
  
guiEditSetReadOnly (PwEditLogin,true) 
guiSetProperty( loginkrypt["loginuser"], "Disabled", "True" ) 
end) 
  
  
addEvent("enableLogin",true) 
addEventHandler("enableLogin",getRootElement(), 
function () 
canlogin = true 
canreg = false 
  
guiEditSetReadOnly (loginkrypt["registerpassword"],true) 
guiSetProperty( regbtn, "Disabled", "True" ) 
end) 
triggerServerEvent ( "checkifRegisteredorleggedIn", lp,lp) 
  
guiSetInputMode ( "no_binds_when_editing" ) 
  
        addEventHandler("onClientGUIClick", regbtn, 
            function () 
                if (guiGetText(loginkrypt["registerpassword"]) == "") or (guiGetText(loginkrypt["registerusername"]) == "") then return end 
                if (canreg == false) then return end 
  
                username = guiGetText(loginkrypt["registerusername"]) 
                password = guiGetText(loginkrypt["registerpassword"]) 
                guiSetVisible(rules["main"],true) 
                addEventHandler("onClientGUIClick", rulesacceptbutton,  
                    function () 
                        if not (guiCheckBoxGetSelected ( rules["checkbox"]) == true ) then return end 
                    --  triggerServerEvent ( "onPlayerDayZFakeCreateRegister", lp,username,password) 
                        setTimer(triggerServerEvent,250,1,"onPlayerDayZRegister", lp,username,password,getLocalPlayer()) 
                        guiSetVisible(rules["main"],false) 
                        showCursor(false) 
                    end 
                ) 
                --showCursor(false) 
                guiSetVisible(loginkrypt["main"],false)              
            end 
        ) 
         
        addEventHandler("onClientGUIClick", loginkrypt["loginuser"], -- Schließt Das Fenster 
            function () 
                if (guiGetText(usereditlogin) == "") or (guiGetText(PwEditLogin) == "") then return end 
                if (canlogin == false) then return end 
                username = guiGetText(usereditlogin) 
                password = guiGetText(PwEditLogin) 
            --  triggerServerEvent ( "onPlayerDayZFakeCreateLogin", lp,username,password,lp) 
                setTimer(triggerServerEvent ,250,1, "onPlayerDayZLogin", lp,username,password,getLocalPlayer()) 
                showCursor(false) 
                guiSetVisible(loginkrypt["main"],false)              
            end 
        ) 
  
         
  

// I think when i have acc in teh DB and i login on the Server have we the same error with onPlayerDayZLogin

Link to comment

Hey i found a MySQL Dayz with Login, and the Login have this problem.

I don't make this Login/ Register. I have a Normal Dayz Script with a login.

and on this is serverside

local root = getRootElement() 
tryToLoginPlayer = function(username, password) 
  local account = getAccount(username, password) 
  if account then 
    local accountName = getAccountName(account) 
    logIn(source, account, password) 
    triggerClientEvent(source, "onPlayerDoneLogin", source, accountName, password) 
    triggerEvent("onPlayerDayZLogin", getRootElement(), username, pass, source) 
  else 
    outputChatBox("[Login]#FF9900 Wrong Passwort or Username", source, 255, 255, 255, true) 
  end 
end 
  
addEvent("onClientSendLoginDataToServer", true) 
addEventHandler("onClientSendLoginDataToServer", root, tryToLoginPlayer) 
tryToRegsiterPlayer = function(username, pass) 
  if not getAccount(username) then 
    theAccount = addAccount(username, pass) 
    if theAccount then 
      logIn(source, theAccount, pass) 
      outputChatBox("Sie haben sich erfolgreich registriert" .. username .. "' for player '" .. getPlayerName(source) .. "'#FFFFFF mit dem password '" .. pass .. "'!", source, 255, 255, 255, true) 
      triggerClientEvent(source, "onPlayerDoneLogin", source, username, pass) 
      triggerEvent("onPlayerDayZRegister", getRootElement(), username, pass, source) 
    else 
      reason = "Unbekannter Fehler!" 
      outputChatBox("[Login]#FF9900 " .. reason, source, 255, 255, 255, true) 
    end 
  else 
    reason = "Dieses Konto ist bereits vorhanden" 
    outputChatBox("[Login]#FF9900 " .. reason, source, 255, 255, 255, true) 
  end 
end 
  
addEvent("onClientSendRegisterDataToServer", true) 
addEventHandler("onClientSendRegisterDataToServer", getRootElement(), tryToRegsiterPlayer) 
addEventHandler("onPlayerJoin", getRootElement(), function() 
  fadeCamera(source, true) 
  setCameraMatrix(source, 2659.2990722656,2730.078125,11.622900009155,2660.2810058594,2730.2053222656,11.483201980591) 
end 
) 
addEvent("requestServerNews", true) 
addEventHandler("requestServerNews", root, function() 
  -- upvalues: root 
  local text1 = get("news1") 
  local text2 = get("news2") 
  local text3 = get("news3") 
  local text4 = get("news4") 
  local bool1 = get("news1new") 
  local bool2 = get("news2new") 
  local bool3 = get("news3new") 
  local bool4 = get("news4new") 
  triggerClientEvent(source, "onClientGetNews", root, text1, text2, text3, text4, bool1, bool2, bool3, bool4) 
end 
) 
  

But this save the Players on a internal.db and not to a Mysql db.

The Dayz Script load the Players from a MySQL DB

//EDIT The MySQL Dayz with Login are 2 Ressource 1 is Login and the other is the Dayz Script

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