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

Wysłany: 2015-09-01, 18:33


mlodasnygo







Wiek: 17
Na forum: 4114 dni
Posty: 205

Piwa: 518

Respekt: 161,8
Respekt: 161,8Respekt: 161,8

Witam, mam problem z pewnym skryptem, mianowicie chodzi o to ze nie pokazuje mi % zape?nienia, pomo?e kto? to naprawi??
Kody:


-server

local jobMarker
local jobVehicle
local jobOdbieranie = createMarker(1323.5300292969,1472.5004882813,10.8203125-1, "cylinder", 6, 0, 0, 255)


local positionTrash = {
    {346.6647644043,2539.1455078125,16.75606918335},
    {-1280.5670166016,-73.867202758789,14.1484375},
    {1985.8670654297,-2395.0385742188,13.546875},
    {1336.6829833984,1454.7218017578,10.8203125},
}

function finishJob()
    if jobMarker and isElement(jobMarker) then
        destroyElement(jobMarker)
        jobMarker = nil
    end
    if jobBlip and isElement(jobBlip) then
        destroyElement(jobBlip)
        jobBlip = nil
    end
end

function hideNextPoint(el, md)
    if el ~= localPlayer or not md then return end
    if not getPedOccupiedVehicle(el) then return end
    local pojazd = getPedOccupiedVehicle(el)
    if not getElementData(pojazd, "pojazd_smieci") then setElementData(pojazd, "pojazd_smieci", 0) end
     
    if getElementData(pojazd, "pojazd_smieci") > 100 then
        outputChatBox("* Posiadasz 100% Towar?w Wro? Do Lotniska LV Aby Roz?adowa?.")
        return
    end
    
    local smieci = getElementData(pojazd, "pojazd_smieci") + math.random(25, 35)
    
    finishJob()
    showNextPoint()
    playSoundFrontEnd(12)
    setElementData(pojazd, "pojazd_smieci", smieci)
    setElementData(pojazd, "pojazd_opis", "Towar: "..smieci.."%")
end

addEvent("givePlayerMoney", true)
addEventHandler("givePlayerMoney", root, function(hajsy)
    if not tonumber(hajsy) then return end
    givePlayerMoney(client,hajsy)
end)

function showNextPoint()
    jobRandom = math.random(1, #positionTrash)

    jobMarker = createMarker(positionTrash[jobRandom][1], positionTrash[jobRandom][2], positionTrash[jobRandom][3], "checkpoint", 4, 0, 0, 255)
    jobBlip = createBlipAttachedTo(jobMarker, 41)
    
    addEventHandler("onClientMarkerHit", jobMarker, hideNextPoint)
end

addEventHandler("onClientVehicleExit", resourceRoot, function(plr, seat)
    if seat == 0 then
        if plr == localPlayer then
            finishJob()
            outputChatBox("* Zako?czy?e? prac?")
            setElementData(source, "pojazd_smieci", 0)
            setElementData(plr, "gracz_praca", false)
        end
    end
end)

addEventHandler("onClientMarkerHit", jobOdbieranie, function(el, md)
    if not md or getElementType(el) ~= "player" then return end
    if el ~= localPlayer then return end
    if not getPedOccupiedVehicle(el) then return end
    local pojazd = getPedOccupiedVehicle(el)
    if getElementData(pojazd, "pojazd_smieci") and tonumber(60) <= getElementData(pojazd, "pojazd_smieci") then
        smieci = getElementData(pojazd, "pojazd_smieci") * 0.6
        
        setElementData(pojazd, "pojazd_smieci", 0)
        triggerServerEvent("givePlayerMoney", el, smieci, 5000)
        setElementData(pojazd, "pojazd_opis", "Towar: 0%")
    else
    outputChatBox("* Nie posiadasz wi?cej ni?. 80% Towar?w")
    end
end)

addEvent("STARTJobTrash", true)
addEventHandler("STARTJobTrash", resourceRoot, function()
    showNextPoint()
end)







-client
local positionVehicles = {
    {1347.587890625,1512.228515625,11.25,359.5, 360.0, 182.0},
    {1330.5113525391,1510.0656738281,11.25,359.5, 360.0, 182.0},
    {1316.7269287109,1508.6776123047,11.25,359.5, 360.0, 182.0},
    {1291.58, 1478.12, 11.28, 359.6, 360.0, 272.6},
    {1291.95, 1462.01, 11.28, 359.6, 360.0, 271.6},
    {1292.20, 1447.93, 11.28, 359.6, 360.0, 272.9},
    {1308.82, 1432.12, 11.28, 359.5, 360.0, 358.2},
    {1325.39, 1431.18, 11.28, 359.5, 0.1, 358.2},
    {1340.72, 1430.90, 11.28, 359.6, 360.0, 0.8},
}

for i,v in ipairs(positionVehicles) do
    local pojazd = createVehicle(593, v[1], v[2], v[3], v[4], v[5], v[6])
    setElementData(pojazd, "pojazd_opis", "Praca Dorywcza\nDodo")
    setElementData(pojazd, "pojazd_paliwo", 100)
    setVehicleEngineState ( pojazd, false )
    setElementFrozen(pojazd, true)
end

addEventHandler("onVehicleEnter", resourceRoot, function(plr, seat)
    if seat == 0 then
        setElementFrozen(source, false)
        setElementData(plr, "gracz_praca", true)
        outputChatBox("* Rozpocz??e?/-a? prac?.", plr)
        triggerClientEvent(plr, "STARTJobTrash", resourceRoot)
        setElementData(source, "pojazd_opis", "Towar: 0%")
    end
end)

function respawnVehicles()
    for i,v in ipairs(getElementsByType("vehicle", resourceRoot)) do
        if not getVehicleOccupant(v) then
            respawnVehicle(v)
            setElementFrozen(v, true)
            setVehicleEngineState ( v, false )
            setElementData(v, "pojazd_opis", "Praca Dorywcza\nDodo")
        end
    end
end
setTimer(respawnVehicles, 1200000, 0)


Za pomoc stawiam :piwo:
?atwe piwko, ?atwe piwko. :D

Pozdrawiam,
mlodygo ;D

Podpis
600 dni - 10 marca 2017
:piwo: 500 piw :piwo: - 10 marca 2017
Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-09-01, 19:00


Jurandovsky

Kurdebele






Wiek: 17
Na forum: 4979 dni
Posty: 915

Piwa: 2697

Respekt: 955,3
Respekt: 955,3Respekt: 955,3

Ehh, a masz tak? element dat?? : pojazd_opis?

W ogole masz 3dtext?

Podpis
Jedyny kontakt ze mną to PW forum

Kod:


local noobs = getElementsByTitle("player", "Programista LUA")
for k, v in ipairs(noobs) do
outputChatBox("Bez mózgu jest użytkownik o nicku: "..getPlayerName(v), root)
destroyElement(v)
end
Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-09-02, 14:54


Kurczak23







Wiek: 32
Na forum: 5173 dni
Posty: 30

Piwa: 499

Respekt: 115,3
Respekt: 115,3

addEventHandler("onClientRender", root, function()
    local rootx,rooty,rootz=getCameraMatrix()
    for i,vehicle in ipairs(getElementsByType("vehicle")) do
        local x,y,z=getElementPosition(vehicle)
        local sx,sy=getScreenFromWorldPosition(x,y,z)
        if sx and sy then
            local opis=getElementData(vehicle,"pojazd_opis")
            if opis then
                local distance=getDistanceBetweenPoints3D(rootx,rooty,rootz,x,y,z)
                if distance <= 20 then
                    dxDrawText(opis, sx-(string.len(opis)/2), sy, sx+100, sy, tocolor(255, 255, 255, 255), 1, "default-bold", "center", "center", false, true, false , false)
                end
            end
        end
    end
end)

Po stronie klienta do dowolnego skryptu nie konkretnie tego.

Postaw piwo autorowi tego posta
 

 
Tagi: nie :: pokazuje :: zapełnienia.
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