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

Wysłany: 2018-07-11, 12:20


DAwinzo







Wiek: 21
Na forum: 3701 dni
Posty: 6
Nick w MP: okyft



Respekt: 50

Witam, poszukuj? pe?nego SQL z Calm Life potrzebuj? go poniewa? chcia?bym uruchomi? frakcje z |GM|Calm Life. Prosz?opomoc

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-07-11, 15:26


STOPseba

Emeryt na scenie MTA






Wiek: 25
Na forum: 3771 dni
Posty: 448
Nick w MP: STOPseba

Piwa: 5014

Respekt: 576,3
Respekt: 576,3

Mo?e tak bardziej si? opiszesz i udzielisz tak istotnej informacji jak wersja Calm Life.

Podpis



Kontakt
Discord: STOPseba#7603
STOPseba na fejsie
Messenger


Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-07-11, 16:02


_jvneczek







Wiek: 22
Na forum: 4325 dni
Posty: 1513
Nick w MP: _jvneczek

Piwa: 3949

Respekt: 337,5
Respekt: 337,5Respekt: 337,5Respekt: 337,5

DAwinzo, Przer?b na mysql, to proste akurat, bo podobny kod.

Podpis

Support Team: 04.10.2020 - 01.09.2020
Test Moderator: 03.05.2021 - 01.09.2021
Moderator: 01.09.2021 - 23.10.2021

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-07-11, 20:13


DAwinzo







Wiek: 21
Na forum: 3701 dni
Posty: 6
Nick w MP: okyft



Respekt: 50

"STOPseba" napisał/a:

Mo?e tak bardziej si? opiszesz i udzielisz tak istotnej informacji jak wersja Calm Life.


http://www.gtao.pl/<fo...16-vt118481.htm

[ Dodano: 2018-07-11, 18:19 ]

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


local frakcja_KGPLS createTeam("KGP",0,0,255)
local frakcja_KGSPLS createTeam("KGSP",255,0,0)
local frakcja_PRLS createTeam("PR",50,100,200)


local fractions = { -- g??wne markery frakcji
--["nazwa_frakcji"]={x,y,z,dim,int},
["KGSP"]={1939.42,-1972.66,13.55,0,0},
["KGP"]={297.49,186.41,1007.17,1000,3},
["PR"]={936.28,-1536.94,13.55,0,0},
}

for _,v in pairs(fractions) do
    local x,y,v[1],v[2],v[3]-1
    local d,v[4],v[5]
    local marker createMarker(x,y,z,"cylinder",1.2,50,100,200,120,root)
    setElementInterior(marker,i) 
    setElementDimension(marker,d)
    setElementData(marker,"fraction:marker",true)
    setElementData(marker,"fraction:marker:rgb",{r,g,b})
end

function isPlayerInTeam(playerteam)
    assert(isElement(player) and getElementType(player) == "player""Bad argument 1 @ isPlayerInTeam [player expected, got "..tostring(player).."]")
    assert((not team) or type(team) == "string" or (isElement(team) and getElementType(team) == "team"), "Bad argument 2 @ isPlayerInTeam [nil/string/team expected, got "..tostring(team).."]")
    return getPlayerTeam(player) == (type(team) == "string" and getTeamFromName(team) or (type(team) == "userdata" and team or (getPlayerTeam(player) or true)))
end

addEventHandler("onMarkerHit",resourceRoot,function(plr)
    if plr and isElement(plr) and getElementType(plr) == "player" then
        if tonumber(getElementData(plr,"player:sid")) then
            if getElementData(plr,"fraction"then
                if not isPedInVehicle(plrthen
                    if getElementData(source,"fraction:marker") == true then
                        triggerClientEvent(plr,"fraction:showButtons:startstop",plr,plr)
                    else
                        outputChatBox("Niezidentyfikowany b??d #1.",plr,255,0,0)
                    end
                else
                    outputChatBox("Wpierw musiz wysi??? z pojazdu, by m?c rozpocz?? s?u?b?!",plr,255,0,0)
                end
            else
                outputChatBox("Nie jeste? zatrudniony w ?adnej frakcji!",plr,255,0,0)
            end
        else
            outputChatBox("Aby rozpocz?c s?u?b?, musisz by? zalogowany!",plr,255,0,0)
        end
    end
end)

addEvent("fraction:start:duty",true)
addEventHandler("fraction:start:duty",root,function(plr)
    if plr and isElement(plr) and getElementType(plr) == "player" then
        if tonumber(getElementData(plr,"player:sid")) then
            if getElementData(plr,"fraction"then
                if not isPedInVehicle(plrthen
                    local frakcja false
                    
                    if getElementData(plr,"fraction") == "KGP" then
                        frakcja frakcja_KGPLS
                    elseif getElementData(plr,"fraction") == "KGSP" then
                        frakcja frakcja_KGSPLS
                    elseif getElementData(plr,"fraction") == "PR" then
                        frakcja frakcja_PRLS
                    end
                    
                    local q exports["pystories-db"]:GdbQuery("SELECT * FROM `pystories_users` WHERE `ID`=?",tonumber(getElementData(plr,"player:sid")))
                    local result dbPoll(q,-1)
                    if result then
                        for _,v in ipairs(result) do
                            if frakcja then
                                setPlayerTeam(plr,frakcja)
                                local dowodca v["fraction_rang_commander"]
                                local ranga v["fraction_rang"]
                                setElementData(plr,"fraction:rang",tostring(ranga))
                                setElementData(plr,"fraction:rang:commander",tonumber(dowodca))
                                setElementData(plr,"fraction:duty","S3")
                                outputChatBox("- - - - - - - - - - - - - - - - - ",plr,255,255,255)
                                outputChatBox("* Rozpocz??e?/a? duty w "..tostring(getElementData(plr,"fraction"))..".",plr,0,255,0)
                                outputChatBox("* Twoja ranga we frakcji: "..tostring(ranga)..".",plr,0,255,0)
                                outputChatBox(" - - - - - - - - - - - - - - - - -",plr,255,255,255)
                            end
                        end
                    end
                else
                    outputChatBox("Wpierw musisz wysi??? z pojazdu, by m?c rozpocz?? s?u?b?!",plr,255,0,0)
                end
            else
                outputChatBox("Nie jeste? zatrudniony/a w ?adnej frakcji!",plr,255,0,0)
            end
        else
            outputChatBox("Aby rozpocz?c s?u?b?, musisz by? zalogowany/a!",plr,255,0,0)
        end
    end
end)

addEvent("fraction:stop:duty",true)
addEventHandler("fraction:stop:duty",root,function(plr)
    if plr and isElement(plr) and getElementType(plr) == "player" then
        if tonumber(getElementData(plr,"player:Sid")) then
            if getElementData(plr,"fraction"then
                if getElementData(plr,"fraction:duty") == "S3" then
                    setElementModel(plr,getElementData(plr,"clothes"))
                    setPlayerTeam(plr,nil)
                    setElementData(plr,"fraction:duty",nil)
                    outputChatBox("- - - - - - - - - - - - - - - - - ",plr,255,255,255)
                    outputChatBox("* Zako?czy?e?/a? duty w "..tostring(getElementData(plr,"fraction"))..".",plr,0,255,0)
                    outputChatBox(" - - - - - - - - - - - - - - - - -",plr,255,255,255)
                else
                    outputChatBox("Wpierw musisz wej?? na duty, by m?c zako?czy? s?u?b?!",plr,255,0,0)
                end
            else
                outputChatBox("Nie jeste? zatrudniony/a w ?adnej frakcji!",plr,255,0,0)
            end
        else
            outputChatBox("Aby zako?czy? s?u?b?, musisz by? zalogowany/a!",plr,255,0,0)
        end
    end
end)


function naliczajCzas()
    if getElementData(source,"player:sid"then
        if getElementData(source,"fraction"then
            if getElementData(source,"fraction:duty") == "S3" then
                if getElementData(source,"fraction:rang"then
                    setTimer(function()
                        local q exports["pystories-db"]:GdbQuery("SELECT * FROM `pystories_users` WHERE `ID`=?",tonumber(getElementData(source,"player:sid")))
                        local result dbPoll(q,-1)
                        if result then
                            for _,v in ipairs(result) do
                                local minuty v["fraction_minutes"]
                                local update exports["pystories-db"]:GdbExec("UPDATE `pystories_users` SET `fraction_minutes`=? WHERE ID=?",tonumber(minuty)+1,tonumber(getElementData(source,"player:sid")))
                            end
                        end    
                    end,60000,0)
                end
            end
        end
    end
end

addCommandHandler("frakcja_ranga",function(plr,cmd,cel,ranga)
    if plr and getElementData(plr,"fraction"then
        if getElementData(plr,"fraction:rang") and getElementData(plr,"fraction:rang:commander") == 1 then
            if getElementData(plr,"fraction:duty") == "S3" then
                if cel then
                    if ranga then
                        local update exports["pystories-db"]:GdbExec("UPDATE `pystories_users` SET `fraction_rang`=? WHERE login=?",ranga,tostring(cel))
                        if update then
                            local odbiorca findPlayer(plr,cel)
                            if odbiorca then
                                setElementData(odbiorca,"fraction:rang",ranga)
                                outputChatBox("* Ranga zosta?a zmieniona na: "..ranga..".",plr,255,255,255)
                                outputChatBox("* Twoja ranga we frakcji zosta?a zaktualizowana!",odbiorca,255,255,255)
                            else
                                outputChatBox("Nie znaleziono celu! Ranga zosta?a zmieniona w bazie danych.",plr,255,0,0)
                            end
                        end
                    end
                end
            end
        end
    end
end)

addCommandHandler("frakcja_dodaj",function(plr,cmd,cel,ranga)
    if plr and getElementData(plr,"fraction"then
        if getElementData(plr,"fraction:rang") and getElementData(plr,"fraction:rang:commander") == or getElementData(plr,"fraction:rang:commander") == 2 then
            if getElementData(plr,"fraction:duty") == "S3" then
                if cel then
                    if ranga then
                        local odbiorca findPlayer(plr,cel)
                        if odbiorca then
                            local update exports["pystories-db"]:GdbExec("UPDATE `pystories_users` SET `fraction`=?, `fraction_rang`=?, `fraction_rang_commander`=? WHERE login=?",getElementData(plr,"fraction"),ranga,3,getElementData(odbiorca,"login"))
                            if update then
                                outputChatBox("* Dodano "..getPlayerName(odbiorca).." do frakcji! Jego ranga: "..ranga..".",plr,255,255,255)
                                outputChatBox("* Twoja przynale?no?? we frakcji zosta?a zaktualizowana! Zosta?e? dodany do "..getElementData(plr,"fraction")..". Twoja ranga: "..ranga..".",odbiorca,255,255,255)
                                setElementData(odbiorca,"fraction",getElementData(plr,"fraction"))
                                setElementData(odbiorca,"fraction:rang",tostring(ranga))
                                setElementData(odbiorca,"fraction:rang:commander",3)
                            end
                        else
                            outputChatBox("Nie znaleziono celu!",plr,255,0,0)
                        end
                    end
                end
            end
        end
    end
end)

addCommandHandler("frakcja_usun",function(plr,cmd,cel)
    if plr and getElementData(plr,"fraction"then
        if getElementData(plr,"fraction:rang") and getElementData(plr,"fraction:rang:commander") == or getElementData(plr,"fraction:rang:commander") == 2 then
            if getElementData(plr,"fraction:duty") == "S3" then
                if cel then
                    local odbiorca findPlayer(plr,cel)
                    if odbiorca then
                        local update exports["pystories-db"]:GdbExec("UPDATE `pystories_users` SET `fraction`=?, `fraction_rang`=?, `fraction_rang_commander`=? WHERE login=?","","",0,getElementData(odbiorca,"login"))
                        if update then
                            outputChatBox("* Wyrzucono "..getPlayerName(odbiorca).." z Twojej frakcji!",plr,255,255,255)
                            outputChatBox("* Twoja przynale?no?? we frakcji zosta?a zaktualizowana! Zosta?e? wyrzucony z "..getElementData(plr,"fraction")..".",odbiorca,255,0,0)
                            setElementData(odbiorca,"fraction",false)
                            setElementData(odbiorca,"fraction:rang",false)
                            setElementData(odbiorca,"fraction:rang:commander",false)
                            setPlayerTeam(odbiorca,nil)
                            setElementData(odbiorca,"fraction:duty",false)
                        end
                    else
                        outputChatBox("Nie znaleziono celu!",plr,255,0,0)
                    end
                end
            end
        end
    end
end)

addCommandHandler("frakcja_typ",function(plr,cmd,cel,typ)
    if plr and getElementData(plr,"fraction"then
        if getElementData(plr,"fraction:rang") and getElementData(plr,"fraction:rang:commander") == or getElementData(plr,"fraction:rang:commander") == 2 then
            if getElementData(plr,"fraction:duty") == "S3" then
                if cel then
                    local odbiorca findPlayer(plr,cel)
                    if odbiorca then
                        if typ and tonumber(typ) and tonumber(typ) < 4 then
                            local update exports["pystories-db"]:GdbExec("UPDATE `pystories_users` SET `fraction_rang_commander`=? WHERE login=?",typ,getElementData(odbiorca,"login"))
                            if update then
                                outputChatBox("* Zmieniono typ rangi dla "..getPlayerName(odbiorca).." ; nowy typ rangi: "..typ..".",plr,255,255,255)
                                outputChatBox("* Tw?j typ rangi we frakcji zosta? zaktualizowany! Aktualny typ rangi: "..typ.."",odbiorca,255,0,0)
                                setElementData(odbiorca,"fraction:rang:commander",false)
                            end
                        else
                            outputChatBox("Typ: 1-dow?dca frakcji ; 2-zast?pca frakcji ; 3-inna. ",plr,255,0,0)
                        end
                    else
                        outputChatBox("Nie znaleziono celu!",plr,255,0,0)
                    end
                end
            end
        end
    end
end)

addCommandHandler("frakcja_rangi",function(plr,cmd)
    if plr and getElementData(plr,"fraction"then
        if getElementData(plr,"fraction:rang") and getElementData(plr,"fraction:rang:commander") == or getElementData(plr,"fraction:rang:commander") == 2 then
            if getElementData(plr,"fraction:duty") == "S3" then
                --CL_fractions
                local q exports["pystories-db"]:GdbQuery("SELECT * FROM `pystories_users` WHERE `fraction`=?",getElementData(plr,"fraction"))
                local result dbPoll(q,-1)
                if result then
                    outputChatBox("Rangi we frakcji "..getElementData(plr,"fraction")..":",plr,255,255,255)
                    for _,v in ipairs(result) do
                        outputChatBox("- Ranga: "..v["Rang"].." / Zarobek: "..v["Payment"]..".",plr,255,255,0)
                    end
                end
            end
        end
    end
end)

addCommandHandler("frakcja_komendy",function(plr,cmd)
    if plr and getElementData(plr,"fraction"then
        if getElementData(plr,"fraction:rang") and getElementData(plr,"fraction:rang:commander") == or getElementData(plr,"fraction:rang:commander") == 2 then
            if getElementData(plr,"fraction:duty") == "S3" then
                outputChatBox(" - - - - - - - - - - - - - - - ",plr)
                outputChatBox("/frakcja_typ cel typ   - Ustawienie typu rangi (1-dow?dca ; 2-zast?pca ; 3-inna).",plr)
                outputChatBox("/frakcja_usun cel    - Usuwanie gracza z frakcji.",plr)
                outputChatBox("/frakcja_dodaj cel ranga    - Dodawanie do frakcji gracza.",plr)
                outputChatBox("/frakcja_ranga cel ranga    - Zmiana rangi we frakcji danego gracza.",plr)
                outputChatBox("/frakcja_rangi    - Rangi we frakcji.",plr)
                outputChatBox("- - - - - - - - - - - - - - -",plr)
            end
        end
    end
end)




setTimer(function()
    for _,v in pairs(getElementsByType("player")) do
        if isPlayerInTeam(v) and getElementData(v,"fraction") and getElementData(v,"fraction:duty") == "S3" then
            exports["pystories-db"]:GdbExec("UPDATE pystories_users SET fraction_minutes=fraction_minutes+1 WHERE ID=?",tonumber(getElementData(v,"ID")))
        end
    end
end,60000,0) 

[size=9][ [i][b]Dodano[/b]: 2018-07-1118:20[/i] ][/size]
function findPlayer(plr,cel)
    local target=nil
    if (tonumber(cel) ~= nilthen
        target=getElementByID("p"..cel)
    else -- podano fragment nicku
        for _,thePlayer in ipairs(getElementsByType("player")) do
            if string.find(string.gsub(getPlayerName(thePlayer):lower(),"#%x%x%x%x%x%x"""), cel:lower(), 1truethen
                if (targetthen
                    outputChatBox("Znaleziono wiecej niz jednego gracza o pasujacym nicku, podaj wiecej liter."plr)
                    return nil
                end
                target=thePlayer
            end
        end
    end
    return target
end


local frakcja_KGPLS createTeam("KGP",0,0,255)
local frakcja_KGSPLS createTeam("KGSP",255,0,0)
local frakcja_PRLS createTeam("PR",50,100,200)


local fractions = { -- g??wne markery frakcji
--["nazwa_frakcji"]={x,y,z,dim,int},
["KGSP"]={1939.42,-1972.66,13.55,0,0},
["KGP"]={297.49,186.41,1007.17,1000,3},
["PR"]={936.28,-1536.94,13.55,0,0},
}

for _,v in pairs(fractions) do
    local x,y,v[1],v[2],v[3]-1
    local d,v[4],v[5]
    local marker createMarker(x,y,z,"cylinder",1.2,50,100,200,120,root)
    setElementInterior(marker,i) 
    setElementDimension(marker,d)
    setElementData(marker,"fraction:marker",true)
    setElementData(marker,"fraction:marker:rgb",{r,g,b})
end

function isPlayerInTeam(playerteam)
    assert(isElement(player) and getElementType(player) == "player""Bad argument 1 @ isPlayerInTeam [player expected, got "..tostring(player).."]")
    assert((not team) or type(team) == "string" or (isElement(team) and getElementType(team) == "team"), "Bad argument 2 @ isPlayerInTeam [nil/string/team expected, got "..tostring(team).."]")
    return getPlayerTeam(player) == (type(team) == "string" and getTeamFromName(team) or (type(team) == "userdata" and team or (getPlayerTeam(player) or true)))
end

addEventHandler("onMarkerHit",resourceRoot,function(plr)
    if plr and isElement(plr) and getElementType(plr) == "player" then
        if tonumber(getElementData(plr,"player:sid")) then
            if getElementData(plr,"fraction"then
                if not isPedInVehicle(plrthen
                    if getElementData(source,"fraction:marker") == true then
                        triggerClientEvent(plr,"fraction:showButtons:startstop",plr,plr)
                    else
                        outputChatBox("Niezidentyfikowany b??d #1.",plr,255,0,0)
                    end
                else
                    outputChatBox("Wpierw musiz wysi??? z pojazdu, by m?c rozpocz?? s?u?b?!",plr,255,0,0)
                end
            else
                outputChatBox("Nie jeste? zatrudniony w ?adnej frakcji!",plr,255,0,0)
            end
        else
            outputChatBox("Aby rozpocz?c s?u?b?, musisz by? zalogowany!",plr,255,0,0)
        end
    end
end)

addEvent("fraction:start:duty",true)
addEventHandler("fraction:start:duty",root,function(plr)
    if plr and isElement(plr) and getElementType(plr) == "player" then
        if tonumber(getElementData(plr,"player:sid")) then
            if getElementData(plr,"fraction"then
                if not isPedInVehicle(plrthen
                    local frakcja false
                    
                    if getElementData(plr,"fraction") == "KGP" then
                        frakcja frakcja_KGPLS
                    elseif getElementData(plr,"fraction") == "KGSP" then
                        frakcja frakcja_KGSPLS
                    elseif getElementData(plr,"fraction") == "PR" then
                        frakcja frakcja_PRLS
                    end
                    
                    local q exports["pystories-db"]:GdbQuery("SELECT * FROM `pystories_users` WHERE `ID`=?",tonumber(getElementData(plr,"player:sid")))
                    local result dbPoll(q,-1)
                    if result then
                        for _,v in ipairs(result) do
                            if frakcja then
                                setPlayerTeam(plr,frakcja)
                                local dowodca v["fraction_rang_commander"]
                                local ranga v["fraction_rang"]
                                setElementData(plr,"fraction:rang",tostring(ranga))
                                setElementData(plr,"fraction:rang:commander",tonumber(dowodca))
                                setElementData(plr,"fraction:duty","S3")
                                outputChatBox("- - - - - - - - - - - - - - - - - ",plr,255,255,255)
                                outputChatBox("* Rozpocz??e?/a? duty w "..tostring(getElementData(plr,"fraction"))..".",plr,0,255,0)
                                outputChatBox("* Twoja ranga we frakcji: "..tostring(ranga)..".",plr,0,255,0)
                                outputChatBox(" - - - - - - - - - - - - - - - - -",plr,255,255,255)
                            end
                        end
                    end
                else
                    outputChatBox("Wpierw musisz wysi??? z pojazdu, by m?c rozpocz?? s?u?b?!",plr,255,0,0)
                end
            else
                outputChatBox("Nie jeste? zatrudniony/a w ?adnej frakcji!",plr,255,0,0)
            end
        else
            outputChatBox("Aby rozpocz?c s?u?b?, musisz by? zalogowany/a!",plr,255,0,0)
        end
    end
end)

addEvent("fraction:stop:duty",true)
addEventHandler("fraction:stop:duty",root,function(plr)
    if plr and isElement(plr) and getElementType(plr) == "player" then
        if tonumber(getElementData(plr,"player:Sid")) then
            if getElementData(plr,"fraction"then
                if getElementData(plr,"fraction:duty") == "S3" then
                    setElementModel(plr,getElementData(plr,"clothes"))
                    setPlayerTeam(plr,nil)
                    setElementData(plr,"fraction:duty",nil)
                    outputChatBox("- - - - - - - - - - - - - - - - - ",plr,255,255,255)
                    outputChatBox("* Zako?czy?e?/a? duty w "..tostring(getElementData(plr,"fraction"))..".",plr,0,255,0)
                    outputChatBox(" - - - - - - - - - - - - - - - - -",plr,255,255,255)
                else
                    outputChatBox("Wpierw musisz wej?? na duty, by m?c zako?czy? s?u?b?!",plr,255,0,0)
                end
            else
                outputChatBox("Nie jeste? zatrudniony/a w ?adnej frakcji!",plr,255,0,0)
            end
        else
            outputChatBox("Aby zako?czy? s?u?b?, musisz by? zalogowany/a!",plr,255,0,0)
        end
    end
end)


function naliczajCzas()
    if getElementData(source,"player:sid"then
        if getElementData(source,"fraction"then
            if getElementData(source,"fraction:duty") == "S3" then
                if getElementData(source,"fraction:rang"then
                    setTimer(function()
                        local q exports["pystories-db"]:GdbQuery("SELECT * FROM `pystories_users` WHERE `ID`=?",tonumber(getElementData(source,"player:sid")))
                        local result dbPoll(q,-1)
                        if result then
                            for _,v in ipairs(result) do
                                local minuty v["fraction_minutes"]
                                local update exports["pystories-db"]:GdbExec("UPDATE `pystories_users` SET `fraction_minutes`=? WHERE ID=?",tonumber(minuty)+1,tonumber(getElementData(source,"player:sid")))
                            end
                        end    
                    end,60000,0)
                end
            end
        end
    end
end

addCommandHandler("frakcja_ranga",function(plr,cmd,cel,ranga)
    if plr and getElementData(plr,"fraction"then
        if getElementData(plr,"fraction:rang") and getElementData(plr,"fraction:rang:commander") == 1 then
            if getElementData(plr,"fraction:duty") == "S3" then
                if cel then
                    if ranga then
                        local update exports["pystories-db"]:GdbExec("UPDATE `pystories_users` SET `fraction_rang`=? WHERE login=?",ranga,tostring(cel))
                        if update then
                            local odbiorca findPlayer(plr,cel)
                            if odbiorca then
                                setElementData(odbiorca,"fraction:rang",ranga)
                                outputChatBox("* Ranga zosta?a zmieniona na: "..ranga..".",plr,255,255,255)
                                outputChatBox("* Twoja ranga we frakcji zosta?a zaktualizowana!",odbiorca,255,255,255)
                            else
                                outputChatBox("Nie znaleziono celu! Ranga zosta?a zmieniona w bazie danych.",plr,255,0,0)
                            end
                        end
                    end
                end
            end
        end
    end
end)

addCommandHandler("frakcja_dodaj",function(plr,cmd,cel,ranga)
    if plr and getElementData(plr,"fraction"then
        if getElementData(plr,"fraction:rang") and getElementData(plr,"fraction:rang:commander") == or getElementData(plr,"fraction:rang:commander") == 2 then
            if getElementData(plr,"fraction:duty") == "S3" then
                if cel then
                    if ranga then
                        local odbiorca findPlayer(plr,cel)
                        if odbiorca then
                            local update exports["pystories-db"]:GdbExec("UPDATE `pystories_users` SET `fraction`=?, `fraction_rang`=?, `fraction_rang_commander`=? WHERE login=?",getElementData(plr,"fraction"),ranga,3,getElementData(odbiorca,"login"))
                            if update then
                                outputChatBox("* Dodano "..getPlayerName(odbiorca).." do frakcji! Jego ranga: "..ranga..".",plr,255,255,255)
                                outputChatBox("* Twoja przynale?no?? we frakcji zosta?a zaktualizowana! Zosta?e? dodany do "..getElementData(plr,"fraction")..". Twoja ranga: "..ranga..".",odbiorca,255,255,255)
                                setElementData(odbiorca,"fraction",getElementData(plr,"fraction"))
                                setElementData(odbiorca,"fraction:rang",tostring(ranga))
                                setElementData(odbiorca,"fraction:rang:commander",3)
                            end
                        else
                            outputChatBox("Nie znaleziono celu!",plr,255,0,0)
                        end
                    end
                end
            end
        end
    end
end)

addCommandHandler("frakcja_usun",function(plr,cmd,cel)
    if plr and getElementData(plr,"fraction"then
        if getElementData(plr,"fraction:rang") and getElementData(plr,"fraction:rang:commander") == or getElementData(plr,"fraction:rang:commander") == 2 then
            if getElementData(plr,"fraction:duty") == "S3" then
                if cel then
                    local odbiorca findPlayer(plr,cel)
                    if odbiorca then
                        local update exports["pystories-db"]:GdbExec("UPDATE `pystories_users` SET `fraction`=?, `fraction_rang`=?, `fraction_rang_commander`=? WHERE login=?","","",0,getElementData(odbiorca,"login"))
                        if update then
                            outputChatBox("* Wyrzucono "..getPlayerName(odbiorca).." z Twojej frakcji!",plr,255,255,255)
                            outputChatBox("* Twoja przynale?no?? we frakcji zosta?a zaktualizowana! Zosta?e? wyrzucony z "..getElementData(plr,"fraction")..".",odbiorca,255,0,0)
                            setElementData(odbiorca,"fraction",false)
                            setElementData(odbiorca,"fraction:rang",false)
                            setElementData(odbiorca,"fraction:rang:commander",false)
                            setPlayerTeam(odbiorca,nil)
                            setElementData(odbiorca,"fraction:duty",false)
                        end
                    else
                        outputChatBox("Nie znaleziono celu!",plr,255,0,0)
                    end
                end
            end
        end
    end
end)

addCommandHandler("frakcja_typ",function(plr,cmd,cel,typ)
    if plr and getElementData(plr,"fraction"then
        if getElementData(plr,"fraction:rang") and getElementData(plr,"fraction:rang:commander") == or getElementData(plr,"fraction:rang:commander") == 2 then
            if getElementData(plr,"fraction:duty") == "S3" then
                if cel then
                    local odbiorca findPlayer(plr,cel)
                    if odbiorca then
                        if typ and tonumber(typ) and tonumber(typ) < 4 then
                            local update exports["pystories-db"]:GdbExec("UPDATE `pystories_users` SET `fraction_rang_commander`=? WHERE login=?",typ,getElementData(odbiorca,"login"))
                            if update then
                                outputChatBox("* Zmieniono typ rangi dla "..getPlayerName(odbiorca).." ; nowy typ rangi: "..typ..".",plr,255,255,255)
                                outputChatBox("* Tw?j typ rangi we frakcji zosta? zaktualizowany! Aktualny typ rangi: "..typ.."",odbiorca,255,0,0)
                                setElementData(odbiorca,"fraction:rang:commander",false)
                            end
                        else
                            outputChatBox("Typ: 1-dow?dca frakcji ; 2-zast?pca frakcji ; 3-inna. ",plr,255,0,0)
                        end
                    else
                        outputChatBox("Nie znaleziono celu!",plr,255,0,0)
                    end
                end
            end
        end
    end
end)

addCommandHandler("frakcja_rangi",function(plr,cmd)
    if plr and getElementData(plr,"fraction"then
        if getElementData(plr,"fraction:rang") and getElementData(plr,"fraction:rang:commander") == or getElementData(plr,"fraction:rang:commander") == 2 then
            if getElementData(plr,"fraction:duty") == "S3" then
                --CL_fractions
                local q exports["pystories-db"]:GdbQuery("SELECT * FROM `pystories_users` WHERE `fraction`=?",getElementData(plr,"fraction"))
                local result dbPoll(q,-1)
                if result then
                    outputChatBox("Rangi we frakcji "..getElementData(plr,"fraction")..":",plr,255,255,255)
                    for _,v in ipairs(result) do
                        outputChatBox("- Ranga: "..v["Rang"].." / Zarobek: "..v["Payment"]..".",plr,255,255,0)
                    end
                end
            end
        end
    end
end)

addCommandHandler("frakcja_komendy",function(plr,cmd)
    if plr and getElementData(plr,"fraction"then
        if getElementData(plr,"fraction:rang") and getElementData(plr,"fraction:rang:commander") == or getElementData(plr,"fraction:rang:commander") == 2 then
            if getElementData(plr,"fraction:duty") == "S3" then
                outputChatBox(" - - - - - - - - - - - - - - - ",plr)
                outputChatBox("/frakcja_typ cel typ   - Ustawienie typu rangi (1-dow?dca ; 2-zast?pca ; 3-inna).",plr)
                outputChatBox("/frakcja_usun cel    - Usuwanie gracza z frakcji.",plr)
                outputChatBox("/frakcja_dodaj cel ranga    - Dodawanie do frakcji gracza.",plr)
                outputChatBox("/frakcja_ranga cel ranga    - Zmiana rangi we frakcji danego gracza.",plr)
                outputChatBox("/frakcja_rangi    - Rangi we frakcji.",plr)
                outputChatBox("- - - - - - - - - - - - - - -",plr)
            end
        end
    end
end)




setTimer(function()
    for _,v in pairs(getElementsByType("player")) do
        if isPlayerInTeam(v) and getElementData(v,"fraction") and getElementData(v,"fraction:duty") == "S3" then
            exports["pystories-db"]:GdbExec("UPDATE pystories_users SET fraction_minutes=fraction_minutes+1 WHERE ID=?",tonumber(getElementData(v,"ID")))
        end
    end
end,60000,0

[ Dodano: 2018-07-11, 18:20 ]
Chcia?bym to podpi?? pod baze mysql z pysa

Komentarz Barcioo dodany 2018-07-17, 09:36Dodałem tag lua [./lua][./lua]
Ostatnio zmieniony przez Barcioo 2018-07-17, 09:35, w całości zmieniany 1 raz  
Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-07-16, 23:47


Mezo.

Mod-Team






Wiek: 24
Na forum: 3211 dni
Posty: 548
Nick w MP: Mezo

Piwa: 6070

Respekt: 517
Respekt: 517

Podpis
- Na forum pomagam na miarę swoich możliwości, oraz bezpłatnie.
- Jeżeli potrzebujesz pomocy, pisz do mnie w prywatnej wiadomości, pomoc uzyskasz szybciej.
Współpraca - [email protected]


Użytkownik - 19.08.2017
GTAO MEMBER - 29.03.2019
Support-Team - 03.02.2019 - 07.05.2019
Moderator - 07.05.2019 - 02.08.2020
Mod-Team - 02.08.2020 - 25.03.2022

Postaw piwo autorowi tego posta
 

 
Tagi: sql :: calm :: life
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