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

Wysłany: 2016-08-15, 20:42


AlaneqYT

Uczeń LUA






Wiek: 25
Na forum: 3884 dni
Posty: 37

Piwa: 20

Respekt: 25,3

Ostrzeżeń: 20%
Witam, zn?w ja! :)
Jak mo?na by by?o zablokowa? wej?cie 2 os?b na jedno konto w tym samym czasie.

server:


("logging:checkAccount"true)
addEventHandler("logging:checkAccount"resourceRoot, function(login,pass)
    local result=exports["ogrpg-db"]:dbGet("SELECT * FROM ogrpg_users WHERE login=?"login)
    if result and #result > 0 then
        if result[1].login == login and result[1].pass == md5(passthen
            local account getAccount(login,pass)
            if account then
                logIn(client,account,pass)
            end
            setPlayerName(clientlogin)
            setElementData(client"player:uid"result[1].id)
            triggerClientEvent(client"logging:result"resourceRoottruenil)
                        
        else
            triggerClientEvent(client"logging:result"resourceRootfalse"Podane dane s? nieprawid?owe.")
        end
    else
        triggerClientEvent(client"logging:result"resourceRootfalse"Podany login nie istnieje w bazie.")
    end
end)
addEvent("onClientSendRegisterDataToServer"true)
addEventHandler("onClientSendRegisterDataToServer"getRootElement(), dodaj)
addEvent("logging:newAccount"true)
addEventHandler("logging:newAccount"resourceRoot, function(login,pass)
       local result=exports["ogrpg-db"]:dbGet("SELECT * FROM ogrpg_users WHERE login=?"login)
    if result and #result > 0 then
        triggerClientEvent(client"logging:result"resourceRootfalse"Podany login ju? istnieje w bazie.")
    else
        local query=exports["ogrpg-db"]:dbSet("INSERT INTO ogrpg_users (login,pass) VALUES (?,?)"loginmd5(pass))
        if getPlayerFromName(Playerthen 
        triggerClientEvent(client"logging:result"resourceRootfalse"Ktos juz jest na tym koncie.")
        else
        triggerClientEvent(client"logging:result"resourceRootfalse"Pomy?lnie zalogowa?e?/a? si?")
        end
        if query then
            triggerClientEvent(client"logging:result"resourceRootfalse"Pomy?lnie zalogowa?e?/a? si?")
            addAccount(loginpass)
            logIn(client,login,pass)
        end
    end
end)


client:
 --[[
    ResourceOURGame v2
    DevelopersSplit <split.programista@gmail.com>
    You have no right to use this code without my permission.
    (c2015 <split.programista@gmail.com>. All rights reserved.
]]

local sx,sy=guiGetScreenSize()
local data={ showed=nilbutton={}, info=nilmisc=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

function renderLoginBox()
    dxDrawRectangle(sx*0/1024sy*201/768sx*1024/1024sy*308/768tocolor(000188
), false)
    if data.info then dxDrawText(data.infosx*252/1024sy*232/768sx*800/1024sy*255/768tocolor(23700255), 1.00"default""center""center"falseend
    dxDrawLine(sx*0/1024sy*199/768sx*1022/1024sy*200/768tocolor(31111193255), 5false)
    dxDrawLine(sx*0/1024sy*509/768sx*1022/1024sy*510/768tocolor(31111193255), 5false)
    dxDrawText("Second-World.pl"sx*0/1024sy*157/768sx*1024/1024sy*237/768white2.00"pricedown""center""center"false)
    dxDrawText("U?ytkownik:"sx*256/1024sy*272/768sx*484/1024sy*305/768white1.00"default-bold""center""center"false)
    dxDrawText("Has?o"sx*571/1024sy*269/768sx*799/1024sy*302/768white1.00"default-bold""center""center"false)
    if not isMouseIn(sx*256/1024sy*408/768sx*226/1024sy*45/768then dxDrawRectangle(sx*256/1024sy*408/768sx*226/1024sy*45/768tocolor(2698197255), false)
    else dxDrawRectangle(sx*256/1024sy*408/768sx*226/1024sy*45/768tocolor(000202), falseend
    if not isMouseIn(sx*573/1024sy*407/768sx*226/1024sy*45/768then dxDrawRectangle(sx*573/1024sy*407/768sx*226/1024sy*45/768tocolor(2698197255), false)
    else dxDrawRectangle(sx*573/1024sy*407/768sx*226/1024sy*45/768tocolor(000202), falseend
    dxDrawText("Zaloguj si?"sx*255/1024sy*408/768sx*482/1024sy*453/768white1.00"default""center""center"false)
    dxDrawText("Zarejestruj si?"sx*572/1024sy*407/768sx*799/1024sy*452/768white1.00"default""center""center"false)
end

addEventHandler("onClientClick"root, function(btn,state)
    if btn=="left" and state=="down" then
        if isMouseIn(sx*256/1024sy*408/768sx*226/1024sy*45/768) and data.showed then
            local login=guiGetText(data.button[1])
            local pass=guiGetText(data.button[2])
            if string.len(login) < or string.len(pass) < 2 then
                data.info="Wype?nij wszystkie pola!"
                return
            end
            triggerServerEvent("logging:checkAccount"resourceRootloginpass)
        end
        if isMouseIn(sx*573/1024sy*407/768sx*226/1024sy*45/768) and data.showed then
            local login=guiGetText(data.button[1])
            local pass=guiGetText(data.button[2])
            if string.len(login) < or string.len(pass) < 2 then
                data.info="Wype?nij wszystkie pola!"
                return
            end
            if string.len(login) > 22 or string.len(pass) > 30 then
                data.info="Login/Has?o musi mie? mniej ni? 22/30 znak?w."
                return
            end
            triggerServerEvent("logging:newAccount"resourceRootloginpass)
        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
        destroyElement(data.button[1])
        destroyElement(data.button[2])
        removeEventHandler("onClientRender"rootrenderLoginBox)
    else
        data.info=tostring(info)
        setTimer(function() data.info=nil end30001)
    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)
    setSoundVolume(data.misc1.0)
    showPlayerHudComponent("all",false)
    guiSetInputMode("no_binds_when_editing")
    setElementData(localPlayer,"status","Loguje si?")
    setElementData(localPlayer,"player:logged",false)
    addEventHandler("onClientRender"rootrenderLoginBox)
    data.button[1]=guiCreateEdit(0.250.410.220.05""true)
    data.button[2]=guiCreateEdit(0.560.410.220.05""true)   
end)

Oczywi?cie, prosz? o szybk? pomoc! :) Z g?ry dziekuje.

[ Dodano: 2016-08-16, 16:10 ]
Moze ktos pomoc? :P

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-16, 16:19


AteX







Wiek: 26
Na forum: 4015 dni
Posty: 927
Nick w MP: #AteX

Piwa: 8360

Respekt: 775,3
Respekt: 775,3Respekt: 775,3

setPlayerName(clientlogin)

Ustawiasz nick gracza po zalogowaniu, wi?c najpro?ciej po prostu sprawdzaj przy logowaniu czy gracz o takim nicku jest.
if getPlayerFromName(loginthen return end


Podpis
MultiTheftAuto++ dla MTA 1.5.7 już dostępne.
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-16, 16:23


AlaneqYT

Uczeń LUA






Wiek: 25
Na forum: 3884 dni
Posty: 37

Piwa: 20

Respekt: 25,3

Ostrzeżeń: 20%
Okej, zrobilem to i teraz nie mozna sie zalogowac.
kod:

addEvent("logging:checkAccount"true)
addEventHandler("logging:checkAccount"resourceRoot, function(login,pass)
    local result=exports["ogrpg-db"]:dbGet("SELECT * FROM ogrpg_users WHERE login=?"login)
    if result and #result > 0 then
        if result[1].login == login and result[1].pass == md5(passthen
            local account getAccount(login,pass)
            if account then
                logIn(client,account,pass)
            end
            setPlayerName(clientlogin)
            if getPlayerFromName(loginthen return end
            setElementData(client"player:uid"result[1].id)
            triggerClientEvent(client"logging:result"resourceRoottruenil)
                        
        else
            triggerClientEvent(client"logging:result"resourceRootfalse"Podane dane s? nieprawid?owe.")
        end
    else
        triggerClientEvent(client"logging:result"resourceRootfalse"Podany login nie istnieje w bazie.")
    end
end)
addEvent("onClientSendRegisterDataToServer"true)
addEventHandler("onClientSendRegisterDataToServer"getRootElement(), dodaj)
addEvent("logging:newAccount"true)
addEventHandler("logging:newAccount"resourceRoot, function(login,pass)
       local result=exports["ogrpg-db"]:dbGet("SELECT * FROM ogrpg_users WHERE login=?"login)
    if result and #result > 0 then
        triggerClientEvent(client"logging:result"resourceRootfalse"Podany login ju? istnieje w bazie.")
    else
        local query=exports["ogrpg-db"]:dbSet("INSERT INTO ogrpg_users (login,pass) VALUES (?,?)"loginmd5(pass))
        if getPlayerFromName(Playerthen 
        triggerClientEvent(client"logging:result"resourceRootfalse"Ktos juz jest na tym koncie.")
        else
        triggerClientEvent(client"logging:result"resourceRootfalse"Pomy?lnie zalogowa?e?/a? si?")
        end
        if query then
            triggerClientEvent(client"logging:result"resourceRootfalse"Pomy?lnie zalogowa?e?/a? si?")
            addAccount(loginpass)
            logIn(client,login,pass)
        end
    end
end)


A DB3 nic.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-16, 16:25


AteX







Wiek: 26
Na forum: 4015 dni
Posty: 927
Nick w MP: #AteX

Piwa: 8360

Respekt: 775,3
Respekt: 775,3Respekt: 775,3

Teraz zobacz co zrobi?e?. Sprawdzasz czy jest gracz o podanym nicku dopiero po tym jak gracz si? zaloguje, a nie na samym pocz?tku jeszcze przed logowaniem.

Podpis
MultiTheftAuto++ dla MTA 1.5.7 już dostępne.
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-16, 16:27


AlaneqYT

Uczeń LUA






Wiek: 25
Na forum: 3884 dni
Posty: 37

Piwa: 20

Respekt: 25,3

Ostrzeżeń: 20%
Czyli to ma byc tak?
addEvent("logging:checkAccount"true)
addEventHandler("logging:checkAccount"resourceRoot, function(login,pass)
    local result=exports["ogrpg-db"]:dbGet("SELECT * FROM ogrpg_users WHERE login=?"login)
    if result and #result > 0 then
        if result[1].login == login and result[1].pass == md5(passthen
            local account getAccount(login,pass)
            if account then
                logIn(client,account,pass)
            end
            if getPlayerFromName(loginthen return end
            setPlayerName(clientlogin)
            setElementData(client"player:uid"result[1].id)
            triggerClientEvent(client"logging:result"resourceRoottruenil)
                        
        else
            triggerClientEvent(client"logging:result"resourceRootfalse"Podane dane s? nieprawid?owe.")
        end
    else
        triggerClientEvent(client"logging:result"resourceRootfalse"Podany login nie istnieje w bazie.")
    end
end)
addEvent("onClientSendRegisterDataToServer"true)
addEventHandler("onClientSendRegisterDataToServer"getRootElement(), dodaj)
addEvent("logging:newAccount"true)
addEventHandler("logging:newAccount"resourceRoot, function(login,pass)
       local result=exports["ogrpg-db"]:dbGet("SELECT * FROM ogrpg_users WHERE login=?"login)
    if result and #result > 0 then
        triggerClientEvent(client"logging:result"resourceRootfalse"Podany login ju? istnieje w bazie.")
    else
        local query=exports["ogrpg-db"]:dbSet("INSERT INTO ogrpg_users (login,pass) VALUES (?,?)"loginmd5(pass))
        if getPlayerFromName(Playerthen 
        triggerClientEvent(client"logging:result"resourceRootfalse"Ktos juz jest na tym koncie.")
        else
        triggerClientEvent(client"logging:result"resourceRootfalse"Pomy?lnie zalogowa?e?/a? si?")
        end
        if query then
            triggerClientEvent(client"logging:result"resourceRootfalse"Pomy?lnie zalogowa?e?/a? si?")
            addAccount(loginpass)
            logIn(client,login,pass)
        end
    end
end)


Jezeli tak to dalej nie dziala.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-16, 16:31


AteX







Wiek: 26
Na forum: 4015 dni
Posty: 927
Nick w MP: #AteX

Piwa: 8360

Respekt: 775,3
Respekt: 775,3Respekt: 775,3

Spr?buj jeszcze tak.
local plr getPlayerFromName(login)
if plr and getElementData(plr,"player:uid"then return end


Podpis
MultiTheftAuto++ dla MTA 1.5.7 już dostępne.
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-16, 16:38


AlaneqYT

Uczeń LUA






Wiek: 25
Na forum: 3884 dni
Posty: 37

Piwa: 20

Respekt: 25,3

Ostrzeżeń: 20%
Dobra dziala do zamkniecia.

Postaw piwo autorowi tego posta
 

 
Tagi: blokada
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Blokada 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