Wysłany: 2020-01-31, 22:12
PropaneRPG
Wiek: 25 Na forum: 3165 dni Posty: 40
Nick w MP: DevilLife
Piwa : 493
Witam, odk?d zacz??em prace nad prac? magazyniera zapomnia?em jak sie robi?o aby gui sie tylko pokazywa?o osobie kt?ra wchodzi w marker kto? pomo?e dopisa? tutaj to do kodu?
Kod:
local marker = createMarker( 2176.77, -2253.96, 14.07, "cylinder", 2, 0, 64, 255, 75)
local markerZABIERANIA = createMarker(2188.69921875, -2253.8017578125, 13.465845108032-1, "cylinder", 5, 0, 0, 0, 210)
function dxDrawGUI()
dxDrawImage(73*rx, 119*ry, 1297*rx, 712*ry, "tlo_job.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
exports['dxLibary']:dxLibary_createButton('Zamknij okno',649*rx, 652*ry, 188*rx, 35*ry)
exports['dxLibary']:dxLibary_text('Praca polega na przenoszeniu skrzynek \nz dworu do magazynu\nna wylosowana pulke.\n\nWynagrodznie:\nGracz: 5000 PLN/Skrzynka\nGracz premium: 7000 PLN/Skrzynka\nGracz Premium+: 8000 PLN/Skrzynka‚ ', 587*rx, 386*ry, 882*rx, 504*ry, tocolor(255, 255, 255, a), 5, 'default', 'center', 'top', false, false, false, true, false)
if getElementData(localPlayer, "praca:magazyn") == true then
exports['dxLibary']:dxLibary_createButton('Zakoncz',649*rx, 608*ry, 188*rx, 35*ry)
else
exports['dxLibary']:dxLibary_createButton('Rozpocznij',649*rx, 608*ry, 188*rx, 35*ry)
end
end
Wysłany: 2020-01-31, 22:17
Wilq
Wiek: 24 Na forum: 4429 dni Posty: 3410
Piwa : 739
No tu nawet nie pokazujesz tego GUI. Musisz wklei? ca?y kod.
Ale mog? powiedzie? ju? teraz, ?e ALBO:
- je?li to client, w evencie onClientMarkerHit musisz sprawdzi??czy element, kt?ry wszed? w marker to lokalny gracz
- je?li to serwer, to jako cel w triggerze musi by? gracz, kt?ry wszed??w marker
Wysłany: 2020-01-31, 22:21
PropaneRPG
Wiek: 25 Na forum: 3165 dni Posty: 40
Nick w MP: DevilLife
Piwa : 493
"Wilq" napisał/a :No tu nawet nie pokazujesz tego GUI. Musisz wklei? ca?y kod.
Ale mog? powiedzie? ju? teraz, ?e ALBO:
- je?li to client, w evencie onClientMarkerHit musisz sprawdzi??czy element, kt?ry wszed? w marker to lokalny gracz
- je?li to serwer, to jako cel w triggerze musi by? gracz, kt?ry wszed??w marker
Mo?esz ja?niej lub dopisa? to do tego gui? xd
Kod:
local screenW, screenH = guiGetScreenSize()
local rx, ry = screenW/1440, screenH/900
--Tworzy markery
local marker = createMarker( 2176.77, -2253.96, 14.07, "cylinder", 2, 0, 64, 255, 75)
local markerZABIERANIA = createMarker(2188.69921875, -2253.8017578125, 13.465845108032-1, "cylinder", 5, 0, 0, 0, 210)
local markery={
--[[ Przyk?‚ad: ||| {x, y, z , "cylinder", wielkosc, kolor RED, Kolor GREEN, Kolor BLUE, Przezroczysto?›?‡}, ||| --]]
{2201.765625, -2223.62890625, 13.546875-0.9 , "cylinder", 1, 0, 255, 0, 130},
{2205.173828125, -2260.2119140625, 13.554685592651-0.9 , "cylinder", 1, 0, 255, 0, 130},
{2219.9150390625, -2245.1904296875, 13.554685592651-0.9 , "cylinder", 1, 0, 255, 0, 130},
{2227.39453125, -2237.9375, 13.554685592651-0.9 , "cylinder", 1, 0, 255, 0, 130},
{2194.333984375, -2230.935546875, 13.531170845032-0.9 , "cylinder", 1, 0, 255, 0, 130},
}
--[----------------------------------------------------]--
--Pozycja Kursora(function https://wiki.multitheftauto.com/wiki/IsMouseInPosition)
function isMouseInPosition ( 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
-- DX
local screenW, screenH = guiGetScreenSize()
local w, h = (screenW/1280), (screenH/1024)
renderr = false
function dxDrawGUI()
-- Zmienny tekst
-- T?‚o
dxDrawImage(73*rx, 119*ry, 1297*rx, 712*ry, "tlo_job.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
-- pod?›wietlane przyciski
-- Reszta
exports['dxLibary']:dxLibary_createButton('Zamknij okno',649*rx, 652*ry, 188*rx, 35*ry)
exports['dxLibary']:dxLibary_text('Praca polega na przenoszeniu skrzynek \nz dworu do magazynu\nna wylosowana pulke.\n\nWynagrodznie:\nGracz: 5000 PLN/Skrzynka\nGracz premium: 7000 PLN/Skrzynka\nGracz Premium+: 8000 PLN/Skrzynka‚ ', 587*rx, 386*ry, 882*rx, 504*ry, tocolor(255, 255, 255, a), 5, 'default', 'center', 'top', false, false, false, true, false)
if getElementData(localPlayer, "praca:magazyn") == true then
exports['dxLibary']:dxLibary_createButton('Zakoncz',649*rx, 608*ry, 188*rx, 35*ry)
else
exports['dxLibary']:dxLibary_createButton('Rozpocznij',649*rx, 608*ry, 188*rx, 35*ry)
end
end
--Wy?›wietla dxDraw po wej?›ciu w marker
function wlaczDX()
if renderr == false then else return end
addEventHandler("onClientRender", root, dxDrawGUI)
showCursor(true)
renderr = true
end
addEventHandler("onClientMarkerHit", marker, wlaczDX)
-- Zamyka dx po kliknieciu
addEventHandler("onClientClick", getRootElement(), function()
if renderr == true then else return end
if isMouseInPosition(649*rx, 652*ry, 188*rx, 35*ry) then
removeEventHandler ("onClientRender", root, dxDrawGUI)
showCursor(false)
renderr = false
end
end
)
-- Tworzy przyciski
addEventHandler("onClientClick", getRootElement(), function()
if renderr == true then else return end
if isMouseInPosition(649*rx, 608*ry, 188*rx, 35*ry) then
if getElementData(localPlayer, "praca:magazyn") == true then
--konczyprace
removeEventHandler ("onClientRender", root, dxDrawGUI)
renderr = false
showCursor(false)
setElementData(localPlayer, "praca:magazyn", false)
outputChatBox("Pomy?›lnie ko?„czysz prace jako Magazynier.")
else
--RozpoczynaPrace
setElementData(localPlayer, "praca:magazyn", true)
removeEventHandler ("onClientRender", root, dxDrawGUI)
renderr = false
showCursor(false)
outputChatBox("Zaczynasz prace jako Magazynier.")
end
end
end)
-- Daje paczke i losuje oraz
bindKey("h", "down", function()
if isElementWithinMarker(localPlayer, markerZABIERANIA) then
if getElementData(localPlayer, "praca:magazyn") == true then
if getElementData(localPlayer, "mamskrzynke") == true then outputChatBox("Masz juĹĽ skrzynke!") return end
losuj = math.random ( 1, #markery )
local markerx = createMarker(markery[losuj][1],markery[losuj][2],markery[losuj][3], markery[losuj][4], markery[losuj][5], markery[losuj][6], markery[losuj][7], markery[losuj][8], markery[losuj][9])
blip = createBlipAttachedTo(markerx, 41)
setElementData(localPlayer, "mamskrzynke", true)
box = createObject(2912, 0, 0, 0)
attachElements(box, localPlayer, 0, 0.78, 0.3)
toggleControl ("sprint", false)
toggleControl ("jump", false)
toggleControl ("fire", false)
setPedAnimation(localPlayer, "carry", "crry_prtial", 1, false, true)
addEventHandler("onClientMarkerHit", markerx, function(el, md)
if localPlayer == el and md then
setPedAnimation(localPlayer, "CARRY", "putdwn", -1, true, false, false)
setTimer(function()
setElementData(localPlayer, "wezpaczke", false)
setElementData(localPlayer, "mamskrzynke", false)
destroyElement(markerx)
destroyElement(blip)
destroyElement(box)
toggleControl ("sprint", true)
toggleControl ("jump", true)
toggleControl ("fire", true)
triggerServerEvent("hajs:paczka", localPlayer)
setPedAnimation(localPlayer)
end, 1000, 1)
end
end)
else
outputChatBox("Nie pracujesz jako Magazynier.")
end
end
end)
addEventHandler("onClientVehicleEnter",root,function(plr)
if plr ~= localPlayer then return end -- je?eli jest to kto? inny ni? osoba kt?ra wykona?a event zwraca end
addEventHandler("onClientRender",root,hud)
removeEventHandler ("onClientRender", root, dxDrawGUI)
end)
Wysłany: 2020-01-31, 22:36
Wilq
Wiek: 24 Na forum: 4429 dni Posty: 3410
Piwa : 739
Zobacz do tego eventu: onClientMarkerHit.
Ustaw pierwszy argument funkcji tak jak jest to opisane tutaj
Wtedy sprawd? czy ten element to lokalny gracz, ?eby pobra? lokalnego gracza u?yj 'localPlayer' albo funkcji
Jak pisa?em na PW, mog??zaoferowa? edycj? / pisanie skrypt?w.
Wysłany: 2020-02-01, 11:50
PropaneRPG
Wiek: 25 Na forum: 3165 dni Posty: 40
Nick w MP: DevilLife
Piwa : 493
dopisa? by mi kto? to do tego kodu? pliska
Wysłany: 2020-02-01, 11:57
Wilq
Wiek: 24 Na forum: 4429 dni Posty: 3410
Piwa : 739
Musisz zdefiniowa? gracza w funkcji onClientMarkerHit, wtedy dodajesz
if gracz ~= getLocalPlayer () then return end
Wystarczy troch? pomy?le? i poczyta? ze zrozumieniem, a jak jest to zbyt trudne to mo?na si? dokszta?ci? w tym kierunku.
Wysłany: 2020-02-01, 12:20
PropaneRPG
Wiek: 25 Na forum: 3165 dni Posty: 40
Nick w MP: DevilLife
Piwa : 493
No dobra, ale gdzie mam to dopisa??
Wysłany: 2020-02-01, 14:25
Wilq
Wiek: 24 Na forum: 4429 dni Posty: 3410
Piwa : 739
Kod wykonuje si? od g?ry do do?u. Chyba sprawdzanie gracza na ko?cu by?oby bez sensu co?
Wysłany: 2020-02-01, 14:35
PropaneRPG
Wiek: 25 Na forum: 3165 dni Posty: 40
Nick w MP: DevilLife
Piwa : 493
No to mi po prostu napisz w kt?rym miejscu a nie sie w detektywa bawimy..
Wysłany: 2020-02-01, 16:15
Wilq
Wiek: 24 Na forum: 4429 dni Posty: 3410
Piwa : 739
Ja si? nie bawi? w detektywa, w 4 wiadomo?ciach z rz?du napisa?em co masz zrobi?. Masz sprawdzi? czy gracz si? zgadza przed wykonaniem reszty skryptu w tym samym evencie.
Jeszcze podrzuce:
https://cdw.edu.pl/jak-uczyc-czytania-ze-zrozumieniem/
B?d?c dok?adnym, to dzia? LUA nie jest miejscem na oczekiwanie gotowego kodu. Radz? poczyta? regulamin.
Więcej szczegółów
Wystawiono 1 piw(a):NotPaladyn
Tagi: gui :: pokazuje :: sie :: wszystkim
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: