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

Wysłany: 2015-07-15, 00:24


timmer1994

Recon






Wiek: 31
Na forum: 3981 dni
Posty: 60
Nick w MP: Recon

Piwa: 6

Respekt: 50

Komendy tylko dla Adma mam za sob? powiedzmy, teraz chcialbym by dany zas?b dzia?a? tylko dla mnie <Admina>
Mozna wgl tak zrobic ?
W przyblizeniu: Mam handling editor, chce by dost?p do niego mial tylko Admin czyli ja.

[ Dodano: 2015-07-15, 00:26 ]
Znalaz?em to, nie wiem czy mi pomo?e

https://wiki.multitheftauto.com/wiki/GetResourceACLRequests

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-15, 08:00


Fanciak

BOT






Wiek: 25
Na forum: 4446 dni
Posty: 728
Nick w MP: Fanciak

Piwa: 1572

Respekt: 500
Respekt: 500


Więcej informacji znajdziesz w Wikipedii MTA:

IsObjectInACLGroup


Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-15, 08:45


Maximerr

Programmer PHP, LUA






Wiek: 25
Na forum: 4427 dni
Posty: 548

Piwa: 1051

Respekt: 365,3
Respekt: 365,3Respekt: 365,3Respekt: 365,3Respekt: 365,3

timmer1994, u?yj funkcji, kt?rej Ci poda? Fanciak, minusem jest, ?e mo?esz jej u?y? tylko po stronie servera.
Nadajesz jak?? elementDat? 'jest:adminem' na Admina?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-15, 09:48


timmer1994

Recon






Wiek: 31
Na forum: 3981 dni
Posty: 60
Nick w MP: Recon

Piwa: 6

Respekt: 50

Maxximer mog? wykorzystac to co wczoraj mi podpowiada?es:

addCommandHandler "setplate",function ( plrcmdtablica )
    if isObjectInACLGroup ("user."..getAccountName (getPlayerAccount(plr)), aclGetGroup "Admin" )) then
    local auto getPedOccupiedVehicle(plr)
        if auto then
            setVehiclePlateText autotablica )
        end
    end
end)


Tylko, ?e w osobnym zasobie je?eli bym zrobi? kod kt?ry sprawdza czy moge wpisac komende /hedit to bedzie dzialac ?

Ten kod co podalem jakos bym musial przerobic

Potem sie zastanawiam czy w tym handling editorze nie bd musial grzebac
No i jeszcze handling editora mozna odpalac za pomoca przycisku "b" to tez jakos trzeba obejsc

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-15, 09:55


Maximerr

Programmer PHP, LUA






Wiek: 25
Na forum: 4427 dni
Posty: 548

Piwa: 1051

Respekt: 365,3
Respekt: 365,3Respekt: 365,3Respekt: 365,3Respekt: 365,3

timmer1994, mo?esz, ale zr?b lepiej tak, poszukaj w hendling editorze funkcji bindowania 'B' i dodawanie komendy '/hedit', a nast?pnie znajd? jak? funkcj? otwiera si? GUI i Ci to zrobi? - jak podasz ten kod, je?li znajdziesz! :->

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-15, 10:16


timmer1994

Recon






Wiek: 31
Na forum: 3981 dni
Posty: 60
Nick w MP: Recon

Piwa: 6

Respekt: 50

Szuka?em, znalaz?em takie co?:

local function toggleEvents windowboolplayer )
    local func removeEventHandler
    if bool then
        func addEventHandler
    end
    
    func("onClientClick"rootonClick)
    func("onClientCursorMove"rootonMove)
    func("onClientRender"rootonRender)

    local actions = {
        onClientGUIDoubleClick onDoubleClick,
        onClientMouseEnter onEnter,
        onClientMouseLeave onLeave,
        onClientGUIFocus onFocus,
        onClientGUIBlur onBlur,
        onClientGUIAccepted onEditBoxAccept,
        onClientGUIComboBoxAccepted onComboBoxAccept
    }
    for eventfn in pairs(actions) do
        func(eventwindowfn)
    end
    
    return true
end


function startBuilding ( )
    outputDebugString "Building the gui.." )
    
    if heditGUI.window then
        destroyGUI ( )
    end

    local window buildMainWindow()
    buildMenubar()
    buildViewButtons()
    buildViews()
    buildSpecials()
    
    guiSetVisible windowfalse )
    
    toggleEvents windowtrue )
    
    forceVehicleChange ( )
    
    bindKey getUserConfig "usedKey" ), toggleEditor )
    addCommandHandler getUserConfig "usedCommand" ), toggleEditor )
    
    return true
end



function destroyGUI ( )
    toggleEvents heditGUI.windowfalse )
    
    if heditGUI.window then
        destroyElement heditGUI.window )
    end
    
    unbindKey "lctrl""both"showOriginalValue )
    unbindKey "rctrl""both"showOriginalValue )
    unbindKey "lshift""both"showPreviousValue )
    unbindKey "rshift""both"showPreviousValue )
    
    guiElements = {}
    heditGUI resetGUI
end





function buildMainWindow()
    local wnd template.window
    heditGUI.window guiCreateElement wnd.typewnd.pos[1], wnd.pos[2], wnd.size[1], wnd.size[2], getText "windowHeader" ), wnd.alphawnd.hovercolor )
    
    if wnd.centered then
        guiSetPosition heditGUI.window, (scrX/2)-(wnd.size[1]/2), (scrY/2)-(wnd.size[2]/2), false )
    end
    
    guiWindowSetSizable heditGUI.windowwnd.sizable or false )
    guiWindowSetMovable heditGUI.windowwnd.movable or false )
    
    guiElements[heditGUI.window] = { "window""window""none"1wnd.events }
    
    for layer,gui in ipairs(wnd) do
        local element guiCreateElement gui.typegui.pos[1], gui.pos[2], gui.size and gui.size[1] or gui.widthgui.size and gui.size[2] or gui.width""gui.alphagui.hovercolor )
        guiSetEnabled elementfalse )
        
        table.insert heditGUI.backgroundelement )
        guiElements[element] = { "window""background""none"layergui.events }
    end
    
    return heditGUI.window
end





function buildMenubar()
    local offset 65
    local size = {6019}
    local pos = {10-offset22}
    for k,menu in ipairs template.menubar ) do
        pos[1] = pos[1] + offset
        local element guiCreateElement("button"pos[1], pos[2], size[1], size[2], getText("menubar"menu.title), 255, {25527224224})
        
        guiElements[element] = { "menuButton""button""none"menu.titlenil}
        table.insert heditGUI.menuButtonselement )

        local buttons = {}
        
        if menu[1then
            local longestName 100
            
            for item,list in ipairs(menu) do
            
                local posY = ( pos[2] + ) + ( 20 item )
                local menuButton guiCreateElement "button"pos[1], posY10020getViewShortName ( list ) )
                
                local textextent guiCreateElement "label"pos[1], posY10020getViewShortName ( list ) )
                local extent guiLabelGetTextExtent textextent )
                
                if extent longestName then
                    longestName extent
                end
                
                destroyElement textextent )
                
                guiSetVisible menuButtonfalse )
                
                guiElements[menuButton] = { "menuItem""button""none", list, nil }
                table.insert buttonsmenuButton )
                
            end
            
            for i,v in ipairs buttons ) do
                guiSetSize vlongestName 1020false )
            end
        end
        
        heditGUI.menuItems[menu.title] = buttons
    end
end



function buildViewButtons()
    local hovercolor = { 255255255128 }
    local offset 55
    local size = {5050}
    local pos = {1054-offset}

    for k,view in pairs template.views ) do
        pos[2] = pos[2] + offset

        local subContents view.contents
        if subContents then

            local width size[1] / #subContents
            for _title in ipairs(subContents) do
                local element guiCreateElement ("button"pos[1]+(width*_)-widthpos[2], widthsize[2], guiTemplateGetViewButtonText title ), alphahovercolor )
                
                guiElements[element] = { "viewButton""button""none"title }
                table.insert heditGUI.viewButtonselement )
            end

        else
            local element guiCreateElement ("button"pos[1], pos[2], size[1], size[2], guiTemplateGetViewButtonText view.title ), alphahovercolor )
            
            guiElements[element] = { "viewButton""button""none"view.title }
            table.insert heditGUI.viewButtonselement )
        end
    end
end



-- these are for views

function buildViews()
    local function scanSpecialView menuitemNamegui )
        local res = {}
        for k,v in pairs gui ) do
            if type ) == "table" then
                if not v.type then
                    res[k] = scanSpecialView menuk)
                else
                    local text guiTemplateGetItemText menu)
                    
                    local element guiCreateElement v.typev.pos[1], v.pos[2], v.size[1], v.size[2], textv.alphav.hovercolor )
                    
                    if type v.runfunction ) == "function" then
                        v.runfunction element )
                    end
                    
                    res[k] = element
                    guiElements[element] = { "viewItem""special""none"kv.events }
                end
            end
        end
        
        return res
    end
    
    for menu,v in pairs template.viewcontents ) do
        if v.redirect ~= "THIS_IS_ONE" then
            local items = {}
            
            
            
            if v.redirect == "handlingconfig" then
                -------------------------
                -- HANDLINGCONFIG MENU
                -------------------------
                
                local guiInfo template.viewcontents.redirect_handlingconfig.content
                
                for i,property in ipairs v.content ) do
                    
                    if isHandlingPropertyValid property then
                    
                        local propertyName getHandlingPropertyFriendlyName property )
                        local propertyName getHandlingPropertyFriendlyName property )
                        local labelInfo guiInfo.labels[i]
                        local label guiCreateElement labelInfo.typelabelInfo.pos[1], labelInfo.pos[2], labelInfo.size[1], labelInfo.size[2], propertyNamelabelInfo.alphalabelInfo.hovercolor )
                        
                        local configInfo guiInfo.buttons[i]
                        
                        if property == "centerOfMass" then
                        
                            local labelPosX guiGetPosition labelfalse )
                            local labelWidth guiLabelGetTextExtent label )
                            
                            guiSetSize labellabelWidth 5labelInfo.size[2], false )
                            
                            local labelX guiCreateElement labelInfo.typelabelPosX labelWidth 20labelInfo.pos[2], 1520"X"labelInfo.alphalabelInfo.hovercolor )
                            local labelY guiCreateElement labelInfo.typelabelPosX labelWidth 35labelInfo.pos[2], 1520"Y"labelInfo.alphalabelInfo.hovercolor )
                            local labelZ guiCreateElement labelInfo.typelabelPosX labelWidth 50labelInfo.pos[2], 1520"Z"labelInfo.alphalabelInfo.hovercolor )
                            
                            table.insert itemslabelX )
                            table.insert itemslabelY )
                            table.insert itemslabelZ )
                            
                            guiElements[labelX] = { "viewItem""infolabel""centerOfMassX"ilabelInfo.events }
                            guiElements[labelY] = { "viewItem""infolabel""centerOfMassY"ilabelInfo.events }
                            guiElements[labelZ] = { "viewItem""infolabel""centerOfMassZ"ilabelInfo.events }
                        
                            local buttonPosX configInfo.pos[1]
                            local buttonWidth math.round configInfo.size[1] / 3)
                            
                            local buttonX guiCreateElement "button"buttonPosX,                       configInfo.pos[2], buttonWidthconfigInfo.size[2], ""configInfo.alphaconfigInfo.hovercolor )
                            local buttonY guiCreateElement "button"buttonPosX buttonWidth,         configInfo.pos[2], buttonWidthconfigInfo.size[2], ""configInfo.alphaconfigInfo.hovercolor )
                            local buttonZ guiCreateElement "button"buttonPosX + ( buttonWidth ), configInfo.pos[2], buttonWidthconfigInfo.size[2], ""configInfo.alphaconfigInfo.hovercolor )
                            
                            guiSetFont buttonX"default-small" )
                            guiSetFont buttonY"default-small" )
                            guiSetFont buttonZ"default-small" )
                            
                            table.insert itemsbuttonX )
                            table.insert itemsbuttonY )
                            table.insert itemsbuttonZ )
                            
                            guiElements[buttonX] = { "viewItem""config""centerOfMassX"iconfigInfo.events }
                            guiElements[buttonY] = { "viewItem""config""centerOfMassY"iconfigInfo.events }
                            guiElements[buttonZ] = { "viewItem""config""centerOfMassZ"iconfigInfo.events }
                            
                        else
                        
                            -- If a table, return tableOtherwisefalse.
                            local propertyOptions type handlingLimits[property].options ) == "table" and handlingLimits[property].options or false
                            
                            -- If propertyOptions is not false, return the combobox as typeOtherwise a button.
                            local buttonType propertyOptions and "combobox" or "button"
                            
                            --If propertyOptions is not false, return a size needed for the heightOtherwisethe normal button size.
                            local buttonHeight propertyOptions and ( #propertyOptions * 20 ) + 20 or configInfo.size[2]
                            
                            -- Create it with no text
                            local button guiCreateElement buttonTypeconfigInfo.pos[1], configInfo.pos[2], configInfo.size[1], buttonHeight""configInfo.alphaconfigInfo.hovercolor )
                            
                            
                            
                            -- If we had a combobox with options
                            if propertyOptions then
                                for num,option in ipairs propertyOptions ) do
                                    guiComboBoxAddItem buttongetHandlingPropertyOptionName propertyoption ) )
                                end
                            end
                            
                            table.insert itemsbutton )
                            guiElements[button] = { "viewItem""config"propertyiconfigInfo.events }
                            
                        end
                        
                        table.insert itemslabel )
                        guiElements[label] = { "viewItem""infolabel"propertyilabelInfo.events }
                        
                    else
                        outputDebugString "Invalid property used for handling menu "..menu..": "..tostring(property) )
                    end
                end
                 
                
            elseif v.redirect == "handlingflags" then
                -------------------------
                -- HANDLINGFLAG MENU
                -------------------------
                
                local property v.content[1]
                
                if isHandlingPropertyHexadecimal property then
                    
                    local guiInfo template.viewcontents.redirect_handlingflags.content
                    
                    -- Make sure we have extras as it's optional
                    if type ( guiInfo.extras ) == "table" then
                        items.extra = {}
                        for i,gui in ipairs ( guiInfo.extras ) do
                            local element = guiCreateElement ( gui.type, gui.pos[1], gui.pos[2], gui.size[1], gui.size[2], tostring(gui.text), gui.alpha, gui.hovercolor )
                            
                            table.insert ( items.extra, element )
                            guiElements[element] = { "viewItem", "extra", property, i, gui.events }
                        end
                    end
                    
                    for byte,tab in ipairs ( guiInfo.checkboxes ) do
                        items[byte] = {}
                        for value,gui in pairs ( tab ) do
                            local byteName = getHandlingPropertyByteName ( property, byte, value )
                            local element = guiCreateElement ( gui.type, gui.pos[1], gui.pos[2], gui.size[1], gui.size[2], byteName, gui.alpha, gui.hovercolor )
                            
                            items[byte][value] = element
                            guiElements[element] = { "viewItem", "infolabel", property, { byte=byte, value=value }, gui.events }
                        end
                    end
                
                else
                
                    outputDebugString ( "Menu "..menu.." does not have a valid handling/model-flag property!" )
                    outputDebugString ( "Please change the first parameter of this menu to \"modelFlags\" or \"handlingFlags\"!" )
                    
                end
                
                
            else
                -------------------------
                -- SPECIAL MENU
                -------------------------
                
                items = scanSpecialView ( menu, "", v.content )
                
                if type ( v.runfunction ) == "function" then
                    v.runfunction ( items )
                end
                
            end
            
            
            
            heditGUI.viewItems[menu] = {
                redirect = v.redirect,
                requireLogin = v.requirelogin,
                requireAdmin = v.requireadmin,
                disabled = v.disable,
                onOpen = v.onOpen,
                onClose = v.onClose,
                guiItems = items
            }
            
            toggleViewItemsVisibility ( menu, false )
        end
    end
end





function buildSpecials()
    local function create ( gui, parent )
        local element = guiCreateElement ( gui.type, gui.pos[1], gui.pos[2], gui.size[1], gui.size[2], "", gui.alpha, gui.hovercolor )
        
        if type ( gui.runfunction ) == "function" then
            gui.runfunction ( element )
        end
        
        return element
    end
    
    
    
    for parent,v in pairs ( template.specials ) do
        
        local items = {}
        
        if not isValidGUI ( v ) then
            
            for sub,item in pairs ( v ) do
                
                if not isValidGUI ( item ) then -- MiniLog only! We won't go deeper!
                
                    items[sub] = {}
                
                    for logsub,logitem in pairs item ) do
                        
                        if isValidGUI logitem then
                            items[sub][logsub] = create logitemparent )
                            guiElementsitems[sub][logsub] ] = { "special""special""none"parentlogitem.events }
                        end
                        
                    end
                    
                else
                
                    items[sub] = create itemparent )
                    guiElementsitems[sub] ] = { "special""special""none"parentv.events }
                    
                end
                
            end
            
        else
            
            items create vparent )
            guiElements[items] = { "special""special""none"parentv.events }
            
        end
        
        heditGUI.specials[parent] = items
    end
end


Znajdz tam addCommandHandler
Ten Edytor pobiera z pliku ustawien

setting = {
    usedKey "b",
    usedCommand "hedit",
    language "english",
    template "default",
    lockVehicleWhenEditing true,
    dragmeterEnabled true,
}


[ Dodano: 2015-07-15, 10:23 ]
zapomnialem !!
bo cos zmienilem tam w bindKey powinno byc

bindKey getUserConfig "usedKey" ), "down"toggleEditor )


nie bylo "down"

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-15, 10:31


Maximerr

Programmer PHP, LUA






Wiek: 25
Na forum: 4427 dni
Posty: 548

Piwa: 1051

Respekt: 365,3
Respekt: 365,3Respekt: 365,3Respekt: 365,3Respekt: 365,3

function startBuilding ( )
if getElementData localPlayer,"jestadminem" then
    outputDebugString "Building the gui.." )
    
    if heditGUI.window then
        destroyGUI ( )
    end

    local window buildMainWindow()
    buildMenubar()
    buildViewButtons()
    buildViews()
    buildSpecials()
    
    guiSetVisible windowfalse )
    
    toggleEvents windowtrue )
    
    forceVehicleChange ( )
    
    bindKey getUserConfig "usedKey" ), toggleEditor )
    addCommandHandler getUserConfig "usedCommand" ), toggleEditor )
    
end
return true
end


A to dodaj po stronie servera do byle jakiego skryptu:
addEventHandler("onPlayerLogin",root,function()
if isObjectInACLGroup "user."..getAccountName (getPlayerAccount(source)), aclGetGroup "Admin" ) ) then
setElementData source"jestadminem",true )
end
end
)

Po wgraniu skryptu, zr?b reloga.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-15, 10:51


timmer1994

Recon






Wiek: 31
Na forum: 3981 dni
Posty: 60
Nick w MP: Recon

Piwa: 6

Respekt: 50

niestety po zmianie editor wgl nie reaguje, na konsoli wgrywa sie normalnie bez bledow, ale nie odpala.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-15, 10:53


Maximerr

Programmer PHP, LUA






Wiek: 25
Na forum: 4427 dni
Posty: 548

Piwa: 1051

Respekt: 365,3
Respekt: 365,3Respekt: 365,3Respekt: 365,3Respekt: 365,3

timmer1994, a s? jakie? b??dy w DB3?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-15, 10:58


timmer1994

Recon






Wiek: 31
Na forum: 3981 dni
Posty: 60
Nick w MP: Recon

Piwa: 6

Respekt: 50

o cholera, jak to sprawdzic

[ Dodano: 2015-07-15, 11:01 ]
Sekunda, edytor za?apa?, sprawdze teraz czy tylko ja mam dostep.

[ Dodano: 2015-07-15, 11:03 ]
Maxximer, wydaje si?, ?e wszystko dzia?a jak nale?y !
Nie wiem, pewnie nie zrestartowalem zasobu, m?j b??d.

Dzieki ! To mi pomo?e na przysz?o?? ;)

Podpis
Uczę się tworzyć skrypty ;) Pomóż zielonemu.
Postaw piwo autorowi tego posta
 

 
Tagi: zasób :: tylko :: dla :: adma
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