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

Wysłany: 2021-03-02, 13:47


NoNamik







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

Piwa: 379

Respekt: 60



C.lua


if getElementData(localPlayer, "player:sid") then return end
local sx, sy = guiGetScreenSize()

local sw,sh = guiGetScreenSize()
local zoom = 1
if sw < 1920 then
    zoom = math.min(2, 1920 / sw)
end
local font = dxCreateFont('font.ttf',12/zoom)
local font2 = dxCreateFont('font.ttf',20/zoom)
local actual = false
local root = getRootElement()
local tick = getTickCount()
local resourceRoot = getResourceRootElement(getThisResource())




local checkbox = {}
checkbox.login = nil 


addEventHandler("onClientResourceStop", resourceRoot,
function()
    if (blurShader) then
        destroyElement(blurShader)
        blurShader = nil
    end
end)

local sm = {}
sm.moov = 0
sm.object1,sm.object2 = nil,nil

local function removeCamHandler()
    if(sm.moov == 1)then
        sm.moov = 0
    end
end
 
local function camRender()
    if (sm.moov == 1) then
        local x1,y1,z1 = getElementPosition(sm.object1)
        local x2,y2,z2 = getElementPosition(sm.object2)
        setCameraMatrix(x1,y1,z1,x2,y2,z2)
    end
end
addEventHandler("onClientPreRender",root,camRender)
 
function smoothMoveCamera(x1,y1,z1,x1t,y1t,z1t,x2,y2,z2,x2t,y2t,z2t,time)
    if(sm.moov == 1)then return false end
    sm.object1 = createObject(1337,x1,y1,z1)
    sm.object2 = createObject(1337,x1t,y1t,z1t)
    setElementAlpha(sm.object1,0)
    setElementAlpha(sm.object2,0)
    setObjectScale(sm.object1,0.01)
    setObjectScale(sm.object2,0.01)
    moveObject(sm.object1,time,x2,y2,z2,0,0,0,"InOutQuad")
    moveObject(sm.object2,time,x2t,y2t,z2t,0,0,0,"InOutQuad")
    sm.moov = 1
    setTimer(removeCamHandler,time,1)
    setTimer(destroyElement,time,1,sm.object1)
    setTimer(destroyElement,time,1,sm.object2)
    return true
end

x,y=2313.58, 1282.80-- my width
intro_step=math.random(0,850)

local muzyka = false

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

function getCenter(x, y)
    x,y = x / zoom, y / zoom
    return (sw / 2) - (x / 2), (sh / 2) - (y / 2)
end
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 = 200
local angler = 0
function getPointFromDistanceRotation(x, y, dist, angler)
    local a = math.rad(270 - angler)
    local dx = math.cos(a) * dist;
    local dy = math.sin(a) * dist;
    return x+dx, y+dy;
end


function renderLoginBox()
        if actual == 'login' then
        dxDrawImage(0/zoom, 0/zoom, 1920/zoom, 1080/zoom, "img/login.png", 0, 0, 0, tocolor(255,255,255,255), false)
    end
        if actual == 'register' then
        dxDrawImage(0/zoom, 0/zoom, 1920/zoom, 1080/zoom, "img/login.png", 0, 0, 0, tocolor(255,255,255,255), false)
    end    
        if isMouseIn(853/zoom, 579/zoom, 214/zoom, 53/zoom) then
        dxDrawImage(853/zoom, 579/zoom, 214/zoom, 53/zoom, ":psrpg-logging/img/click2.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
    else
        dxDrawImage(853/zoom, 579/zoom, 214/zoom, 53/zoom, ":psrpg-logging/img/click.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
    end
    if actual == 'login' then
        dxDrawText("Kliknij aby przejsc do rejestracji", 850/zoom, 781/zoom, 1070/zoom, 805/zoom, tocolor(255, 255, 255, 255), 1, font, "center", "center", false, false, false, false, false)
dxDrawText("ZALOGUJ", 881/zoom, 580/zoom, 1039/zoom, 630/zoom, tocolor(255, 255, 255, 255), 1, font2, "center", "center", false, false, false, false, false)
    

        dxDrawText(guiGetText(zaloguj), 841/zoom, 386/zoom, 1119/zoom, 424/zoom, tocolor(255, 255, 255, 255), 1, font, "left", "center", false)
        if guiEditIsMasked(zarejestruj) then
        dxDrawText(string.gsub(guiGetText(zarejestruj), ".", "*"), 841/zoom, 500/zoom, 1119/zoom, 538/zoom, tocolor(255, 255, 255, 255), 1, font, "left", "center", false)
    end
            dxDrawText("Zapami?taj mnie", (1920/2), 658, left, top, tocolor(150, 150, 150, 255), 1, "default-bold", "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
end
    if actual == 'register' then
        dxDrawText("Kliknij aby przejsc do logowania", 850/zoom, 781/zoom, 1070/zoom, 805/zoom, tocolor(255, 255, 255, 255), 1, font, "center", "center", false, false, false, false, false)

        
        dxDrawText("ZAREJESTRUJ", 881/zoom, 580/zoom, 1039/zoom, 630/zoom, tocolor(255, 255, 255, 255), 1, font2, "center", "center", false, false, false, false, false)
        dxDrawText(guiGetText(zaloguj), 841/zoom, 386/zoom, 1119/zoom, 424/zoom, tocolor(255, 255, 255, 255), 1, font, "left", "center", false)
        if guiEditIsMasked(zarejestruj) then
        dxDrawText(string.gsub(guiGetText(zarejestruj), ".", "*"), 841/zoom, 500/zoom, 1119/zoom, 538/zoom, tocolor(255, 255, 255, 255), 1, font, "left", "center", false)
    end
end

    if data.info then
        
        dxDrawText(""..data.info, 730/zoom, 826/zoom, 1193/zoom, 1047/zoom, tocolor(255, 0, 0, 255), 1, font, "center", "center", false, false, false, false, false)
    end

end


function math.round(number, decimals, method)
    decimals = decimals or 0
    local factor = 10 ^ decimals
    if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor
    else return tonumber(("%."..decimals.."f"):format(number)) 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
        local x_2, y_2 = getCenter(328,-115)
        local x_4, y_4 = getCenter(300,800)
        if isMouseIn(853/zoom, 579/zoom, 214/zoom, 53/zoom) and data.showed and actual == 'login' then
            setTimer(function()
            local login=guiGetText(zaloguj)
            local pass=guiGetText(zarejestruj)
            if string.len(login) < 2 or string.len(pass) < 2 then
                data.info="Aby si? zalogowa? nale?y wype?ni? wszystkie pola."
                return
            end
            triggerServerEvent("logging:checkAccount", resourceRoot, login, pass)
             end, 1000, 1)
        elseif isMouseIn(853/zoom, 579/zoom, 214/zoom, 53/zoom) and data.showed and actual == 'register' then
            setTimer(function()
            local login=guiGetText(zaloguj)
            local pass=guiGetText(zarejestruj)
            if string.len(login) > 22 or string.len(pass) > 22 and string.len(login) < 3 or string.len(pass) < 3 then
                data.info="Nazwa/Has?o U?ytkownika musi zawiera? od 3 do 22 znak?w"
                return
            end
            triggerServerEvent("logging:newAccount", resourceRoot, login, pass)
                end, 1000, 1)
        elseif isMouseIn(874/zoom, 781/zoom, 179/zoom, 19/zoom) and data.showed and actual == 'login' then
            actual = 'register'
        elseif isMouseIn(874/zoom, 781/zoom, 179/zoom, 19/zoom) and data.showed and actual == 'register' then
            actual = 'login'
        
        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(muzyka)
        
        -- Usuwamy elementy
        destroyElement(zaloguj)
        destroyElement(zarejestruj)
        removeEventHandler("onClientRender", root, renderLoginBox)
        removeEventHandler("onClientPreRender",root,camRender)

        local tick = getTickCount()
    else
        data.info=tostring(info)
        setTimer(function() data.info=nil end, 3000, 1)
    end
end)



    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,"zaloguj", 0)
        passXML = xmlFindChild(xml,"zarejestruj", 0)
        logGetChildValue =  xmlNodeGetValue(logXML)
        passGetChildValue = xmlNodeGetValue(passXML)
        
        checkbox.login = true 
        dxSetEditText("zaloguj", logGetChildValue)
        dxSetEditText("zarejestruj", passGetChildValue)
        else 
            checkbox.login = false  
    end  


addEventHandler("onClientResourceStart", resourceRoot, function()
    showChat(false)
    showCursor(true)
    fadeCamera(true)
    data.showed=true
    setElementAlpha(localPlayer,0)
    local tick = getTickCount()
    muzyka=playSound("misc/intro2.mp3",true)
    actual = 'login'
    setSoundVolume(muzyka, 1.0)
    showPlayerHudComponent("all",false)
    showPlayerHudComponent("radar",false)
    showPlayerHudComponent("crosshair",true)
    showPlayerHudComponent("weapon",false)
    showPlayerHudComponent("radar",false)
    showPlayerHudComponent("health",false)
    showPlayerHudComponent("breath",false)
    showPlayerHudComponent("clock",false)
    showPlayerHudComponent("ammo",false)
    guiSetInputMode("no_binds_when_editing")
    setElementData(localPlayer,"status","Loguje si?")
    --setElementData(localPlayer,"player:logged",false)
    addEventHandler("onClientRender", root, renderLoginBox)
    zaloguj=guiCreateEdit(840/zoom, 386/zoom, 279/zoom, 38/zoom, "", false)
    zarejestruj=guiCreateEdit(840/zoom, 500/zoom, 2799/zoom, 38/zoom, "", false)  
    guiEditSetMasked(zarejestruj,true)
    guiEditSetMaxLength(zaloguj, 22)
    guiEditSetMaxLength(zarejestruj, 22)
    guiSetAlpha(zaloguj,0.0)
    guiSetAlpha(zarejestruj,0.0)
    guiSetVisible(zaloguj,true)
    guiSetVisible(zarejestruj,true)
end)



Postaw piwo autorowi tego posta
 

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


xyzzzikk

.gg






Wiek: 19
Na forum: 2915 dni
Posty: 175
Nick w MP: aspyk

Piwa: 6564

Respekt: 30,5

kt?ra to linia 252?

Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
borsuk
Tagi: zapamietywanie :: db3
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