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

Wysłany: 2016-03-18, 16:57


P.Wiśnia

Programista LUA






Wiek: 25
Na forum: 4186 dni
Posty: 568
Nick w MP: P.Wiśnia

Piwa: 378

Respekt: 100
Respekt: 100

Czemu to nie dzia?a

server

function ostrzezenie(plr,cmd,cel,...)
    local tresc = {...}
    local tresc = table.concat(tresc," ")
    local account = getPlayerAccount(plr)
    local accname = getAccountName(account)
    if isObjectInACLGroup("user."..accname, aclGetGroup("Rcon") or aclGetGroup("Moderator")) then
        if cel then
            if getPlayerFromPartialName(cel) then
                local cel = getPlayerFromPartialName(cel)
                if tresc then
                    local nick = getPlayerName(plr)
                    local nickcel = getPlayerName(cel)
                    local co = "otrzyma? ostrze?enie od"
                    triggerClientEvent("ostrzezenie",resourceRoot,cel,nick,tresc)
                    triggerClientEvent("info",resourceRoot,root,nickcel,nick,co,tresc)
                end
            end
        end
    end
end
addCommandHandler("warn",ostrzezenie)

addEventHandler("onPlayerQuit",root,function(quitType,tresc,responsibleElement)
    if quitType == "Kicked" then
        local nick = getPlayerName(responsibleElement) or "Console"
        local nickcel = getPlayerName(source)
        local co = "zosta? wyrzucony przez"
        triggerClientEvent("info",resourceRoot,root,nickcel,nick,co,tresc)
    end
end)

addEventHandler("onPlayerBan",root,function(ban,responsibleElement)
    local nickcel = getPlayerName(source)
    local nick = getPlayerName(responsibleElement) or "Console"
    local tresc = getBanReason(ban)
    local czas = getUnbanTime(ban) - getBanTime(ban)
    local co = "zosta? zbanowany przez"
    if czas > 0 then
        triggerClientEvent("infoczas",resourceRoot,root,nickcel,nick,co,tresc,czas)
    else
        local czas = "na zawsze"
        triggerClientEvent("infoczas",resourceRoot,root,nickcel,nick,co,tresc,czas)
    end
end)

addEventHandler("onPlayerMute",root,function()
    local nickcel = getPlayerName(source)
    triggerClientEvent("infomute",resourceRoot,root,nickcel)
end)

function getPlayerFromPartialName(name)
    local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil
    if name then
        for _, player in ipairs(getElementsByType("player")) do
            local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower()
            if name_:find(name, 1, true) then
                return player
            end
        end
    end
end


Client

local screenW, screenH = guiGetScreenSize()

function math.round(number, decimals, method)
    decimals = decimals or 0
    local factor = 10 ^ decimals
    if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor
    else return tonumber(("%."..decimals.."f"):format(number)) end
end

wyswietla = false
wyswietlainfo = false
addEvent("ostrzezenie",true)
addEventHandler("ostrzezenie",resourceRoot,function(cel,nick,tresc)
    if cel ~= localPlayer then return end
    if wyswietla == true then return end
    function gui()
        dxDrawRectangle((screenW - 1083) / 2, (screenH - 609) / 2, 1083, 609, tocolor(253, 0, 0, 80), false)
        dxDrawText("Otrzymales Ostrzezenie od "..nick..":", screenW * 0.1619, screenH * 0.2133, screenW * 0.8388, screenH * 0.2678, tocolor(255, 255, 255, 255), 2.50, "default", "center", "top", false, false, false, true, false)
        dxDrawText("Niestosowanie si? do ostrze?e? mo?e skutkowa? kickiem lub banem!", screenW * 0.1619, screenH * 0.85, screenW * 0.8388, screenH * 0.2678, tocolor(255, 255, 255, 255), 2.50, "default", "center", "top", false, false, false, true, false)
        dxDrawText(tresc, screenW * 0.1619, screenH * 0.2678, screenW * 0.8388, screenH * 0.8389, tocolor(255, 255, 255, 255), 2.00, "default", "center", "center", false, false, false, true, false)
    end
    wyswietla = true
    addEventHandler("onClientRender",root,gui)
    setTimer(function()
        playSoundFrontEnd(5)
    end,500,3)
    setTimer(function()
        removeEventHandler("onClientRender",root,gui)
        wyswietla = false
    end,5000,1)
end)

addEvent("info",true)
addEventHandler("info",resourceRoot,function(plr,cel,nick,co,tresc)
    if wyswietlainfo == true then return end
    function info()
        dxDrawRectangle(screenW * 0.0, screenH * 0.9300, screenW * 0.2650, screenH * 0.0706, tocolor(0, 0, 0, 83), false)
        dxDrawText(cel.." "..co.." "..nick..". \nPowod: "..tresc, screenW * 0.0, screenH * 1.8600, screenW * 0.2650, screenH * 0.0706, tocolor(255, 0, 0, 255), 1.00, "default", "center", "center", false, true, false, false, false)
    end
    wyswietlainfo = true
    addEventHandler("onClientRender",root,info)
    setTimer(function()
        removeEventHandler("onClientRender",root,info)
        wyswietlainfo = false
    end,5000,1)
end)

addEvent("infoczas",true)
addEventHandler("infoczas",resourceRoot,function(plr,cel,nick,co,tresc,czas)
    if wyswietla == true then return end
    if czas == "na zawsze" then
        czas = "zawsze"
        czasname = ""
    else
        czas = tonumber(czas)
        if czas < 60 then
            czasname = " sekund"
        elseif czas >= 60 and czas <= 3599 then
            czas = math.round(czas/60)
            czasname = " minut"
        elseif czas >= 3600 and czas <= 86399 then
            czas = math.round(czas/3600)
            czasname = " godzin"
        elseif czas >= 86400 then
            czas = math.round(czas/86400)
            czasname = " dni"
        end
    end
    function info()
        dxDrawRectangle(screenW * 0.0, screenH * 0.9300, screenW * 0.2650, screenH * 0.0706, tocolor(0, 0, 0, 83), false)
        dxDrawText(cel.." "..co.." "..nick.." na "..czas..""..czasname..". \nPowod: "..tresc, screenW * 0.0, screenH * 1.8600, screenW * 0.2650, screenH * 0.0706, tocolor(255, 0, 0, 255), 1.00, "default", "center", "center", false, true, false, false, false)
    end
    wyswietlainfo = true
    addEventHandler("onClientRender",root,info)
    setTimer(function()
        removeEventHandler("onClientRender",root,info)
        wyswietlainfo = false
    end,5000,1)
end)

addEvent("infomute",true)
addEventHandler("infomute",resourceRoot,function(plr,cel)
    if wyswietlainfo == true then return end
    function info()
        dxDrawRectangle(screenW * 0.0, screenH * 0.9300, screenW * 0.2650, screenH * 0.0706, tocolor(0, 0, 0, 83), false)
        dxDrawText(cel.." zosta?&#8218; zmutowany.", screenW * 0.0, screenH * 1.8600, screenW * 0.2650, screenH * 0.0706, tocolor(255, 0, 0, 255), 1.00, "default", "center", "center", false, true, false, false, false)
    end
    wyswietlainfo = true
    addEventHandler("onClientRender",root,info)
    setTimer(function()
        removeEventHandler("onClientRender",root,info)
        wyswietlainfo = false
    end,5000,1)
end)


Meta

<meta>
         <script src="info-s.lua" type="server" />
      <script src="info-c.lua" type="client" cache="false" /> 
</meta>

Errory
WARNING: Script 'Panel-Moderatora/info-s.lua' is not encoded in UTF-8. Loading as ANSI...
SCRIPT ERROR: Panel-Moderatora/info-s.lua:1: unexpected symbol near '?'

Ostatnio zmieniony przez #404 2016-03-19, 09:28, w całości zmieniany 1 raz  
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-03-18, 16:59


AteX







Wiek: 27
Na forum: 4156 dni
Posty: 925
Nick w MP: #AteX

Piwa: 8366

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

Z?e kodowanie tekstu. Przy zapisywaniu w notatniku wybierz na dole Kodowanie: UTF-8. Notepad++ ma to na g?rnym pasku w zak?adce Format.

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

 
Tagi: ostrzeżenia
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






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