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

Wysłany: 2018-05-10, 03:56


Vxen







Wiek: 28
Na forum: 4228 dni
Posty: 293

Piwa: 1299

Respekt: 130,5
Respekt: 130,5

W panelu logowania zrobi?em lataj?c? kamer? dzi?ki smoothMoveCamera, no i po zalogowaniu kamera stoi w ostanim miejscu i nie przechodzi na gracza... jak temu zaradzi??

[ Dodano: 2018-05-10, 05:03 ]
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

local sw, sh = guiGetScreenSize()
local w, h = (sw/1680), (sh/1050)



local gui = {
    login = guiCreateEdit(0.45*w, 0.35*h, 0.15*w, 0.04*h, "msmsmsm", true),
    pass = guiCreateEdit(0.45*w, 0.41*h, 0.15*w, 0.04*h, "12345", true),
}



function renderDX()
    dxDrawRectangle(620*w, 332*h, 417*w, 332*h, tocolor(0, 0, 0, 180), false)
    dxDrawLine(620*w, 500*h, 1037*w, 500*h, tocolor(255, 255, 255, 127), 1, false)
    dxDrawLine(620*w, 580*h, 1037*w, 580*h, tocolor(255, 255, 255, 127), 1, false)
    dxDrawText("Zaloguj si?", 750*w, 531*h, 890*w, 553*h, tocolor(255, 255, 255, 255), 2.20, "default-bold", "center", "center", false, false, false, false, false)
    dxDrawText("Zarejestruj si?", 750*w, 597*h, 890*w, 636*h, tocolor(255, 255, 255, 255), 2.20, "default-bold", "center", "center", false, false, false, false, false)
    dxDrawText("Login:", 527*w, 491*h, 839*w, 260*h, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
    dxDrawText("Has?o:", 527*w, 455*h, 839*w, 420*h, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
    dxDrawImage(550*w, 50*h, 539*w, 400*h,"files/logo.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) 
    
    dxDrawRectangle(475*w, 530*h, 415*w, 53*h, tocolor(0, 255, 255, 180), false)

    dxDrawRectangle(475*w, 583*h, 415*w, 53*h, tocolor(255, 255, 255, 180), false)
end



addEventHandler("onClientResourceStart", resourceRoot, function()
    showGUI(true)
    fadeCamera(true)
    guiEditSetMasked(gui.pass, true)
    smoothMoveCamera (-1527.97180, -259.88281, 14.34688, -1555.83667, -203.45720, 19.37344, -1661.17383, -168.68188, 19.37344, -1632.46838, -138.43019, 19.37344, 8000)

end)



addEvent("closePanel", true)
addEventHandler("closePanel", resourceRoot, function()
    showGUI(false)
end)



addEventHandler("onClientClick", root, function(btn,state)
    local login = guiGetText(gui.login)
    local pass = guiGetText(gui.pass)
    if guiGetVisible(gui.login) and guiGetVisible(gui.pass) then
        if btn == "left" and state == "up" then
            if isMouseInPosition(475*w, 530*h, 415*w, 53*h) then
                triggerServerEvent("tryLogin", resourceRoot, login, pass)
            elseif isMouseInPosition(475*w, 583*h, 415*w, 53*h) then
                if #login >= 3 and #pass >= 3 then
                    triggerServerEvent("tryRegister", resourceRoot, login, pass)
                else
                    outputChatBox("* Login i/lub has?o musz? mie? minimalnie 3 znaki!")
                end
            end
        end
    end
end)



function showGUI(value)
    if value then
        showCursor(true)
        setPlayerHudComponentVisible("all", false)
        s = playSound("files/intro.mp3")
        addEventHandler("onClientRender", root, renderDX)
        guiSetVisible(gui.login, true)
        guiSetVisible(gui.pass, true)

    else
        showCursor(false)
        setPlayerHudComponentVisible("all", true)
        destroyElement(s)
        removeEventHandler("onClientRender", root, renderDX)
        guiSetVisible(gui.login, false)
        guiSetVisible(gui.pass, false)        
    end
end



function isMouseInPosition(x,y,width,height)
    if not isCursorShowing() then return false end
    
    local sx,sy = guiGetScreenSize()
    local cx,cy = getCursorPosition()
    local cx,cy = (cx * sx), (cy * sy)
    if (cx >= x and cx <= x + width) and (cy >= y and cy <= y + height) then
        return true
    else
        return false
    end
end


[ Dodano: 2018-05-10, 05:04 ]
s-lua
addEventHandler("onResourceStart", resourceRoot, function()
    local baza = "logo.res"
    local host = "127.0.0.1"
    local user = "root"
    local pass = ""

    db = dbConnect("mysql", "dbname="..baza..";host="..host, user, pass, "share=1") -- Po??czenie z serwerem MySQL.
end)

function blockChatMessage()
    cancelEvent()
end
addEventHandler( "onPlayerChat", getRootElement(), blockChatMessage )

addEvent("tryRegister", true)
addEventHandler("tryRegister", resourceRoot, function(login,pass)
    local q = dbQuery(db, "SELECT login FROM users WHERE login=?", login)
    local w = dbPoll(q, -1)
    if w and #w > 0 then
        outputChatBox("* Istnieje ju? konto o podanym nicku!", client)
    else
        outputChatBox("* Rejestrujesz si? pomy?lnie!", client)
        dbExec(db, "INSERT INTO users SET login=?, pass=?, skin=137, pieniadze=800, health=100, posx=2252.31, posy=-91.91, posz=26.48, rotx=90", login, md5(pass))
    end
end)

addEvent("tryLogin", true)
addEventHandler("tryLogin", resourceRoot, function(login,pass)
    local q = dbQuery(db, "SELECT * FROM users WHERE login=? AND pass=?", login, md5(pass), getPlayerIP(client))
    local w = dbPoll(q, -1)
    if w and #w > 0 then
            outputChatBox("Witaj na Social Track Role Play!", client)
            removeEventHandler("onPlayerChat", getRootElement(), blockChatMessage)
       triggerClientEvent(client, "closePanel", resourceRoot)
       setCameraTarget(client, client)
       setPlayerName(client, w[1].login)
       setPlayerMoney(client, w[1].pieniadze)
       setElementHealth(source, w[1].health)
       setElementFrozen(client,false)
       setPedArmor(client, w[1].armor)
       setElementModel(client, w[1].skin)
       setElementPosition(client, w[1].posx, w[1].posy, w[1].posz)
       dbExec(db, "UPDATE users SET serial=?, playerIP=?", getPlayerSerial(client), getPlayerIP(client))
    else
        outputChatBox("Podany login lub has?o s? nieprawid?owe! #FFFFFFSpr?buj jeszcze raz.", client, 255, 0, 0, true)
    end
end)
--onPlayer
--onPlayerLogout
--onPlayerQuit
--getElementHealth
addEventHandler("onPlayerQuit",root,function()
    local login = getPlayerName(source)
    local pieniadze = getPlayerMoney(source)
    local health = getElementHealth(source)
    local skin = getElementModel(source)
    local x,y,z = getElementPosition(source)
    local armor = getPedArmor(source)
    dbExec(db,"UPDATE users SET pieniadze=?, health=?, skin = ?, posx=?, posy=?, posz=?, armor=? WHERE login=?",pieniadze, health, skin, x, y, z, armor, login)
end)



Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-05-10, 16:09


Xrent

-






Wiek: 22
Na forum: 3188 dni
Posty: 230
Nick w MP: Pazdam

Piwa: 535

Respekt: 295,3
Respekt: 295,3Respekt: 295,3Respekt: 295,3

Ostrzeżeń: 60%

Więcej informacji znajdziesz w Wikipedii MTA:

setCameraTarget
je?li, dobrze rozumiem.
Bo u mnie te? mam cameraTarget no i po kamerze od razu spawnuje u ciebie z tego co widze te? jest ale chyba w z?ym miejscu jak b?d? pc poprawi?.
 addEvent("closePanel", true)
addEventHandler("closePanel", resourceRoot, function()
    showGUI(false)
end) 
w ko?cowej fazie logowania daj setCameraTarget. Dok?adnie, nie wiem bo na tel jestem daj w end login ev w c side spr?buj bo mo?e w side cos nie dziala. Ja mam w c side i dziala.

Postaw piwo autorowi tego posta
 

 
Tagi: czemu :: kamera :: staje :: miejscu :: zalogowaniu
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA Ten temat jest zablokowany bez możliwości zmiany postów lub pisania odpowiedzi

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