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

Wysłany: 2017-10-21, 12:23


Husky123







Wiek: 21
Na forum: 3460 dni
Posty: 45
Nick w MP: fabeN

Piwa: 750

Respekt: 60

Pomo?e mi kto? zrobi? org na paczce OWN bo chce zrobi? serwer na tej paczce.
Ale nie dzia?aj? mi Organizacje.

Tak wiem, ?e nie ten dzia? tylko potrzebuje szybko pomocy.

Napiscie w jakim skrypcie jest b??d i jak go naprawi? b?d? wdzi?czny.


Zrobi?em takie ?eczy ale i tak nie dzia?a?o:
-doda?em si? do organizacji.

Oto kody

--[[
    System kont graczy w oparciu o MySQL
    @author value <value2k@gmail.com>
    Nie masz prawa u?y? tego kodu bez mojej zgody
]]
addEvent("onPlayerAccountLogin", true)
local defpos = "-1503.07,920.32,7.19, 90, 0, 0" -- Domy?lna pozycja musi by? w stringu!

function auth(username, password)
    if not username then
        exports.rpg_noti:createNotification(source, "error", "B??d podczas pr?by logowania, zg?o? to administratorowi na forum [ERR01]")
        return
    end
    if not password then
        exports.rpg_noti:createNotification(source, "error", "B??d podczas pr?by logowania, zg?o? to administratorowi na forum [ERR02]")
        return
    end
    local q = exports.rpg_mysql:mysql_query("SELECT * FROM rpg_accounts WHERE username=? AND password=?", username, md5(password))
    if #q > 1 then -- Znaleziono wi?cej ni? 1 usera o podanej kombinacji loginu i has?a
        exports.rpg_noti:createNotification(source, "error", "B??d podczas pr?by logowania, zg?o? to administratorowi na forum [ERR03]")
    elseif #q < 1 then -- Nie znaleziono ?adnego usera o podanej kombinacji loginu i has?a
        exports.rpg_noti:createNotification(source, "error", "Podana kombinacja nazwy u?ytkownika i has?a jest b??dna")
    else -- Jest tylko jeden user! Hura!
        for i,p in pairs(getElementsByType("player")) do
        if q[1].uid == getElementData(p, "user:uid") then
            exports.rpg_noti:createNotification(source, "error", "Niestety ale kto? jest ju? zalogowany na podanym koncie")
            return
        end
        end
        local player = source
        fadeCamera(player, false)
        setPlayerName(player, q[1].username)
        triggerClientEvent(player, "cursor:off", player)

        setElementData(player, "user:uid", q[1].uid)
        setElementData(player, "user:username", q[1].username)
        --setElementData(player, "user:email", q[1].email)
        setElementData(player, "user:regdate", q[1].regdate)
        setElementData(player, "user:lastlogin", q[1].lastlogin)
        setElementData(player, "user:serial", q[1].serial)
        setElementData(player, "user:ip", q[1].ip)
        setElementData(player, "user:skin", q[1].skin)
        setElementData(player, "user:money", q[1].money)
        setElementData(player, "user:bankmoney", q[1].bankmoney)
        setElementData(player, "user:gamescore", q[1].gamescore)
        setElementData(player, "user:job", q[1].job)
        setElementData(player, "user:jobmoney", q[1].jobmoney)
        setElementData(player, "user:pjA", q[1].pjA)
        setElementData(player, "user:pjB", q[1].pjB)
        setElementData(player, "user:pjC", q[1].pjC)
        setElementData(player, "user:pjCE", q[1].pjCE)
        setElementData(player, "user:onlinetime", q[1].onlinetime)
        setElementData(player, "user:aduty", false)
        setElementData(player, "user:licensegornik", q[1].lickag)
        setElementData(player, "user:org", q[1].organizacja)
        setElementData(player, "user:orgrank", q[1].orgrank)
        setElementData(player, "user:fid", q[1].frakcja)
        setElementData(player, "user:frank", q[1].franga)
        setElementData(player, "user:ftime", q[1].ftime)

        if string.len(q[1].serial) < 1 then
            local serial = getPlayerSerial(player)
            local q2 = exports.rpg_mysql:mysql_query("UPDATE rpg_accounts SET serial=? WHERE uid=?", serial, q[1].uid)
            if not q2 then
                exports.rpg_noti:createNotification(source, "error", "B??d podczas pr?by logowania, zg?o? to administratorowi na forum [ERR10]")
                return
            end
        end

        if string.len(q[1].ip) < 1 then
            local ip = getPlayerIP(player)
            local q3 = exports.rpg_mysql:mysql_query("UPDATE rpg_accounts SET ip=? WHERE uid=?", ip, q[1].uid)
            if not q3 then
                exports.rpg_noti:createNotification(source, "error", "B??d podczas pr?by logowania, zg?o? to administratorowi na forum [ERR11]")
                return
            end
        end

        local q2 = exports.rpg_mysql:mysql_query("SELECT * FROM rpg_admins WHERE user=?", q[1].uid)
        if #q2 > 0 then
            setElementData(player, "user:admin", q2[1].level)
            setElementData(player, "user:aperm", q2[1])
        else
            setElementData(player, "user:admin", 0)
            setElementData(player, "user:aperm", false)
        end

        local oq = exports.rpg_mysql:mysql_query("SELECT * FROM rpg_organizacje WHERE uid=?", q[1].nazwa)
        if #oq > 0 then
        setElementData(player, "user:org", oq[1].nazwa)
        setElementData(player, "user:orgrank", oq)
      else
        setElementData(player, "user:org", false)
        setElementData(player, "user:orgrank", false)
           end


        local qtuner = exports.rpg_mysql:mysql_query("SELECT * FROM rpg_tunerzy WHERE uid=?", q[1].uid)
        if #qtuner > 0 then
            setElementData(player, "user:tuning", true)
        else
            setElementData(player, "user:tuning", false)
        end

        local pd = split(q[1].premium, " ")
        local pd1 = split(pd[1], "-")
        local pd2 = split(pd[2], ":")
        local ts1 = getTimestamp()
        local ts2 = getTimestamp(pd1[1], pd1[2], pd1[3], pd2[1], pd2[2], pd2[3])
        if ts1 <= ts2 then
            local fs = ts2 - ts1
            local p_left = math.floor(fs/86400)
            if p_left < 1 then
                p_left = math.floor(fs/3600)
                if p_left < 1 then
                    p_left = math.floor(fs/60).." min."
                else
                    p_left = p_left.." godz."
                end
            else
                    p_left = p_left.." d."
            end
            outputChatBox("[#FFFF00#PREMIUM#FFFFFF] Posiadasz ulepszenie konta do statusu premium jeszcze na "..p_left, player, 255, 255, 255, true)
            setElementData(player, "user:premium", true)
            setPlayerNametagColor(player, 255, 200, 0)
            setElementData(player, "user:premium:ts", ts2)
        else
            setElementData(player, "user:premium", false)
        end

        local timer = setTimer(function ()
            setElementData(player, "user:onlinetime", getElementData(player, "user:onlinetime")+1)
            local cts = getTimestamp()
            if getElementData(player, "user:premium") then
                local pts = getElementData(player, "user:premium:ts") or 0
                if pts < cts then
                    outputChatBox("[#FFFF00#PREMIUM#FFFFFF] Twoje ulepszenie do konta premium dobiega ko?ca!", player, 255, 255, 255, true)
                    setElementData(player, "user:premium", false)
                end
            end
        end, 60000, 0)
        setElementData(player, "user:timer", timer)

        setTimer(function ()
            fadeCamera(player, true)
            local pos = split(q[1].position, ",")
            spawnPlayer(player, pos[1], pos[2], pos[3], pos[4], q[1].skin, pos[5], pos[6])

            setElementHealth(player, q[1].health)
            setPedArmor(player, q[1].armor)

            toggleControl(player, "fire", false)
            setCameraTarget(player, player)
            setElementData(player, "user:logged", true)
            setElementData(player, "hud:enabled", true)
            if tonumber(pos[5]) < 1 then
                showPlayerHudComponent(player, "clock", false)
                showPlayerHudComponent(player, "health", true)
                showPlayerHudComponent(player, "armour", true)
                showPlayerHudComponent(player, "breath", true)
                showPlayerHudComponent(player, "money", false)
                showPlayerHudComponent(player, "weapon", true)
                showPlayerHudComponent(player, "ammo", true)
                showPlayerHudComponent(player, "radar", true)
                showPlayerHudComponent(player, "area_name", false)
                showPlayerHudComponent(player, "vehicle_name", false)
            end
            showChat(player, true)
        end, 2000, 1)

    end
end
addEvent("auth", true)
addEventHandler("auth", getRootElement(), auth)

function register(username, password, email)
    if not username then
        exports.rpg_noti:createNotification(source, "error", "B??d podczas pr?by rejestracji, zg?o? to administratorowi na forum [ERR04]")
        return
    end
    if not password then
        exports.rpg_noti:createNotification(source, "error", "B??d podczas pr?by rejestracji, zg?o? to administratorowi na forum [ERR05]")
        return
    end
    local q1 = exports.rpg_mysql:mysql_query("SELECT username FROM rpg_accounts WHERE username=?", username)
    if not q1 then
        exports.rpg_noti:createNotification(source, "error", "B??d podczas pr?by rejestracji, zg?o? to administratorowi na forum [ERR09]")
        return
    elseif #q1 > 0 then
        exports.rpg_noti:createNotification(source, "error", "Podana nazwa u?ytkownika jest ju? w u?ytku")
        return
    end
    local ip = getPlayerIP(source)
    local serial = getPlayerSerial(source)
    local q3 = exports.rpg_mysql:mysql_query("INSERT INTO rpg_accounts SET username=?, password=?, serial=?, ip=?, position=?, lickag=0", username, md5(password), serial, ip, defpos)
    if q3 then
        triggerClientEvent(source, "switchLogin", source)
        exports.rpg_noti:createNotification(source, "info", "Twoje konto zosta?o utworzone, mo?esz si? teraz zalogowa?!")
    else
        exports.rpg_noti:createNotification(source, "error", "B??d podczas pr?by rejestracji, zg?o? to administratorowi na forum [ERR07]")
    end
end
addEvent("register", true)
addEventHandler("register", getRootElement(), register)

addEvent("wybral:wyjscie", true)
addEventHandler("wybral:wyjscie", getRootElement(), function()
kickPlayer(source, "Console", "Pomy?lnie wyszed?e? z servera")
end)

addEventHandler("onPlayerQuit", getRootElement(), function ()
    local uid = getElementData(source, "user:uid")
    if not uid then return end
    local money = getElementData(source, "user:money")
    local bankmoney = getElementData(source, "user:bankmoney")
    local gamescore = getElementData(source, "user:gamescore")
    local lickag = getElementData(source, "user:licensegornik")
    if not lickag then lickag = 0 end
    local skin = getElementData(source, "user:skin")
    local hajszfrakcji = getElementData(source, "user:factionmoney")
    local x,y,z = getElementPosition(source)
    local _,_,rz = getElementRotation(source)
    local int = getElementInterior(source)
    local dim = getElementDimension(source)
    local health = getElementHealth(source)
    local armor = getPedArmor(source)
    local pos = x..", "..y..", "..z..", "..rz..", "..int..", "..dim
    local job = getElementData(source, "user:job") or 0
    local jobmoney = getElementData(source, "user:jobmoney") or 0
    local onlinetime = getElementData(source, "user:onlinetime")
    local timer = getElementData(source, "user:timer")
    if timer then
    killTimer(timer)
    else return end
    local q = exports.rpg_mysql:mysql_query("UPDATE rpg_accounts SET money=?, bankmoney=?, gamescore=?, skin=?, position=?, health=?, armor=?, job=?, jobmoney=?, onlinetime=?, lickag=?, ftime=? WHERE uid=?", money, bankmoney, gamescore, skin, pos, health, armor, job, jobmoney, onlinetime, lickag, hajszfrakcji, uid)
    outputDebugString("[rpg_accounts] Zapisywanie gracza o UID "..uid.."! Problemy (Je?eli brak - Jest git!) :")
    if not q then
        outputDebugString("[rpg_accounts] Wyst?pi? problem z zapisywaniem gracza o UID "..uid)
    end
    outputDebugString("[rpg_accounts] Koniec funkcji zapisywania gracza o UID "..uid)
end)

addCommandHandler("zapiszfull", function(player)
if getElementData(player, "user:duty") == 3 then
    for i,source2 in pairs(getElementsByType("player")) do
    local uid = getElementData(source2, "user:uid")
    if not uid then return end
    local money = getElementData(source2, "user:money")
    local bankmoney = getElementData(source2, "user:bankmoney")
    local gamescore = getElementData(source2, "user:gamescore")
    local lickag = getElementData(source2, "user:licensegornik")
    if not lickag then lickag = 0 end
    local skin = getElementData(source2, "user:skin")
    local x,y,z = getElementPosition(source2)
    local hajszfrakcji = getElementData(source2, "user:factionmoney")
    local _,_,rz = getElementRotation(source2)
    local int = getElementInterior(source2)
    local dim = getElementDimension(source2)
    local health = getElementHealth(source2)
    local armor = getPedArmor(source2)
    local pos = x..", "..y..", "..z..", "..rz..", "..int..", "..dim
    local job = getElementData(source2, "user:job") or 0
    local jobmoney = getElementData(source2, "user:jobmoney") or 0
    local onlinetime = getElementData(source2, "user:onlinetime")
    local timer = getElementData(source2, "user:timer")
    killTimer(timer)
    local q = exports.rpg_mysql:mysql_query("UPDATE rpg_accounts SET money=?, bankmoney=?, gamescore=?, skin=?, position=?, health=?, armor=?, job=?, jobmoney=?, onlinetime=?, lickag=?, ftime=? WHERE uid=?", money, bankmoney, gamescore, skin, pos, health, armor, job, jobmoney, onlinetime, uid)
    outputDebugString("[rpg_accounts] Zapisywanie wszystkich graczy! Problemy (Je?eli brak - Jest git!) :")
    if not q then
        outputDebugString("[rpg_accounts] Wyst?pi? problem z zapisywaniem gracza o UID "..uid)
      end
    outputDebugString("[rpg_accounts] Koniec funkcji zapisywania graczy!")
    end
  end
end)


----------------
---- UTILS ----
----------------
function getKoncowka(time, k1, k2, k3)
    if time == 0 then
        return k1
    elseif time == 1 then
        return k2
    else
        return k3
    end
end

function getTimestamp(year, month, day, hour, minute, second)
    -- initiate variables
    local monthseconds = { 2678400, 2419200, 2678400, 2592000, 2678400, 2592000, 2678400, 2678400, 2592000, 2678400, 2592000, 2678400 }
    local timestamp = 0
    local datetime = getRealTime()
    year, month, day = year or datetime.year + 1900, month or datetime.month + 1, day or datetime.monthday
    hour, minute, second = hour or datetime.hour, minute or datetime.minute, second or datetime.second

    -- calculate timestamp
    for i=1970, year-1 do timestamp = timestamp + (isLeapYear(i) and 31622400 or 31536000) end
    for i=1, month-1 do timestamp = timestamp + ((isLeapYear(year) and i == 2) and 2505600 or monthseconds[i]) end
    timestamp = timestamp + 86400 * (day - 1) + 3600 * hour + 60 * minute + second

    timestamp = timestamp - 3600 --GMT+1 compensation
    if datetime.isdst then timestamp = timestamp - 3600 end

    return timestamp
end

function isLeapYear(year)
    if year then year = math.floor(year)
    else year = getRealTime().year + 1900 end
    return ((year % 4 == 0 and year % 100 ~= 0) or year % 400 == 0)
end

--[[
Autor: Asper <nezymr69@gmail.com>
Dla servera Own World!
Zakaz uzywania skryptu bez zgody autora!
]]

addEvent("org:dodajgracz", true)
addEventHandler("org:dodajgracz", root, function(nick, org)
local target = findPlayer(source, nick)
if not target then return end
if getElementData(target, "user:org") then
exports.rpg_noti:createNotification(source, "error", getPlayerName(target).." posiada organizacje.")
return
end
exports.rpg_mysql:mysql_query("INSERT INTO rpg_organizacje SET uid=?, organizacja=?, rank=?, nick=?", getElementData(target, "user:uid"), org, "1", getPlayerName(target))
exports.rpg_noti:createNotification(source, "info", getPlayerName(target).." zosta? dodany do organizacji.")
outputChatBox("Zosta?e? dodany do organizacji "..org, target)
setElementData(target, "user:org", org)
setElementData(target, "user:orgrank", 1)
end)

addEvent("org:kickgracz", true)
addEventHandler("org:kickgracz", root, function(nick, org)
local target = findPlayer(source, nick)
if not target then return end
if not getElementData(target, "user:org") then
exports.rpg_noti:createNotification(source, "error", getPlayerName(target).." nie posiada organizacji.")
return
end
if org ~= getElementData(target, "user:org") then
exports.rpg_noti:createNotification(source, "error", getPlayerName(target).." nie znajduje si? w tej organizacji.")
return
end
if getElementData(target, "user:orgrank") == 4 then
exports.rpg_noti:createNotification(source, "error", "Nie mo?esz wyrzuci? lidera!")
return
end
exports.rpg_mysql:mysql_query("DELETE FROM rpg_organizacje WHERE organizacja=? AND uid=?", getElementData(target, "user:org"), getElementData(target, "user:uid"))
exports.rpg_noti:createNotification(source, "info", getPlayerName(target).." zosta? wyrzucony z organizacji.")
outputChatBox("Zosta?e? wyrzucony z organizacji "..(getElementData(target, "user:org") or "..."), target)
setElementData(target, "user:org", false)
setElementData(target, "user:orgrank", false)
end)

addEvent("org:infogracz", true)
addEventHandler("org:infogracz", root, function(nick, org)
local target = findPlayer(source, nick)
if not target then return end
if org ~= getElementData(target, "user:org") then
exports.rpg_noti:createNotification(source, "error", getPlayerName(target).." nie znajduje si? w tej organizacji.")
return
end
local result = exports.rpg_mysql:mysql_query("SELECT * FROM rpg_organizacje WHERE uid=? AND organizacja=?", getElementData(target, "user:uid"), getElementData(target, "user:org"))
outputChatBox("Nick: "..result[1].nick..", DBID: "..result[1].uid..", Ranga: "..result[1].rank.."", source, 50, 200, 50)
end)

addEvent("org:editgracz", true)
addEventHandler("org:editgracz", root, function(nick, ranga, org, rangaja)
local target = findPlayer(plr, nick)
if not target then return end
if not getElementData(target, "user:org") == org then
exports.rpg_noti:createNotification(source, "error", getPlayerName(target).." nie znajduje si? w tej organizacji.")
return
end
if getElementData(target, "user:orgrank") == 4 then
exports.rpg_noti:createNotification(source, "error", "Nie mo?esz edytowa? lidera.")
return
end
if ranga == 4 then
exports.rpg_noti:createNotification(source, "error", "Maksymalna ranga to 3 = V-Lider.")
return
end
if ranga < 1 then
exports.rpg_noti:createNotification(source, "error", "Minimalna ranga to 1.")
return
end
if rangaja == 3 and ranga == 3 then
exports.rpg_noti:createNotification(source, "error", "Nie mo?esz nikomu da? V-Lidera.")
return
end
setElementData(target, "user:orgrank", ranga)
exports.rpg_noti:createNotification(source, "info", "Edytowano gracza "..getPlayerName(target).." na rang? "..ranga)
exports.rpg_mysql:mysql_query("UPDATE rpg_organizacje SET rank=? WHERE uid=?", ranga, getElementData(target, "user:uid"))
end)

addCommandHandler("opuscorganizacje", function(plr)
if not getElementData(plr, "user:org") then return end
if getElementData(plr, "user:orgrank") == 4 then return end
exports.rpg_mysql:mysql_query("DELETE FROM rpg_organizacje WHERE organizacja=? AND uid=?", getElementData(plr, "user:org"), getElementData(plr, "user:uid"))
exports.rpg_noti:createNotification(plr, "info", "Opu?ci?e? organizacje o nazwie "..getElementData(plr, "user:org"))
setElementData(plr, "user:org", false)
setElementData(plr, "user:orgrank", false)
end)

function orgGetPlayers(org)
    local q = exports.rpg_mysql:mysql_query("SELECT * FROM rpg_organizacje WHERE organizacja=? ORDER BY rank DESC", org)
    triggerClientEvent(source, "uzupelnijListe", source, q)
end
addEvent("orgGetPlayers", true)
addEventHandler("orgGetPlayers", getRootElement(), orgGetPlayers)

function findPlayer(plr, cel)
    local target = nil
    if (tonumber(cel) ~= nil) then
        target = getElementByID("p"..cel)
    else
        for _,thePlayer in ipairs(getElementsByType("player")) do
            if string.find(string.gsub(getPlayerName(thePlayer):lower(),"#%x%x%x%x%x%x", ""), cel:lower(), 1, true) then
                if (target) then
                    outputChatBox("Znaleziono wiecej niz jednego gracza o pasujacym nicku, podaj wiecej liter.", plr)
                    return nil
                end
                target=thePlayer
            end
        end
    end
    return target
end


Ostatnio zmieniony przez marcin778 2017-10-21, 14:48, w całości zmieniany 1 raz  
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-10-21, 13:01


Husky123







Wiek: 21
Na forum: 3460 dni
Posty: 45
Nick w MP: fabeN

Piwa: 750

Respekt: 60

Tak Wiem tylko potrzebuje szybko odpowiedzi.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-10-21, 13:15


kamilryb1

LUA






Wiek: 21
Na forum: 4407 dni
Posty: 146

Piwa: 321

Respekt: 7,3

Ostrzeżeń: 40%
Ogarnijcie sie z tymi tematami bo to jest dramat - Piszcie w odp. dziale...
Tak wgl to musisz mie? baze danych do tego i podpi??.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-10-21, 13:19


Husky123







Wiek: 21
Na forum: 3460 dni
Posty: 45
Nick w MP: fabeN

Piwa: 750

Respekt: 60

Podpio?em mam organizacje zrobion? w bazy danych robie reconnecta i nie mam organizacji a organizacja jest dodana w bazie danych.

Postaw piwo autorowi tego posta
 

 
Tagi: jak :: zrobić :: organizacje
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Jak zrobić organizacje na gm 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