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: 24
Na forum: 4044 dni
Posty: 568
Nick w MP: P.Wiśnia

Piwa: 376

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."..accnameaclGetGroup("Rcon") or aclGetGroup("Moderator")) then
        if cel then
            if getPlayerFromPartialName(celthen
                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(name1truethen
                return player
            end
        end
    end
end


Client

local screenWscreenH guiGetScreenSize()

function math.round(numberdecimalsmethod)
    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) / 21083609tocolor(2530080), false)
        dxDrawText("Otrzymales Ostrzezenie od "..nick..":"screenW 0.1619screenH 0.2133screenW 0.8388screenH 0.2678tocolor(255255255255), 2.50"default""center""top"falsefalsefalsetruefalse)
        dxDrawText("Niestosowanie si? do ostrze?e? mo?e skutkowa? kickiem lub banem!"screenW 0.1619screenH 0.85screenW 0.8388screenH 0.2678tocolor(255255255255), 2.50"default""center""top"falsefalsefalsetruefalse)
        dxDrawText(trescscreenW 0.1619screenH 0.2678screenW 0.8388screenH 0.8389tocolor(255255255255), 2.00"default""center""center"falsefalsefalsetruefalse)
    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.0screenH 0.9300screenW 0.2650screenH 0.0706tocolor(00083), false)
        dxDrawText(cel.." "..co.." "..nick..". \nPowod: "..trescscreenW 0.0screenH 1.8600screenW 0.2650screenH 0.0706tocolor(25500255), 1.00"default""center""center"falsetruefalsefalsefalse)
    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.0screenH 0.9300screenW 0.2650screenH 0.0706tocolor(00083), false)
        dxDrawText(cel.." "..co.." "..nick.." na "..czas..""..czasname..". \nPowod: "..trescscreenW 0.0screenH 1.8600screenW 0.2650screenH 0.0706tocolor(25500255), 1.00"default""center""center"falsetruefalsefalsefalse)
    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.0screenH 0.9300screenW 0.2650screenH 0.0706tocolor(00083), false)
        dxDrawText(cel.." zosta?&#8218; zmutowany."screenW 0.0screenH 1.8600screenW 0.2650screenH 0.0706tocolor(25500255), 1.00"default""center""center"falsetruefalsefalsefalse)
    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: 26
Na forum: 4015 dni
Posty: 927
Nick w MP: #AteX

Piwa: 8360

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 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