Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2021-03-19, 10:57


NoNamik







Wiek: 35
Na forum: 2327 dni
Posty: 288
Nick w MP: JestemNoNamem

Piwa: 379

Respekt: 60

Witam chcialem zrobic zapamietywanie w xml do logowania lecz cos nie dziala w db3 taki blad
Kod:

WARNING pystories-logging\c_logging.lua:233: Bad argument @ 'xmlFindChild' [Expected xml-node at argument 1, got boolean]

Kod:

WARNING pystories-logging\c_logging.lua:234: Bad argument @ 'xmlFindChild' [Expected xml-node at argument 1, got boolean]


tutaj kod

setWorldSoundEnabled(0, 0, false, true)
setWorldSoundEnabled(0, 29, false, true)
setWorldSoundEnabled(0, 30, false, true)
setWorldSoundEnabled(0, 5, false, true)
setAmbientSoundEnabled( "general", false )
setAmbientSoundEnabled( "gunfire", false )


local screenW, screenH = guiGetScreenSize()

czas = getTickCount()
function roundedRectangle(x, y, rx, ry, color, radius)
    rx = rx - radius * 2
    ry = ry - radius * 2
    x = x + radius
    y = y + radius

    if (rx >= 0) and (ry >= 0) then
        dxDrawRectangle(x, y, rx, ry, color)
        dxDrawRectangle(x, y - radius, rx, radius, color)
        dxDrawRectangle(x, y + ry, rx, radius, color)
        dxDrawRectangle(x - radius, y, radius, ry, color)
        dxDrawRectangle(x + rx, y, radius, ry, color)

        dxDrawCircle(x, y, radius, 180, 270, color, color, 7)
        dxDrawCircle(x + rx, y, radius, 270, 360, color, color, 7)
        dxDrawCircle(x + rx, y + ry, radius, 0, 90, color, color, 7)
        dxDrawCircle(x, y + ry, radius, 90, 180, color, color, 7)
    end
end


local sw,sh = guiGetScreenSize()
local zoom = 1
if sw < 1920 then
    zoom = math.min(2, 1920 / sw)
end

if getElementData(localPlayer, "player:sid") then return end

local root = getRootElement()
local resourceRoot = getResourceRootElement(getThisResource())
local screenWidth, screenHeight = guiGetScreenSize()



local f1= dxCreateFont("uni.otf", 13/zoom)
local f2= dxCreateFont("calibrib.ttf", 10/zoom)
local dxfont1_normal = dxCreateFont("normal.ttf", 10/zoom)
local dxfont2_normal = dxCreateFont("normal.ttf", 12/zoom)
local dxfont3_normal = dxCreateFont("normal.ttf", 11/zoom)
local myScreenSource = dxCreateScreenSource(screenWidth, screenHeight)


local f2ff= dxCreateFont("calibrib.ttf", 20/zoom)
local f1ff= dxCreateFont("normal.ttf", 15/zoom)



local checkbox = {}
checkbox.login = nil 


local sx,sy=guiGetScreenSize()
local data={ showed=nil, button={}, info=nil, misc=nil, }

function isMouseIn(psx,psy,pssx,pssy,abx,aby)
    if not isCursorShowing() then return end
    cx,cy=getCursorPosition()
    cx,cy=cx*sx,cy*sy
    if cx >= psx and cx <= psx+pssx and cy >= psy and cy <= psy+pssy then
        return true,cx,cy
    else
        return false
    end
end
local dist = 100
local angler = 0
function getPointFromDistanceRotation(x, y, dist, angler)
    local a = math.rad(90 - angler)
    local dx = math.cos(a) * dist;
    local dy = math.sin(a) * dist;
    return x+dx, y+dy;
end

function renderLoginBox()
    dxDrawImage(0, 0, sx, sy, "bglog.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
       dxDrawImage(screenW * 0.3438, screenH * 0.1861, screenW * 0.3125, screenH * 0.6287, "panellog.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        if isMouseIn(screenW * 0.3901, screenH * 0.5769, screenW * 0.0922, screenH * 0.0407) then
          roundedRectangle(screenW * 0.3901, screenH * 0.5769, screenW * 0.0922, screenH * 0.0407,  tocolor(5, 5, 5), 15/zoom)
        else
        roundedRectangle(screenW * 0.3901, screenH * 0.5769, screenW * 0.0922, screenH * 0.0407,  tocolor(10, 10, 10), 15/zoom)
        end
        if isMouseIn(screenW * 0.5167, screenH * 0.5769, screenW * 0.0922, screenH * 0.0407) then
          roundedRectangle(screenW * 0.5167, screenH * 0.5769, screenW * 0.0922, screenH * 0.0407,  tocolor(5, 5, 5), 15/zoom)
        else
        roundedRectangle(screenW * 0.5167, screenH * 0.5769, screenW * 0.0922, screenH * 0.0407,  tocolor(10, 10, 10), 15/zoom)
        end        
        dxDrawText("ZALOGUJ", screenW * 0.3896, screenH * 0.5750, screenW * 0.4833, screenH * 0.6185, tocolor(255, 255, 255, 255), 1.00, f1, "center", "center", false, false, false, false, false)
        dxDrawText("ZAREJESTRUJ", screenW * 0.5161, screenH * 0.5750, screenW * 0.6099, screenH * 0.6185, tocolor(255, 255, 255, 255), 1.00, f1, "center", "center", false, false, false, false, false)
        if data.info then
        dxDrawText(data.info, screenW * 0.4031, screenH * 0.6398, screenW * 0.5969, screenH * 0.7315, tocolor(255, 0, 0, 255), 1.00, f2, "center", "center", false, false, false, false, false)
end
        dxDrawText("Zapami?taj mnie", (1920/2), 658, left, top, tocolor(150, 150, 150, 255), 1, f1, "center", "center", false, false, false, false, false)
        if checkbox.login == true then 
            dxDrawRectangle((1920/2)-95, 647, 20, 20, tocolor(255, 204, 0, 255), false)
        elseif checkbox.login == false then 
            dxDrawRectangle((1920/2)-95, 647, 20, 20, tocolor(40, 40, 40, 255), false)
        end
--dxDrawText(guiGetText(zaloguj), 802/zoom, 360/zoom, 1166/zoom, 414/zoom, tocolor(255, 255, 255, 255), 1.00, dxfont1_normal, "left", "center", false, false, true, false, false)
--dxDrawText(string.gsub(guiGetText(zarejestruj), ".", "*"), 800/zoom, 472/zoom, 1166/zoom, 528/zoom, tocolor(255, 255, 255, 255), 1, dxfont2_normal, "left", "center", false, false, true, false, false)

end






addEventHandler("onClientClick", root, function(b, s)
    if b == "left" and s == "down" then 
        if isMouseIn((1920/2)-95, 647, 20, 20) then 
            if checkbox.login == false then 
                checkbox.login = true 
            else
                checkbox.login = false 
            end 
        end
    end
end)

addEvent("zapamietajMnie", true)
addEventHandler( "zapamietajMnie", root, function(  )
    login =  editbox:dxGetEditText("login")
    pass =  editbox:dxGetEditText("has?o")
    if checkbox.login == true then 
    if not xml then
        xml = xmlCreateFile("zapamietaj.xml","login")
        loginXML = xmlCreateChild(xml,"login")
        passXML = xmlCreateChild(xml,"password")
        checkboxXML = xmlCreateChild(xml,"checkboxState")
        xmlNodeSetValue(loginXML, login)
        xmlNodeSetValue(passXML, pass)
        xmlNodeSetValue(checkboxXML, "1")
        xmlSaveFile(xml)
      else
        loginXML = xmlFindChild(xml,"login",0)
        passXML = xmlFindChild(xml,"password",0)
        checkboxXML = xmlFindChild(xml,"checkboxState",0)
        end
    end 
end)
        

addEvent("usunXML", true)
addEventHandler( "usunXML", root, function(  )
    if checkbox.login == false then 
    fileDelete ("zapamietaj.xml")
    end 
end)

addEventHandler("onClientClick", root, function(btn,state)
    if btn=="left" and state=="down" then
        if isMouseIn(screenW * 0.3901, screenH * 0.5769, screenW * 0.0922, screenH * 0.0407) and data.showed then
            local login = exports['pystories_editbox']:dxGetEditText("login")
            local pass = exports['pystories_editbox']:dxGetEditText("haslo")
            if string.len(login) < 2 or string.len(pass) < 2 then
                data.info="Nale?y wype?ni? wszystkie pola."
                return
            end
            triggerServerEvent("logging:checkAccount", resourceRoot, login, pass)
        end
        
        if isMouseIn(screenW * 0.5167, screenH * 0.5769, screenW * 0.0922, screenH * 0.0407) and data.showed then
            local login = exports['pystories_editbox']:dxGetEditText("login")
            local pass = exports['pystories_editbox']:dxGetEditText("haslo")
            if string.len(login) > 22 or string.len(pass) > 22 and string.len(login) < 3 or string.len(pass) < 3 then
                data.info="Login i has?o powinno zawiera? od 3 do 22 znak?w."
                return
            end
            local xml = xmlLoadFile("zapamietaj.xml")
            local checkXML = xmlFindChild(xml,"checkboxState", 0)
            local checkGetChildValue = xmlNodeGetValue(checkXML)
                if checkGetChildValue == "1" then 
                logXML = xmlFindChild(xml,"login", 0)
                passXML = xmlFindChild(xml,"password", 0)
                logGetChildValue =  xmlNodeGetValue(logXML)
                passGetChildValue = xmlNodeGetValue(passXML)
                checkbox.login = true 
                exports['pystories_editbox']:dxSetEditText("login", logGetChildValue)
                exports['pystories_editbox']:dxSetEditText("has?o", passGetChildValue)
                else 
                    checkbox.login = false  
                end                   
            triggerServerEvent("logging:newAccount", resourceRoot, login, pass)
        end
    end
end)

addEvent("logging:result", true)
addEventHandler("logging:result", resourceRoot, function(value,info)
    if not info then info="" end
    if value then
        data.showed=false
        showZones(data.misc)
        
        -- Usuwamy elementy
        exports['pystories_editbox']:dxDestroyEdit("login")
        exports['pystories_editbox']:dxDestroyEdit("haslo")
        removeEventHandler("onClientRender", root, renderLoginBox)
    else
        data.info=tostring(info)
        setTimer(function() data.info=nil end, 3000, 1)
    end
end)

addEventHandler("onClientResourceStart", resourceRoot, function()
    showChat(false)
    showCursor(true)
    fadeCamera(true)
    data.showed=true
    setElementAlpha(localPlayer,0)
    data.misc=playSound("misc/intro.mp3",true)
    showPlayerHudComponent("radar",false)
    setSoundVolume(data.misc, 1.0)
    showPlayerHudComponent("all",false)
    guiSetInputMode("no_binds_when_editing")
    setElementData(localPlayer,"status","Loguje si?")
    local xml = xmlLoadFile("zapamietaj.xml")
    if not xml then 
        checkbox.login = false 
    end 
    local checkXML = xmlFindChild(xml,"checkboxState", 0)
    local checkGetChildValue = xmlNodeGetValue(checkXML)
    if checkGetChildValue == "1" then 
        logXML = xmlFindChild(xml,"login", 0)
        passXML = xmlFindChild(xml,"password", 0)
        logGetChildValue =  xmlNodeGetValue(logXML)
        passGetChildValue = xmlNodeGetValue(passXML)
        
        checkbox.login = true 
        exports['pystories_editbox']:dxSetEditText("login", logGetChildValue)
        exports['pystories_editbox']:dxSetEditText("has?o", passGetChildValue)
        else 
            checkbox.login = false  
    end  
    
    --setElementData(localPlayer,"player:logged",false)
    addEventHandler("onClientRender", root, renderLoginBox)
    local nick = getPlayerName( localPlayer )
                exports['pystories_editbox']:dxCreateEdit("login", "", "Wpisz sw?j login", screenW * 0.4172, screenH * 0.3333, screenW * 0.1807, screenH * 0.0472, false, 255, 255, false, false);

            exports['pystories_editbox']:dxCreateEdit("haslo", "", "Wpisz swoje has?o", screenW * 0.4172, screenH * 0.4426, screenW * 0.1807, screenH * 0.0472, true, 255, 255, false, false);


end)


blad jest w onClientResourceStart
dokladnie tu

    local checkXML = xmlFindChild(xml,"checkboxState", 0)
    local checkGetChildValue = xmlNodeGetValue(checkXML)


Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
borsuk
Wysłany: 2021-03-19, 12:33


marcin778

Krytyk serwerów MTA






Wiek: 24
Na forum: 4291 dni
Posty: 2268
Nick w MP: Marcineg

Piwa: 4661

Respekt: 1436,8
Respekt: 1436,8

W pliku XML nie ma childu "checkboxState".

Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
borsuk
Wysłany: 2021-03-19, 12:38


NoNamik







Wiek: 35
Na forum: 2327 dni
Posty: 288
Nick w MP: JestemNoNamem

Piwa: 379

Respekt: 60

marcin778, a gdzie to dodac

[ Dodano: 2021-03-27, 10:13 ]
marcin778, pomozesz czy nie?

Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
borsuk
Tagi: zapamietywanie :: xml
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA Odpowiedz do tematu

Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Dodaj temat do Ulubionych
Wersja do druku