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

Wysłany: 2015-03-15, 16:49


GumaPL123







Wiek: 52
Na forum: 4301 dni
Posty: 6
Nick w MP: GumaPl

Piwa: 1

Respekt: 50

Klatka dzia?a, ale gdy chce usun?? j? usuwa si?, ale wyst?puje b??d z destroyElement. Stawiam piwka.

-- Copyright by Fanta @2014. Zachowaj autora !

local kratki={}
klatka = {}
local komenda = "klatka" -- komenda bez '/'

addCommandHandler(komenda, function(plr, cmd, target)
local accName = getAccountName ( getPlayerAccount ( plr ) ) 
     if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
    if not target then 
        outputChatBox("Uzyj: /klatka <nick gracza>")
        return
    end

    local cel=getPlayerFromName(target)
    if not cel then 
        outputChatBox("Nie ma takiego gracza.")
        return
    end

    local x,y,z=getElementPosition(cel)
    local dim=getElementDimension(cel)
    local int=getElementInterior(cel)

    if kratki[cel] then
        for i=1, #kratki[cel] do -- najoptymalniejsza petla
            if isElement(kratki[cel][i]) then
                destroyElement(kratki[cel][i])
            end
        end
        kratki[cel]=nil
    end

    kratki[cel]={}
    kratki[cel][1]=createObject(971, x, y, z-0.9, 270, 0, 180.0) -- O.K. Nie rusza?
    kratki[cel][2]=createObject(971, x, y, z+6, 270, 0, 180) -- O.K Nie rusza?
    kratki[cel][3]=createObject(971, x, y+3.5, z+2.5, 0, 0, 0) -- O.K. Nie rusza?
    kratki[cel][4]=createObject(971, x-4.5, y, z+2.5, 0, 0, 270) -- O.K. Nie rusza?
    kratki[cel][5]=createObject(971, x, y-3.5, z+2.5, 0, 0, 180) -- O.K. Nie rusza?
    kratki[cel][6]=createObject(971, x+4, y, z+2.5, 0, 0, 270) -- O.K. Nie rusza?
    table.insert ( klatka, kratki[cel][1] )
    table.insert ( klatka, kratki[cel][2] )
    table.insert ( klatka, kratki[cel][3] )
    table.insert ( klatka, kratki[cel][4] )
    table.insert ( klatka, kratki[cel][5] )
    table.insert ( klatka, kratki[cel][6] )
    

    setElementInterior(kratki[cel][1], int)
    setElementDimension(kratki[cel][1], dim)
    setElementInterior(kratki[cel][2], int)
    setElementDimension(kratki[cel][2], dim)
    setElementInterior(kratki[cel][3], int)
    setElementDimension(kratki[cel][3], dim)
    setElementInterior(kratki[cel][4], int)
    setElementDimension(kratki[cel][4], dim)
    setElementInterior(kratki[cel][5], int)
    setElementDimension(kratki[cel][5], dim)
    setElementInterior(kratki[cel][6], int)
    setElementDimension(kratki[cel][6], dim)
    outputChatBox("Stworzy?e?/a? klatk? wok?? gracza " .. getPlayerName(cel), plr)
    end
end)


-- Event

function zabezpieczenie()
        -- zabezpieczenie - jezeli zakratowano gracza, a on wyszedl.
    if kratki[source] then
        for i=1, #kratki[source] do
            if isElement(kratki[source][i]) then
                destroyElement(kratki[source][i])
            end
        end
        kratki[source]=nil
    end
end
addEventHandler("onPlayerQuit", root, zabezpieczenie)
addCommandHandler("klatkausun", zabezpieczenie)


addCommandHandler ( "usunklatke", function(plr)
for k,v in ipairs ( klatka ) do
local accName = getAccountName ( getPlayerAccount ( plr ) ) 
     if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
destroyElement ( v )
end
end
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-03-15, 18:38


MeeShuffle

Programista/Grafik






Wiek: 33
Na forum: 4535 dni
Posty: 2758
Nick w MP: Shuffle

Piwa: 8578

Respekt: 535,3
Respekt: 535,3

Nie wnios? nic do tematu, ale pan Fanta powinien by? ukarany. Kod pochodzi z innego forum, kt?ry wstawi? m?j kolega, nie wiem czemu na g?rze jest napisane "Copyright by Fanta.."

Co do kodu, prosz? przerobi?em go lekko dla swojego serwera ale udost?pnie Ci go :


addCommandHandler ( "usun", function ( plr, cmd, cel )
    gr = exports["core"]:partNick ( plr, cel )
    if gr then
        if kratki[gr] then
            for i=1, #kratki[gr] do -- najoptymalniejsza petla
                if isElement(kratki[gr][i]) then
                    destroyElement(kratki[gr][i])
                end
            end
        kratki[gr]=nil
        id = getElementData ( gr, "ID" )
        outputChatBox ( "Administrator "..getPlayerName ( plr ).." [ "..id.." ] uwolni? Ci?", gr, 255, 255, 255 )
        setElementData ( gr, "klatka", false )
        end
    end
end)


Podpis

https://shufflecode.pl
Static Codes and Graphics - Join our discord!
Postaw piwo autorowi tego posta
 

 
Tagi: usuwanie :: klatki
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