Wysłany: 2019-11-08, 19:41
Kulegg
Wiek: 46 Na forum: 3125 dni Posty: 283
Piwa : 20
Hej,
Gdy pracuje na magazynier i chc? zako?czy? prac? na nim to musze wpisa? /zakoncz.magazynier.
Po wpisaniu tego, blipy(cel?w, czyli marker?w tam gdzie oddajemy skrzynke) znikaj? oraz praca si? zaka?cza, jednak?e tym samym obiekt(skrzynka), kt?ry trzymam po rozpocz?ciu tej pracy, dodany w skrypcie gdy pracujemy aby ta praca wygl?da?a "realistyczniej", nie znika. Ma?o tego, Po umarciu nadal mam t? skrzynk?, i tylko reconnect pomaga.
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 )
Wysłany: 2019-11-08, 19:54
Wilq
Wiek: 24 Na forum: 4428 dni Posty: 3410
Piwa : 739
Musisz u?y? zmiennej globalnej na skrzyni ?eby m?c j? potem usun??.
Wysłany: 2019-11-08, 20:00
Kulegg
Wiek: 46 Na forum: 3125 dni Posty: 283
Piwa : 20
Mam ju? t? funkcj?,
na samym dole kodu, jednak?e nadal skrzynka jest widoczna i tylko po reconnect'cie znika.
Zmienna globalnej skrzyni tzn?
Wysłany: 2019-11-08, 21:18
Wilq
Wiek: 24 Na forum: 4428 dni Posty: 3410
Piwa : 739
Musisz usun?? local przy tworzeniu skrzyni, albo zdefiniowa? 'skrzynia' na samym pocz?tku skryptu jako local.
Wysłany: 2019-11-08, 22:20
Kulegg
Wiek: 46 Na forum: 3125 dni Posty: 283
Piwa : 20
Usun??em local z przed "skrzyni" i uda?o si?, po od?o?eniu skrzyni skrzynia znika, lecz gdy od?o?ymy skrzynie to odrazu pojawia si? nast?pny blip, marker itp i to jest normalnie, ale teraz ?e skrzynia znika odrazu po od?o?eniu skrzyni to jest problem bo gdy mamy nastepny marker to nie mamy skrzyni aby wyglada realistycznie.
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 )
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 )
Wysłany: 2019-11-08, 22:54
Wilq
Wiek: 24 Na forum: 4428 dni Posty: 3410
Piwa : 739
No to nie usuwaj skrzyni, kiedy przechodzisz do nast?pnego punktu???
Za to odpowiada ta sama funkcja (destroyElement).
Gdyby? napisa? to sam, to by? si? orientowa? gdzie co jest.
Więcej szczegółów
Wystawiono 1 piw(a):Kulegg
Wysłany: 2019-11-08, 23:12
Kulegg
Wiek: 46 Na forum: 3125 dni Posty: 283
Piwa : 20
Dzi?ki dzia?a, dla ciebie za pomoc
Chcia?bym umie? tak? prac? napisa? sam xd
Tagi: usunięcie :: obiektu(skrzynki) :: zakończeniu :: pracy
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: