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

Wysłany: 2015-12-04, 14:44


teusz11







Wiek: 29
Na forum: 4793 dni
Posty: 191
Nick w MP: Matevsz

Piwa: 4

Respekt: 50

Witam, napisa?em dzi? prosty sktypt na blokad? bicia, jednak dzia?a on dopiero gdy zaloguje si? na konto Admina, jako gracz na spawnie mog? si? bi? i strzela?.. Jak zrobi? aby by?o to dost?pne dla wszystkich?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-12-04, 14:55


Maximerr

Programmer PHP, LUA






Wiek: 25
Na forum: 4568 dni
Posty: 548

Piwa: 1051

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

Poka? go, pewnie da?e? z?y EventHandler.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-12-04, 15:59


teusz11







Wiek: 29
Na forum: 4793 dni
Posty: 191
Nick w MP: Matevsz

Piwa: 4

Respekt: 50

Dobra, jednak pomyli?em Event. Teraz jest ok. Ale teraz chcia?bym naprawi? licznik, mianowicie, gdy wsiadam do samochodu wskaz?wka od razu jest na 120 a jak jad? max pr?dko?ci? to wychodzi po za licznik (max 260).

 </span><fieldset style="background-color: #191919;border: 1px dashed #3d3d3d; border-radius: 5px 5px 5px 5px; max-width:95%;"><legend><b><img src=http://www.gtao.pl/templates/FIBlack/images/resource.png><span class="genmed"> Kod:</span></b></legend><div style="overflow: auto; overflow-x: auto; overflow-y: auto; width:100%; max-height: 200px;"><table style="width:100%;"><br><td style="font-size: 11px;font-family: Courier New; color: #FFF0B0">
g_root = getRootElement()
g_rootElement = getResourceRootElement( getThisResource() )
g_Player = getLocalPlayer()

c_EnableScaling = true
c_XOffset = 10
c_YOffset = 10
c_ImageW = 200
c_ImageH = 200
c_BarW = 0
c_BarH = 0
c_BarYOffset = 70


c_FireTimeMs = 5000
c_BarAlpha = 120
c_BarFlashInterval = 300

g_tFireStart = nil

function drawNeedle()
    if not isPedInVehicle(g_Player) then
        -- Fallback for player exiting car without onClientVehicleStartExit event
        --   (e.g. falling off a bike)
        hideSpeedometer()
    end
    local vehSpeed = getVehicleSpeed()
    --local vehHealth = getElementHealth(source,getPedOccupiedVehicle(g_Player))

    if vehHealth and (vehHealth > 0) then
        local hp = (vehHealth-250)/750
        local curBarLen = hp*g_BarW
        if curBarLen < 1 then curBarLen = 1 end

        local r = 255*(1 - hp)/0.5
        if r > 255 then r = 255 end
        local g = 255*hp/0.5
        if g > 255 then g = 255 end
        if g < 0 then g = 0 end
       
        if hp >= 0 then
            g_tFireStart = nil
            dxDrawRectangle(x + g_ImageW/2 - g_BarW/2, y + g_BarYOffset, curBarLen, g_BarH, tocolor(r, g, 0, c_BarAlpha))
        else
            if not g_tFireStart then g_tFireStart = getTickCount() end
            local firePerc = (c_FireTimeMs - (getTickCount() - g_tFireStart)) / c_FireTimeMs
            if firePerc < 0 then firePerc = 0 end
            local a = c_BarAlpha
            if (getTickCount()/c_BarFlashInterval)%2 > 1 then a = 0 end
            dxDrawRectangle(x + g_ImageW/2 - g_BarW/2, y + g_BarYOffset, firePerc*g_BarW, g_BarH, tocolor(255, 0, 0, a))
        end    
    end
    dxDrawImage(x, y, g_ImageW, g_ImageH, "needle.png", vehSpeed, 0, 0, white, true)
end


function showSpeedometer()
    guiSetVisible(disc, true)
    addEventHandler("onClientRender", g_root, drawNeedle)
end
function hideSpeedometer()
    guiSetVisible( disc, false)
    removeEventHandler("onClientRender", g_root, drawNeedle)
end

function getVehicleSpeed()
    if isPedInVehicle(g_Player) then
        local vx, vy, vz = getElementVelocity(getPedOccupiedVehicle(g_Player))
        return math.sqrt(vx^2 + vy^2 + vz^2) * 161
    end
    return 0
end


addEventHandler("onClientVehicleEnter", g_root,
    function(thePlayer)
        if thePlayer == g_Player then
            showSpeedometer()
        end
    end
)

addEventHandler("onClientVehicleStartExit", g_root,
    function(thePlayer)
        if thePlayer == g_Player then
            hideSpeedometer()
        end
    end
)

function round(num)
    return math.floor(num + 0.3)
end

function initGui()
    if disc then
        destroyElement(disc)
    end
    g_screenWidth, g_screenHeight = guiGetScreenSize()
    local scale
    if c_EnableScaling then
        scale = (g_screenWidth/1000 + g_screenHeight/850)/2
    else
        scale = 1
    end
    g_XOffset = round(c_XOffset*scale)
    g_YOffset = round(c_YOffset*scale)
    g_ImageW = round(c_ImageW*scale)
    g_ImageH = round(c_ImageH*scale)
    g_BarW = round(c_BarW*scale)
    g_BarH = round(c_BarH*scale)
    g_BarYOffset = round(c_BarYOffset*scale)
    disc = guiCreateStaticImage(g_screenWidth - g_ImageW - g_XOffset, g_screenHeight - g_ImageH - g_YOffset, g_ImageW, g_ImageH, "disc.png", false)
    x, y = guiGetPosition(disc, false)
end

addEventHandler("onClientResourceStart", g_rootElement,
    function ()
        initGui()
        guiSetVisible(disc, false)
        setTimer(function()
            local w, h = guiGetScreenSize()
            if (w ~= g_screenWidth) or (h ~= g_screenHeight) then
                initGui()
            end
        end, 500, 0)
        if isPedInVehicle(g_Player) then
            showSpeedometer()
        end
    end
)
</td></table></div></fieldset><span class="postbody">


Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-12-04, 19:43


Fanciak

BOT






Wiek: 26
Na forum: 4587 dni
Posty: 728
Nick w MP: Fanciak

Piwa: 1572

Respekt: 500
Respekt: 500

No to pozmieniaj cyfry na pocz?tku dot. wskaz?wki. Jak Ci mamy pom?c, jak nie mamy k??ka (licznika)? Pomy?l troch?...

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-12-06, 20:41


DamianGames







Wiek: 23
Na forum: 4087 dni
Posty: 75

Piwa: 524

Respekt: 31,5

Ostrzeżeń: 60%
To nie wina skryptu tylko obrazka wskaz?wki

Tak powinna wygl?da? poprawnie u?o?ona wskaz?wka


Postaw piwo autorowi tego posta
 

 
Tagi: blokada :: bicia
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