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

Wysłany: 2019-11-06, 14:19


Kulegg







Wiek: 46
Na forum: 3266 dni
Posty: 283

Piwa: 20

Respekt: 50

Cze??,
Chcia?em urozmaici? skrypt na prace i ulepszy? go z wygl?du, jednak?e nie mam poj?cia jak to zrobi?(pr?cz funkcji dxdrawimage), gdzie wklei? linijki oraz co jeszcze potrzeba aby to dzia?a?o.

Mam przygotowan? ju? linijke:
dxDrawImage(0*px, 0*py, 1920*px, 1080*py, "StreetView.png", 0, 0, 0, tocolor(255, 255, 255, 255))


Lecz nie mam poj?cia co dalej robi?, chc? zrobi? tak aby po wej?ciu w marker pracy, zamiast automatycznego poprzez skrypt dawania nam odrazu auta sv, wy?wietla? nam si? dany obrazek, i po ustawieniu isMouseIn i klikni?ciu w np Zacznij Prac?, dopiero wtedy nam si? da?o auto i rozpoczynamy prace.

Kod pracy:
 
local b=createElement("text")
setElementData(b,"name","PRACA: Kierowca Street-View\nZAROBEK:\n100 PLN\nPremium Zarobek 400 PLN")
setElementPosition(b,1396.93, -1569.73, 14.27)


local zone = createColSphere(-1986.58, 955.03, 45.54,3 )
createBlip(1398.00, -1562.42, 29.22, 46,2,0,0,0,0,0,275)
local m1 = createMarker(1396.95, -1569.73, 13.27, "cylinder", 1.5, 35, 142, 35)
vehs = {}
local code = "StreetView"
veh_obj = {}

function removePreviousVehicles(plr)
    for i,v in ipairs(getElementsByType("vehicle", resourceRoot)) do
        local sby = getElementData(v, "zrespilGracz")
        if sby and sby == plr and getPedOccupiedVehicle(plr) ~= v then
            destroyElement(v)
        end
    end
end


addEventHandler("onMarkerHit", m1, function(el, md)
    if getElementData(el, "vehicle_job_owner2") then
        outputChatBox("Wyst?pi? b??d #6969, zg?o? si? do zarz?du!", el)
        return
    end



    if not md or getElementType(el) ~= "player" or getPedOccupiedVehicle(el) then return end
    if getElementData(el,"player:job") then return end
    if #getElementsWithinColShape(zone,"vehicle") >= 1 then outputChatBox("*Nie ma wolnego miejsca poczekaj chwile!",el) return end
    local x,y,z = getElementPosition(el)
    local bus = createVehicle(505, 1382.10, -1564.78, 13.32, 359.8, 0.1, 166.3)
    setElementFrozen(el,true)
    setElementData(bus, "vehicle_job_owner2", el)
    setElementData(bus, "vehicle:fuel", 100000)
    setElementData(bus, "vehicle:mileage", math.random(50000,80000))
    setVehicleHandling(bus, "maxVelocity", 80.0)
    setElementData(el,"player:job",code)
   setTimer(warpPedIntoVehicle,200,1,el,bus)
    toggleControl(el,"enter_exit",false)
     setTimer(toggleControl,2000,1,el, "enter_exit",true)
    setTimer(setElementFrozen,2000,1,el, false)
    triggerClientEvent(el, "STARTJobBus", resourceRoot, bus)

    vehs[el] = bus
    veh_obj[bus] = createObject(3031,0,0,0)
    attachElements(veh_obj[bus],bus,0.3,-0.9,1.6,0,0,90)
 end)

addEvent("STOPJobBus", true)
addEventHandler("STOPJobBus", resourceRoot, function()
    local pojazd = getPedOccupiedVehicle(client)
    if pojazd then
        destroyElement(pojazd)
    end
end)

addEventHandler("onPlayerVehicleExit",resourceRoot,function()
destroyElement(source)
end)

addEvent("destroyVeh", true)
addEventHandler("destroyVeh", getRootElement(),
function()
     if vehs[client] then
          if isElement(vehs[client]) then destroyElement(vehs[client]) end
     end
end)

addEventHandler("onElementDestroy",resourceRoot,function()
  if getElementType(source) == "vehicle" then
    if veh_obj[source] then destroyElement(veh_obj[source]); veh_obj[source] = nil end
  end
end)

addEvent("onPlayerQuit", true)
addEventHandler ( "onPlayerQuit", getRootElement(), function()
     if vehs[source] then
          if isElement(vehs[source]) then destroyElement(vehs[source]) end
    end
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-11-06, 15:13


Wilq







Wiek: 24
Na forum: 4570 dni
Posty: 3409

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

onMarkerHit + triggerClientEvent,
po kliencie:
event onClientRender + dxDrawImage
onClientClick + isMouseInPosition + triggerServerEvent

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-11-06, 15:35


Kulegg







Wiek: 46
Na forum: 3266 dni
Posty: 283

Piwa: 20

Respekt: 50

Czyli to ma tak wygl?da??


onMarkerHit + triggerClientEvent,
event onClientRender + dxDrawImage(0*px, 0*py, 1920*px, 1080*py, "StreetView.png", 0, 0, 0, tocolor(255, 255, 255, 255))
onClientClick + isMouseInPosition + triggerServerEvent


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-11-06, 21:16


Wilq







Wiek: 24
Na forum: 4570 dni
Posty: 3409

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

No nie?le, co ja mam Ci te funkcje oddzielnie w linijkach napisa? ?eby je zrozumia??
Ja Ci je tylko wypisa?em, musisz je odpowiednio uzupe?ni? i wstawi? do kodu.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-11-06, 22:57


Kulegg







Wiek: 46
Na forum: 3266 dni
Posty: 283

Piwa: 20

Respekt: 50

Skopiowa?em kod z innej pracy z innej paczki, przerobi?em to na magazyniera i teraz ?adnie wszystko dzia?a z obrazkiem, doda?em obiekt jak? jest skrzynia(Do magazynu) i animacje r?k tak aby wygl?da?o ?e gdy rozpoczniemy prace to trzymamy skrzynie, i tak jest
.
Jednak?e m?j problem polega na tym teraz, ?e aby zako?czy? prac? to musimy wpisa? komende /zakoncz.magazynier, i po wpisaniu tego marker nam znika oraz konczymy prace, jednak dany obiekt(skrzynka) oraz animacja wpisana przezemnie w skrypcie nie usuwa si? i po zako?czeniu pracy dalej zostaj? te rzeczy, i co musze zrobi? aby je tak?e usun???

Kod:


local startPracy =  createMarker(1788.29, -2056.47, 12.58, "cylinder", 1.5, 133, 133, 133, 50)
setElementData(startPracy,"custom44", true)
createBlipAttachedTo(startPracy, 46)

local punktyOgrodnik = {
{1802.99, -2031.37, 13.52},
{1787.07, -2024.83, 13.48},
{1796.59, -2038.03, 13.53},
{1806.03, -2051.78, 13.56},
{1788.29, -2044.61, 13.54},
{1768.58, -2040.66, 13.53},
{1780.94, -2035.44, 13.51},
{1779.75, -2071.79, 13.59},
{1766.35, -2056.17, 13.59},
{1753.01, -2072.80, 13.63},
}

x,y = guiGetScreenSize()
px, py = (x/1024), (y/768)

local mousePoints = {
{246*px, 387*py, 15*px, 15*px},
{276*px, 370*py, 15*px, 15*px},
{302*px, 377*py, 15*px, 15*px},
{342*px, 377*py, 15*px, 15*px},
{372*px, 360*py, 15*px, 15*px},
{402*px, 387*py, 15*px, 15*px},
{432*px, 387*py, 15*px, 15*px},
{442*px, 365*py, 15*px, 15*px},
{478*px, 365*py, 15*px, 15*px},
{498*px, 383*py, 15*px, 15*px},
{549*px, 366*py, 15*px, 15*px},
{569*px, 373*py, 15*px, 15*px},
{589*px, 383*py, 15*px, 15*px},
{595*px, 356*py, 15*px, 15*px},
{629*px, 373*py, 15*px, 15*px},
{649*px, 373*py, 15*px, 15*px},
{679*px, 390*py, 15*px, 15*px},
{699*px, 373*py, 15*px, 15*px},
{729*px, 363*py, 15*px, 15*px},
{759*px, 373*py, 15*px, 15*px},
{779*px, 373*py, 15*px, 15*px},
}
target=0
addEventHandler("onClientMarkerHit", startPracy, function(h)
    if h ~= localPlayer then return end
    if isPedInVehicle(localPlayer) then return end
    setElementData(localPlayer, "praca:ogrodnik:gui", true)
    showCursor(true)
end)

function isMouseIn ( x, y, width, height )
    if ( not isCursorShowing( ) ) then
        return false
    end
    local sx, sy = guiGetScreenSize ( )
    local cx, cy = getCursorPosition ( )
    local cx, cy = ( cx * sx ), ( cy * sy )
    if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then
        return true
    else
        return false
    end
end

setElementData(localPlayer, "ogrodnik:zakonczono", false)

function tworzenieMarkera()
    rnd = math.random(1, #punktyOgrodnik)
    markerRandomowy = createMarker(punktyOgrodnik[rnd][1], punktyOgrodnik[rnd][2], punktyOgrodnik[rnd][3], 'corona', 1.5)
    blipRandomowy = createBlipAttachedTo(markerRandomowy, 41)
end

        function onRandom(h)
        if h ~= localPlayer then return end
        if isPedInVehicle(localPlayer) then return end
            target = target+1
            setElementData(localPlayer, "ogrodnik:zakonczono", false)
            addEventHandler("onClientRender", root, function()
                if getElementData(localPlayer, "ogrodnik:zakonczono") then return end
                dxDrawImage(241*px, 63*py, 570*px, 357*py,"trawa.png")
                dxDrawImage(mousePoints[target][1], mousePoints[target][2], mousePoints[target][3], mousePoints[target][4],"kolo.png")
            end)
            showCursor(true)
            destroyElement(source)
            destroyElement(blipRandomowy)
        end

function gui()
    if not getElementData(localPlayer, "praca:ogrodnik:gui") == true then return end
    dxDrawImage(312*px, 184*py, 400*px, 400*py, "test.png")
end
addEventHandler("onClientRender", root, gui)

bindKey("mouse1", "down", function()
    if not getElementData(localPlayer, "praca:ogrodnik:gui") == true then return end
    if isMouseIn(538*px, 527*py, 161*px, 39*py) then
        setElementData(localPlayer, "praca:ogrodnik:gui", false)
        showCursor(false)
    end
    if isMouseIn(324*px, 527*py, 161*px, 39*py) then
    if isPedInVehicle(localPlayer) then return end
    if getElementData(localPlayer, "praca") then outputChatBox("Posiadasz aktywn? prac?!", 255, 0, 0) return end
        outputChatBox("Rozpoczynasz prac? magazyniera. Aby zako?czy? wpisz /zakoncz.magazynier", 100, 100, 250)
        setElementData(localPlayer, "praca", "ogrodnik")
        setElementData(localPlayer, "praca:ogrodnik:gui", false)
      --  outputChatBox("* Od??? skrzynk? na p??k?.")
        setPedAnimation ( localPlayer, "CARRY", "crry_prtial", 1,true )
        local skrzynia = createObject(1271, 0, 0, 0)
        attachElements ( skrzynia, localPlayer, 0, 0.8, 0.5)

        showCursor(false)
        tworzenieMarkera()
        addEventHandler("onClientMarkerHit", markerRandomowy, onRandom)
    end
end)

function kliki()
    if getElementData(localPlayer, "praca") ~= "ogrodnik" then return end
    if isMouseIn(mousePoints[target][1], mousePoints[target][2], mousePoints[target][3], mousePoints[target][4]) then
        target = target+1
        if target == #mousePoints then
            if not getElementData(localPlayer, "player:premium") then
            triggerServerEvent("hajsOgrodnik", localPlayer, math.random(20,50))
            else
            triggerServerEvent("hajsOgrodnik", localPlayer, math.random(30,80))
            end
            target = 0

            setElementData(localPlayer, "ogrodnik:zakonczono", true)
                        destroyElement(skrzynia)
                        setPedAnimation(localPlayer, false)
                        setElementData(el, "praca", false)
            showCursor(false)
            tworzenieMarkera()
            addEventHandler("onClientMarkerHit", markerRandomowy, onRandom)
        end
        return
    end
end
bindKey("mouse1", "down", kliki)

addCommandHandler("zakoncz.magazynier", function()
    if getElementData(localPlayer, "praca") ~= "ogrodnik" then
        outputChatBox("Nie posiadasz aktywnej pracy magazyniera.", 255, 0, 0)
        return
    end
    setElementData(localPlayer, "praca", nil)
    destroyElement(markerRandomowy)
    destroyElement(blipRandomowy)
        destroyElement(skrzynia)
end)
 


Postaw piwo autorowi tego posta
 

 
Tagi: wstawienie :: obrazka :: skryptu :: pracą
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Wstawienie obrazka do skryptu z pracą Odpowiedz do tematu

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