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