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: 3125 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*px0*py1920*px1080*py"StreetView.png"000tocolor(255255255255))


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.7314.27)


local zone createColSphere(-1986.58955.0345.54,)
createBlip(1398.00, -1562.4229.2246,2,0,0,0,0,0,275)
local m1 createMarker(1396.95, -1569.7313.27"cylinder"1.53514235)
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(elmd)
    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(elthen 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,getElementPosition(el)
    local bus createVehicle(5051382.10, -1564.7813.32359.80.1166.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,elfalse)
    triggerClientEvent(el"STARTJobBus"resourceRootbus)

    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[clientthen
          if isElement(vehs[client]) then destroyElement(vehs[client]) end
     end
end)

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

addEvent("onPlayerQuit"true)
addEventHandler "onPlayerQuit"getRootElement(), function()
     if vehs[sourcethen
          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: 4429 dni
Posty: 3410

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: 3125 dni
Posty: 283

Piwa: 20

Respekt: 50

Czyli to ma tak wygl?da??


onMarkerHit triggerClientEvent,
event onClientRender dxDrawImage(0*px0*py1920*px1080*py"StreetView.png"000tocolor(255255255255))
onClientClick isMouseInPosition triggerServerEvent


Postaw piwo autorowi tego posta
 

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


Wilq







Wiek: 24
Na forum: 4429 dni
Posty: 3410

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: 3125 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.4712.58"cylinder"1.513313313350)
setElementData(startPracy,"custom44"true)
createBlipAttachedTo(startPracy46)

local punktyOgrodnik = {
{1802.99, -2031.3713.52},
{1787.07, -2024.8313.48},
{1796.59, -2038.0313.53},
{1806.03, -2051.7813.56},
{1788.29, -2044.6113.54},
{1768.58, -2040.6613.53},
{1780.94, -2035.4413.51},
{1779.75, -2071.7913.59},
{1766.35, -2056.1713.59},
{1753.01, -2072.8013.63},
}

x,guiGetScreenSize()
pxpy = (x/1024), (y/768)

local mousePoints = {
{246*px387*py15*px15*px},
{276*px370*py15*px15*px},
{302*px377*py15*px15*px},
{342*px377*py15*px15*px},
{372*px360*py15*px15*px},
{402*px387*py15*px15*px},
{432*px387*py15*px15*px},
{442*px365*py15*px15*px},
{478*px365*py15*px15*px},
{498*px383*py15*px15*px},
{549*px366*py15*px15*px},
{569*px373*py15*px15*px},
{589*px383*py15*px15*px},
{595*px356*py15*px15*px},
{629*px373*py15*px15*px},
{649*px373*py15*px15*px},
{679*px390*py15*px15*px},
{699*px373*py15*px15*px},
{729*px363*py15*px15*px},
{759*px373*py15*px15*px},
{779*px373*py15*px15*px},
}
target=0
addEventHandler("onClientMarkerHit"startPracy, function(h)
    if ~= localPlayer then return end
    if isPedInVehicle(localPlayerthen return end
    setElementData(localPlayer"praca:ogrodnik:gui"true)
    showCursor(true)
end)

function isMouseIn xywidthheight )
    if ( not isCursorShowing( ) ) then
        return false
    end
    local sxsy guiGetScreenSize ( )
    local cxcy getCursorPosition ( )
    local cxcy = ( cx sx ), ( cy sy )
    if ( cx >= and cx <= width ) and ( cy >= and cy <= 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(markerRandomowy41)
end

        function onRandom(h)
        if ~= localPlayer then return end
        if isPedInVehicle(localPlayerthen return end
            target target+1
            setElementData(localPlayer"ogrodnik:zakonczono"false)
            addEventHandler("onClientRender"root, function()
                if getElementData(localPlayer"ogrodnik:zakonczono"then return end
                dxDrawImage(241*px63*py570*px357*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*px184*py400*px400*py"test.png")
end
addEventHandler("onClientRender"rootgui)

bindKey("mouse1""down", function()
    if not getElementData(localPlayer"praca:ogrodnik:gui") == true then return end
    if isMouseIn(538*px527*py161*px39*pythen
        setElementData(localPlayer"praca:ogrodnik:gui"false)
        showCursor(false)
    end
    if isMouseIn(324*px527*py161*px39*pythen
    if isPedInVehicle(localPlayerthen return end
    if getElementData(localPlayer"praca"then outputChatBox("Posiadasz aktywn? prac?!"25500) return end
        outputChatBox("Rozpoczynasz prac? magazyniera. Aby zako?czy? wpisz /zakoncz.magazynier"100100250)
        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(1271000)
        attachElements skrzynialocalPlayer00.80.5)

        showCursor(false)
        tworzenieMarkera()
        addEventHandler("onClientMarkerHit"markerRandomowyonRandom)
    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"localPlayermath.random(20,50))
            else
            triggerServerEvent("hajsOgrodnik"localPlayermath.random(30,80))
            end
            target 0

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

addCommandHandler("zakoncz.magazynier", function()
    if getElementData(localPlayer"praca") ~= "ogrodnik" then
        outputChatBox("Nie posiadasz aktywnej pracy magazyniera."25500)
        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 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