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

Wysłany: 2019-02-12, 22:47


Yami

Mapper / Uczeń LUA






Wiek: 25
Na forum: 3059 dni
Posty: 379

Piwa: 97

Respekt: 235
Respekt: 235Respekt: 235

Siemka
Mam GM XaWorld i nie dzia?a mi duty admina, wpisuje /duty i nie si? nie dzieje
W bazie danych nale?y uzupe?ni?
ID | Gracz | Serial | ranga | tranga | hex |

Ja mam uzupe?nione tak:
1 | ReMiK1337 | M?j Serial | Admin | 4 | Tutaj nic nie mam |

Co jest zle zrobione?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-02-12, 22:53


Query

SyndicateMTA






Wiek: 24
Na forum: 3071 dni
Posty: 319
Nick w MP: Query

Piwa: 5257

Respekt: 141
Respekt: 141

ReMiK1337, podczas wpisywania /duty wywala b??d w debugscript 3 ?
Poprawnie uzupe?ni?e? tabel??
Je?li b??du nie ma to poka? kod odpowiedzialny za administracje.

Podpis
Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-02-12, 23:08


Yami

Mapper / Uczeń LUA






Wiek: 25
Na forum: 3059 dni
Posty: 379

Piwa: 97

Respekt: 235
Respekt: 235Respekt: 235

W db3 czysto
W?a?nie nie wiem czy tabelka jest dobrze uzupe?niona

kod:

function jp(gracz)
    if getElementData(gracz"duty"then
        if doesPlayerHaveJetPack(graczthen
            removePlayerJetPack(gracz)
        else
            givePlayerJetPack(gracz)
        end
    end
end

local jednostki = {
    ["m"] = true,
    ["h"] = true,
    ["d"] = true,    
}

function getTimestamp(yearmonthdayhourminutesecond)
    -- initiate variables
    local monthseconds = { 267840024192002678400259200026784002592000267840026784002592000267840025920002678400 }
    local timestamp 0
    local datetime getRealTime()
    yearmonthday year or datetime.year 1900month or datetime.month 1day or datetime.monthday
    hourminutesecond hour or datetime.hourminute or datetime.minutesecond or datetime.second

    -- calculate timestamp
    for i=1970year-do timestamp timestamp + (isLeapYear(i) and 31622400 or 31536000end
    for i=1month-do timestamp timestamp + ((isLeapYear(year) and == 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 == and year 100 ~= 0) or year 400 == 0)
end

function zbanuj(plrcmdtargett1t2, ...)
    if not getElementData(plr"duty"then return end
    if not target or not t1 or not t2 or not ... then
        return
    end
    local player findPlayer(plrtarget)
    if not player then return end
        local text table.concat({...}, ", ")
        local ts_start getTimestamp()
        if t1 == "m" then
            local t2 tonumber(t2)
            local ts_final ts_start t2*60
            local time getRealTime(ts_final)
            local txt getPlayerName(player).." zosta? zbanowany przez "..getPlayerName(plr).." na czas "..t2.." minut z powodu "..text
            triggerClientEvent(getRootElement(), "notiAdmin"getRootElement(), txt)
            outputConsole(txt)
            local user_id getElementData(player"dbid")
            local user_serial getPlayerSerial(player)
            local final_date = (time.year+1900).."-"..(time.month+1).."-"..(time.monthday).." "..(time.hour)..":"..(time.minute)..":"..(time.second)
            exports.mysql:wykonaj("INSERT INTO bany SET nick=?, serial=?, ip=?, data=?, admin=?"getPlayerName(player), getPlayerSerial(player), getPlayerIP(player), final_dategetPlayerName(plr))
            kickPlayer(player"Po??cz si? ponownie")
        elseif t1 == "h" then
            local t2 tonumber(t2)
            local ts_final ts_start t2*3600
            local time getRealTime(ts_final)
            local txt getPlayerName(player).." zosta? zbanowany przez "..getPlayerName(plr).." na czas "..t2.." godzin z powodu "..text
            triggerClientEvent(getRootElement(), "notiAdmin"getRootElement(), txt)
            outputConsole(txt)
            local user_id getElementData(player"dbid")
            local user_serial getPlayerSerial(player)
            local final_date = (time.year+1900).."-"..(time.month+1).."-"..(time.monthday).." "..(time.hour)..":"..(time.minute)..":"..(time.second)
            exports.mysql:wykonaj("INSERT INTO bany SET nick=?, serial=?, ip=?, data=?, admin=?"getPlayerName(player), getPlayerSerial(player), getPlayerIP(player), final_dategetPlayerName(plr))
            kickPlayer(player"Po??cz si? ponownie")
        elseif t1 == "d" then
            local t2 tonumber(t2)
            local ts_final ts_start t2*86400
            local time getRealTime(ts_final)
            local txt getPlayerName(player).." zosta? zbanowany przez "..getPlayerName(plr).." na czas "..t2.." dni z powodu "..text
            triggerClientEvent(getRootElement(), "notiAdmin"getRootElement(), txt)
            outputConsole(txt)
            local user_id getElementData(player"dbid")
            local user_serial getPlayerSerial(player)
            local final_date = (time.year+1900).."-"..(time.month+1).."-"..(time.monthday).." "..(time.hour)..":"..(time.minute)..":"..(time.second)
            exports.mysql:wykonaj("INSERT INTO bany SET nick=?, serial=?, ip=?, data=?, admin=?"getPlayerName(player), getPlayerSerial(player), getPlayerIP(player), final_dategetPlayerName(plr))
            kickPlayer(player"Po??cz si? ponownie")
    end
end

function kicknij(gracz_graczhere, ...)
    if graczhere and ... and getElementData(gracz"duty"then
        graczhere findPlayer(graczgraczhere)
        if not graczhere then
            exports["nm-noti"]:noti("Nie znaleziono podanego gracza."gracz)
            return
        end
        local tresc table.concat({...}, " ")
        local txt getPlayerName(graczhere).." zosta? wykopany przez "..getPlayerName(gracz).." z powodu "..tresc
        kickPlayer(graczheregracztresc)
        outputConsole(txt)
        triggerClientEvent(root"notiAdmin"roottxt)
    end
end

function warnij(gracz_graczhere, ...)
    if graczhere and ... and getElementData(gracz"duty"then
        graczhere findPlayer(graczgraczhere)
        if not graczhere then
            exports["nm-noti"]:noti("Nie znaleziono podanego gracza."gracz)
            return
        end
        local tresc table.concat({...}, " ")
        local txt getPlayerName(graczhere).." zosta? ostrze?ony przez "..getPlayerName(gracz).." z powodu "..tresc
        outputChatBox(" "graczhere25500)
        outputChatBox("Otrzyma?e? ostrze?enie od "..getPlayerName(gracz), graczhere25500)
        outputChatBox(" "graczhere25500)
        outputChatBox("Pow?d: "..trescgraczhere255255255)
        outputChatBox(" "graczhere25500)
        outputChatBox("Nie stosowanie si? do ostrze?enia, mo?e skutkowa? kickiem lub banem."graczhere0131255)
        outputConsole(txt)
        triggerClientEvent(root"notiAdmin"roottxt)
        triggerClientEvent(graczhere"warnPlayer"root, {
            ["powod"] = tresc,
            ["kto"] = getPlayerName(gracz),
        })
    end
end

function prawko(plrcmdtargett1t2, ...)
    if not getElementData(plr"duty"then return end
    if not target or not t1 or not t2 or not ... then
        return
    end
    local player findPlayer(plrtarget)
    if not player then return end
        local text table.concat({...}, ", ")
        local ts_start getTimestamp()
        if t1 == "m" then
            local t2 tonumber(t2)
            local ts_final ts_start t2*60-3600
            local time getRealTime(ts_final)
            local txt getPlayerName(player).." otrzyma? zakaz prowadzenia pojazd?w kat. A,B,C od "..getPlayerName(plr).." na czas "..t2.." minut z powodu "..text
            triggerClientEvent(getRootElement(), "notiAdmin"getRootElement(), txt)
            outputConsole(txt)
            local user_id getElementData(player"dbid")
            local user_serial getPlayerSerial(player)
            removePedFromVehicle(player)
            local final_date = (time.year+1900).."-"..(time.month+1).."-"..(time.monthday).." "..(time.hour)..":"..(time.minute)..":"..(time.second)
            exports.mysql:wykonaj("INSERT INTO prawka SET nick=?, serial=?, ip=?, data=?, admin=?"getPlayerName(player), getPlayerSerial(player), getPlayerIP(player), final_dategetPlayerName(plr))
        elseif t1 == "h" then
            local t2 tonumber(t2)
            local ts_final ts_start t2*3600-3600
            local time getRealTime(ts_final)
            removePedFromVehicle(player)
            local txt getPlayerName(player).." otrzyma? zakaz prowadzenia pojazd?w kat. A,B,C od "..getPlayerName(plr).." na czas "..t2.." godzin z powodu "..text
            triggerClientEvent(getRootElement(), "notiAdmin"getRootElement(), txt)
            outputConsole(txt)
            local user_id getElementData(player"dbid")
            local user_serial getPlayerSerial(player)
            local final_date = (time.year+1900).."-"..(time.month+1).."-"..(time.monthday).." "..(time.hour)..":"..(time.minute)..":"..(time.second)
            exports.mysql:wykonaj("INSERT INTO prawka SET nick=?, serial=?, ip=?, data=?, admin=?"getPlayerName(player), getPlayerSerial(player), getPlayerIP(player), final_dategetPlayerName(plr))
        elseif t1 == "d" then
            local t2 tonumber(t2)
            removePedFromVehicle(player)
            local ts_final ts_start t2*86400-3600
            local time getRealTime(ts_final)
            local txt getPlayerName(player).." otrzyma? zakaz prowadzenia pojazd?w kat. A,B,C od "..getPlayerName(plr).." na czas "..t2.." dni z powodu "..text
            triggerClientEvent(getRootElement(), "notiAdmin"getRootElement(), txt)
            outputConsole(txt)
            local user_id getElementData(player"dbid")
            local user_serial getPlayerSerial(player)
            local final_date = (time.year+1900).."-"..(time.month+1).."-"..(time.monthday).." "..(time.hour)..":"..(time.minute)..":"..(time.second)
            exports.mysql:wykonaj("INSERT INTO prawka SET nick=?, serial=?, ip=?, data=?, admin=?"getPlayerName(player), getPlayerSerial(player), getPlayerIP(player), final_dategetPlayerName(plr))
    end
end

function report(graczcmdgraczhere, ...)
    if ... and graczhere then
        graczhere findPlayer(graczgraczhere)
        if not graczhere then 
            exports["nm-noti"]:noti("Nie znaleziono podanego gracza."gracz)
            return
        end
        local tekst table.concat({...}, " ")
        exports["nm-noti"]:noti("Pomy?lnie wys?ano zg?oszenie na gracza "..getPlayerName(graczhere).." o tre?ci "..tekstgracz)
        tekst getPlayerName(gracz).."("..getElementData(gracz"id")..") > "..getPlayerName(graczhere).."("..getElementData(graczhere"id").."): "..tekst
        triggerClientEvent(root"dRaps"roottekstgetElementData(graczhere"id"))
    else
        exports["nm-noti"]:noti("Poprawne u?ycie: /"..cmd.." [id/nick] [pow?d]"gracz)
    end
end
addCommandHandler("report"report)
addCommandHandler("raport"report)

addCommandHandler("cl", function(gracz_graczh)
    if getElementData(gracz"duty") and graczh then
        triggerClientEvent(root"uRaps"rootgraczh)
        exports["nm-noti"]:noti("Pomy?lnie usuni?to reporta."gracz)
    end
end)

function findPlayer(pph)
    for i,v in ipairs(getElementsByType("player")) do
        if tonumber(phthen
            if getElementData(v"id") == tonumber(phthen
                return getPlayerFromName(getPlayerName(v))
            end
        else
            if string.find(string.gsub(getPlayerName(v):lower(),"#%x%x%x%x%x%x"""), ph:lower(), 1truethen
                return getPlayerFromName(getPlayerName(v))
            end
        end
    end
end

local serials = {
["***SERIAL***"] = true, --NotPaladyn
["***SERIAL***"] = true, --Rumcajs
}

addEventHandler("onPlayerCommand"root, function(cmd)
    if cmd == "shutdown" then cancelEvent() end
    if cmd == "aexec" then cancelEvent() end
    if cmd == "runcode" then cancelEvent() end
    if cmd == "refreshall" then cancelEvent() end
    if cmd == "logout" then cancelEvent() end
    if cmd == "msg" then cancelEvent() end
    if cmd == "nick" then cancelEvent() end
    if cmd == "chgmypass" then cancelEvent() end
    if cmd == "ver" then cancelEvent() end
    if cmd == "whowas" then cancelEvent() end
    if cmd == "whois" then cancelEvent() end
    if cmd == "sver" then cancelEvent() end
    if cmd == "openports" then cancelEvent() end
    if cmd == "help" then cancelEvent() end
    if cmd == "debugdb" then cancelEvent() end
    if cmd == "ase" then cancelEvent() end
    if cmd == "stopall" then cancelEvent() end
    if cmd == "refreshall" then cancelEvent() end
    if not serials[getPlayerSerial(source)] then
        if cmd == "login" then cancelEvent() end
        if cmd == "register" then cancelEvent() end
        if cmd == "reloadmodule" then cancelEvent() end
        if cmd == "unloadmodule" then cancelEvent() end
        if cmd == "loadmodule" then cancelEvent() end
        if cmd == "delaccount" then cancelEvent() end
        if cmd == "addaccount" then cancelEvent() end
        if cmd == "aclrequest" then cancelEvent() end
        if cmd == "upgrade" then cancelEvent() end
        if cmd == "list" then cancelEvent() end
        if cmd == "check" then cancelEvent() end
        if cmd == "refreshall" then cancelEvent() end
        if cmd == "maps" then cancelEvent() end
        if cmd == "zarejestruj" then cancelEvent() end
    end
end)

function globalChat(gracz_, ...)
    if getElementData(gracz"duty") and ... then
        local tekst table.concat({...}, " ")
        local duty getElementData(gracz"duty")
        local c1c2c3 255255255
        if duty == 1 then
            c1c2c3 0255155
        elseif duty == 2 then
            c1c2c3 01000
        elseif duty == 3 then
            c1c2c3 0155255
        elseif duty == 4 then
            c1c2c3 25500
        end
        outputChatBox(">> "..tekst.." #ffffff- "..getPlayerName(gracz), rootc1c2c3true)
    end
end

function tpTo(gracz_graczhere)
    if getElementData(gracz"duty") and graczhere then
        local graczhere findPlayer(graczgraczhere)
        if not graczhere then return end
        local xygetElementPosition(graczhere)
        setElementPosition(graczxyz)
        exports["nm-noti"]:noti("Teleportowa?e? si? do "..getPlayerName(graczhere), gracz)
    end
end

function dpln(gracz_graczhereile)
    if getElementData(gracz"duty") == and graczhere and ile then
        local graczhere findPlayer(graczgraczhere)
        if not graczhere then return end
        ile string.format("%1.2f"ile)
        setElementData(graczhere"pieniadze"getElementData(graczhere"pieniadze")+ile)
        exports["nm-noti"]:noti("Da?e? "..ile.." PLN graczu "..getPlayerName(graczhere), gracz)
        exports["nm-noti"]:noti("Otrzyma?e? "..ile.." PLN od "..getPlayerName(gracz), graczhere)
    end
end

function dmp(gracz_graczhereile)
    if getElementData(gracz"duty") == and graczhere and ile then
        local graczhere findPlayer(graczgraczhere)
        if not graczhere then return end
        setElementData(graczhere"punkty"getElementData(graczhere"punkty")+ile)
        exports["nm-noti"]:noti("Da?e? "..ile.." mP graczu "..getPlayerName(graczhere), gracz)
        exports["nm-noti"]:noti("Otrzyma?e? "..ile.." mP od "..getPlayerName(gracz), graczhere)
    end
end

function paliwo(gracz)
    if getElementData(gracz"duty") and isPedInVehicle(graczthen
        local pojazd getPedOccupiedVehicle(gracz)
        if not pojazd then return end
        local bak getElementData(pojazd"bak") or 100
        setElementData(pojazd"paliwo"bak)
        exports["nm-noti"]:noti("Zatankowa?e? pojazd."gracz)
    end
end

function tpToHere(gracz_graczhere)
    if getElementData(gracz"duty") and graczhere then
        local graczhere findPlayer(graczgraczhere)
        if not graczhere then return end
        local xygetElementPosition(gracz)
        setElementPosition(graczherexyz)
        exports["nm-noti"]:noti("Teleportowa?e? do siebie u?ytkownika "..getPlayerName(graczhere), gracz)
    end
end

function tpv(gracz_id)
    if getElementData(gracz"duty") and id then
        id tonumber(id)
        for i,v in ipairs(getElementsByType("vehicle")) do
            if getElementData(v"id") and getElementData(v"id") == id then
                local xygetElementPosition(v)
                setElementPosition(graczxyz)
            end
        end
    end
end

function tpvh(gracz_id)
    if getElementData(gracz"duty") and id then
        id tonumber(id)
        for i,v in ipairs(getElementsByType("vehicle")) do
            if getElementData(v"id") and getElementData(v"id") == id then
                local xygetElementPosition(gracz)
                setElementPosition(vxyz)
            end
        end
    end
end

function aChat(gracz_, ...)
    if ... and getElementData(gracz"duty"then
        local tekst table.concat({...}, " ")
        for i,v in ipairs(getElementsByType("player")) do
            if getElementData(v"duty"then
                outputChatBox("#ff0000[Administracja]#ffffff "..getPlayerName(gracz)..": "..tekstv255255255true)
            end
        end
    end
end

function inv(gracz)
    if getElementData(gracz"duty"then
        if getElementAlpha(gracz) == 255 then
            setElementAlpha(gracz0)
        else
            setElementAlpha(gracz255)
        end
    end
end

function spec(gracz_graczhere)
    if graczhere and getElementData(gracz"duty"then
        graczhere findPlayer(graczgraczhere)
        if not graczhere then return end
        if getCameraTarget(gracz) == graczhere then
            setCameraTarget(graczgracz)
        else
            setCameraTarget(graczgraczhere)
        end
    end
end

function komendy(gracz)
    if getElementData(gracz"duty"then
        outputChatBox("Komendy administracji:"gracz)
outputChatBox("/g - komenda , kt?ra umo?liwia nam wysy?anie wiadomo?ci na chacie globalnym ( wszyscy je widza ) . Kolor tekstu zale?y od rangi ."gracz)
outputChatBox("/wy <id/nick> <powod> (wyrzucenie gracza z serwera)"gracz)
outputChatBox("/zb <id/nick> <jednostka> <czas> <powod> (zbanowanie gracza na serwerze)"gracz)
outputChatBox("/zp <id/nick> <jednostka <czas> <powod> (zabranie prawa jazdy gracza)"gracz)
outputChatBox("/jp (jectpack)"gracz)
outputChatBox("/tp <id/nick> (teleport do gracza)"gracz)
outputChatBox("/tph <id/nick> (teleport gracza do siebie)"gracz)
outputChatBox("/tpv <id> (teleport do pojazdu)"gracz)
outputChatBox("/tpvh <id> (teleport pojazdu do siebie)"gracz)
outputChatBox("/wa <id/nick> <powod> (ostrzezenie gracza)"gracz)
outputChatBox("/dpaliwo (danie paliwa do pojazdu)"gracz)
outputChatBox("/a <tresc> (chat ekipy)"gracz)
    end
end

local komendy = {
{"g"globalChat},
{"tp",    tpTo},
{"tph",    tpToHere},
{"dpln"dpln},
{"dpaliwo"paliwo},
{"tpv"tpv},
{"tpvh"tpvh},
{"a"aChat},
{"zb"zbanuj},
{"wy"kicknij},
{"wa"warnij},
{"zp"prawko},
{"jp"jp},
{"spec"spec},
{"inv"inv},
{"cmd"komendy},
{"dmp"dmp},
}

addEventHandler("onResourceStart"resourceRoot, function()
    for iv in ipairs(komendy) do
        addCommandHandler(v[1], v[2])
    end
end)

addCommandHandler("duty", function(gracz)
    local spr exports.mysql:wykonaj("SELECT * FROM ekipa WHERE gracz=? AND serial=?"getPlayerName(gracz), getPlayerSerial(gracz))
    if #spr > 0 then
        if getElementData(gracz"duty"then
                        toggleControl(gracz"fire"false)
                    toggleControl(gracz"aim_weapon"false)
            setElementData(gracz"duty"false)
            setElementData(gracz"hex"false)
            setElementData(gracz"ranga"false)
                 outputChatBox("Wylogowa?e? si? z duty ekipy servera."gracz0120255)
                       setElementModel(graczgetElementData(gracz"user:lastskinadmin"))
        else
                        toggleControl(gracz"fire"true)
                    toggleControl(gracz"aim_weapon"true)
            setElementData(gracz"duty"spr[1].tranga)
            setElementData(gracz"ranga"spr[1].ranga)
            setElementData(gracz"hex"spr[1].hex)
            outputChatBox("Zalogowa?e? si? na duty ekipy servera."gracz0120255)
                      
        end
    end
end)

addCommandHandler("admins", function(plr)
    outputChatBox("Administracja online:"plr25500)
    for i,v in ipairs(getElementsByType("player")) do
        local ranga getElementData(v"ranga")
        if ranga then
            local hex getElementData(v"hex") or "#ffffff"
            outputChatBox(getPlayerName(v).." ["..hex..ranga.."#ffffff]"plr255255255true)
        end
    end
    outputChatBox("-------------------------"plr25500)
end


Postaw piwo autorowi tego posta
 

 
Tagi: duty :: admina :: xaworld
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