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

Wysłany: 2016-02-07, 21:35


Bananek_PL







Wiek: 24
Na forum: 3996 dni
Posty: 6
Nick w MP: Bananek_PL

Piwa: 5

Respekt: 60

Chcia?bym pod??czy? AC pod duty.

Duty.

-- Ustawienia MySQL
addEventHandler("onResourceStart", resourceRoot, function()
    local baza = "NAZWA TWOJEJ BAZY"
    local host = "HOST"
    local user = "U?YTKOWNIK MYSQL"
    local pass = "HAS?O MYSQL"

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



-- Reszta zasobu
addCommandHandler("duty", function(plr,cmd)
    local q = dbQuery(db, "SELECT level FROM admins WHERE serial=?", getPlayerSerial(plr))
    local w = dbPoll(q, -1)
    if w and #w > 0 then
        if not getElementData(plr, "duty") then
            if w[1].level == 1 then -- Je?eli kolumna 'level' ma warto?? 1 to nadajemy rang? moderatora.
                setElementData(plr, "duty", 1)
                outputChatBox("Logujesz si? na duty moderatora.", plr)
            elseif w[1].level == 2 then -- Je?eli kolumna 'level' ma warto?? 2 to nadajemy rang? administratora.
                setElementData(plr, "duty", 2)
                outputChatBox("Loguejsz si? na duty administratora.", plr)
            elseif w[1].level == 3 then -- Je?eli kolumna 'level' ma warto?? 3 to nadajemy rang? administratora RCON.
                setElementData(plr, "duty", 3)
                outputChatBox("Logujesz si? na duty administratora RCON.", plr)
            end
        else
            removeElementData(plr, "duty")
            outputChatBox("Wylogowujesz si? z duty.", plr)
        end
    else
        outputChatBox("Nie jeste? w ekipie serwera.", plr)
    end
end)



--[[
    Informacje:
    Aby zas?b dzia?a? poprawnie, musisz doda? tabel? do MySQL z nazw? 'admins' (bez apostrof?w) z kolumnami: 
    serial - typ VARCHAR - d?ugo?? 255
    level - typ INT - d?ugo?? 1
    
    Aby doda? gracza do administracji, dodaj do MySQL serial gracza oraz level
    Level 1 - Moderator
    Level 2 - Administrator
    Level 3 - Administrator RCON
    
    Aby pobra? rang? gracza przy np. robieniu komend:
    
    aby sprawdzi?, czy gracz jest moderatorem wpisujemy:
        if getElementData(plr, "duty") == 1 then
            Reszta Twojego kodu.
        end
    aby sprawdzi?, czy gracz jest administratorem wpisujemy:
        if getElementData(plr, "duty") == 2 then
            Reszta Twojego kodu.
        end
    aby sprawdzi?, czy gracz jest administratorem RCON wpisujemy:
        if getElementData(plr, "duty") == 3 then
            Reszta Twojego kodu
        end
]]--


AC.

addCommandHandler("mc", function(plr, cmd, ...)
if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(plr)), aclGetGroup("Moderator")) or isObjectInACLGroup("user."..getAccountName(getPlayerAccount(plr)), aclGetGroup("Admin")) or isObjectInACLGroup("user."..getAccountName(getPlayerAccount(plr)), aclGetGroup("RCON")) then
if ... then
    local msg = table.concat({...}, " ")
    for k, v in ipairs(getElementsByType("player")) do
        if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(v)), aclGetGroup("Moderator")) or isObjectInACLGroup("user."..getAccountName(getPlayerAccount(plr)), aclGetGroup("Admin")) or isObjectInACLGroup("user."..getAccountName(getPlayerAccount(plr)), aclGetGroup("RCON")) then
            outputChatBox("#006600M> #006600"..getPlayerName(plr).."#FFFFFF: "..msg, v,255,255,255,true)
        end
    end
end
end
end)



addCommandHandler("ac", function(plr, cmd, ...)
if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(plr)), aclGetGroup("Admin")) or isObjectInACLGroup("user."..getAccountName(getPlayerAccount(plr)), aclGetGroup("RCON")) then
if ... then
    local msg = table.concat({...}, " ")
    for k, v in ipairs(getElementsByType("player")) do
        if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(v)), aclGetGroup("Admin")) or isObjectInACLGroup("user."..getAccountName(getPlayerAccount(plr)), aclGetGroup("RCON")) then
            outputChatBox("#FF0000A> #FF0000"..getPlayerName(plr).."#FFFFFF: "..msg, v, 255,255,255,true)
        end
    end
end
end
end)



addCommandHandler("rc", function(plr, cmd, ...)
if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(plr)), aclGetGroup("RCON")) then 
if ... then
    local msg = table.concat({...}, " ")
    for k, v in ipairs(getElementsByType("player")) do
        if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(v)), aclGetGroup("RCON")) then
            outputChatBox("#660000R> #660000"..getPlayerName(plr).."#FFFFFF: "..msg, v, 255,255,255,true)
        end
    end
end
end
end)


[ Dodano: 2016-02-07, 21:37 ]
Poda?em kod bez autor?w, bo za du?o by go by?o.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-02-13, 14:57












POST ZOSTAŁ UKRYTY Z POWODU ZŁAMANIA REG. LUB OCZEKUJE NA AKCEPTACJĘ


 

 
Tagi: podłączenie :: pod :: duty.
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Podłączenie AC pod duty. 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