Huan_Strasilov
Wiek: 29 Na forum: 2230 dni Posty: 6
Nick w MP: Huan_Strasilov
Piwa : 47
Witam, chcia?bym do pracy magazyniera z pys 3.0 doda? gui gdzie mia?oby by? przycisk rozpocz?cia tylko i zeby kursor sie pokaza? klikn?? F3 i zeby normalnie wyj?? sobie z markera. Gui stworze sobie w guieditor bedzie tam tylko napis i button rozpocznij. Chcia?bym abyscie nakierowali mnie po kolei jakich funkcji u?y?.
A fajnie by by?o jak by sie te? da?o zako?czy? komend?, albo tak jak rozpocz??o
tutaj kod po stronie clienta
local startMagazyn = createMarker ( 5.69 , - 106.82 , 998.06 - 0.9 , "cylinder" , 1.5 , 255 , 255 , 0 )
setElementInterior ( startMagazyn , 1 )
setElementDimension ( startMagazyn , 1 )
x , y = guiGetScreenSize ()
px , py = ( x / 1024 ), ( y / 768 )
pkt = {
{ 1.86 , - 136.43 , 993.39 },
{ 2.75 , - 143.92 , 993.39 },
{- 3.87 , - 146.44 , 993.39 },
{- 9.60 , - 146.95 , 993.39 },
{ 10.07 , - 144.76 , 993.39 },
{ 10.15 , - 140.12 , 993.39 },
{ 9.02 , - 128.05 , 993.39 },
{ 7.75 , - 119.44 , 993.39 },
{ 10.20 , - 116.68 , 993.39 },
{ 9.95 , - 120.39 , 993.39 },
{ 16.24 , - 119.62 , 993.39 },
{ 16.80 , - 115.82 , 993.39 },
{ 16.42 , - 110.51 , 993.39 },
{ 10.78 , - 109.25 , 993.39 },
{ 23.66 , - 110.44 , 993.39 },
{ 22.95 , - 115.79 , 993.39 },
{ 26.34 , - 117.90 , 993.39 },
{ 30.17 , - 111.63 , 993.39 },
{ 30.42 , - 117.48 , 993.39 },
{ 30.50 , - 121.04 , 993.39 },
{ 30.53 , - 125.72 , 993.39 },
{ 26.93 , - 134.48 , 993.39 },
{ 26.47 , - 138.39 , 993.39 },
{ 29.88 , - 139.57 , 993.39 },
{ 30.04 , - 143.99 , 993.39 },
{ 6.26 , - 108.71 , 993.39 },
}
setElementData ( localPlayer , "skrzynia:magazyn" , nil )
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
posx , posy = 465 , 621
addEventHandler ( "onClientRender" , root , function()
if not getElementData ( localPlayer , "skrzynia:magazyn" ) == true then return end
if loading == 390 then setElementData ( localPlayer , "skrzynia:magazyn" , false ) toggleAllControls ( true )
triggerServerEvent ( "anim" , localPlayer , false )
if getElementData ( localPlayer , "player:premium" ) then
triggerServerEvent ( "monetyMagazynier" , localPlayer , math . random ( 120000 * 1.2 , 135000 * 1.2 ), math . random ( 1 , 6 ))
else
triggerServerEvent ( "monetyMagazynier" , localPlayer , math . random ( 120000 , 135000 ), math . random ( 0 , 4 ))
end
return end
newTick = getTickCount ()
loading = interpolateBetween ( 0 , 0 , 0 , 390 , 0 , 0 , ( newTick - tick )/ 7500 , "Linear" )
dxDrawImage ( 316 * px , 331 * py , 400 * px , 50 * py , "bar.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , 255 ), false )
dxDrawRectangle ( 319 * px , 335 * py , loading * px , 42 * py , tocolor ( 255 , 255 , 255 , 255 ), false )
end )
function markery ()
markerOdbior = createMarker (- 4.52 , - 127.93 , 993.39 - 0.9 , "cylinder" , 2 , 255 , 0 , 0 )
blipOdbior = createBlipAttachedTo ( markerOdbior , 41 )
setElementInterior ( markerOdbior , 1 )
setElementDimension ( markerOdbior , 1 )
setElementInterior ( blipOdbior , 1 )
setElementDimension ( blipOdbior , 1 )
addEventHandler ( "onClientMarkerHit" , markerOdbior , function( el )
if el ~= localPlayer then return end
destroyElement ( source )
destroyElement ( blipOdbior )
triggerServerEvent ( "anim" , localPlayer , true )
rand = math . random ( 1 , #pkt)
markerOddawanie = createMarker ( pkt [ rand ][ 1 ], pkt [ rand ][ 2 ], pkt [ rand ][ 3 ]- 0.9 , "cylinder" , 1.5 , 100 , 255 , 55 )
blipOddawanie = createBlipAttachedTo ( markerOddawanie , 41 )
setElementInterior ( markerOddawanie , 1 )
setElementDimension ( markerOddawanie , 1 )
setElementInterior ( blipOddawanie , 1 )
setElementDimension ( blipOddawanie , 1 )
addEventHandler ( "onClientMarkerHit" , markerOddawanie , function( el )
if el ~= localPlayer then return end
destroyElement ( source )
destroyElement ( blipOddawanie )
markery ()
setElementData ( localPlayer , "skrzynia:magazyn" , true )
tick = getTickCount ()
loading = 0
toggleAllControls ( false )
end )
end )
end
addEventHandler ( "onClientMarkerHit" , startMagazyn , function( el )
if el ~= localPlayer then return end
setElementData ( localPlayer , "gui:magazyniera" , true )
showCursor ( true )
if getElementData ( localPlayer , "praca" ) then triggerEvent ( "onClientAddNotification" , localPlayer , "Posiadasz aktywn? prac?" , "error" ) return end
outputChatBox ( "Rozpoczynasz prac? magazyniera. Aby zako?czy? wpisz /zakoncz.magazyn" , 100 , 100 , 250 )
for i , v in ipairs ( getElementsByType ( "player" )) do
setElementCollidableWith ( localPlayer , v , false )
setElementCollidableWith ( v , localPlayer , false )
end
setElementData ( localPlayer , "praca" , "magazyn" )
triggerEvent ( "onClientAddNotification" , localPlayer , "Rozpoczynasz prac? magazyniera, aby zako?czy? wpisz /zakoncz.magazyn" , "success" )
showCursor ( false )
setElementData ( localPlayer , "gui:magazyniera" , false )
markery ()
end )
addCommandHandler ( "zakoncz.magazyn" , function()
if getElementData ( localPlayer , "praca" ) ~= "magazyn" then
triggerEvent ( "onClientAddNotification" , localPlayer , "Nie posiadasz aktywnej pracy magazyniera" , "error" )
return
end
setElementData ( localPlayer , "praca" , nil )
destroyElement ( markerOdbior )
destroyElement ( blipOdbior )
destroyElement ( markerOddawanie )
destroyElement ( blipOddawanie )
setElementData ( localPlayer , "skrzynia:magazyn" , nil )
for i , v in ipairs ( getElementsByType ( "player" )) do
setElementCollidableWith ( localPlayer , v , false )
setElementCollidableWith ( v , localPlayer , false )
end
showCursor ( false )
triggerServerEvent ( "magazyn" , localPlayer )
triggerEvent ( "onClientAddNotification" , localPlayer , "Ko?czysz prac? jako magazynier" , "success" )
end )
tutaj kod po stronie serwera
box = {}
addEvent ( "anim" , true )
addEventHandler ( "anim" , root , function( bul )
if bul then
setPedAnimation ( client , "CARRY" , "crry_prtial" , 4.1 , true , true , true )
box [ client ] = createObject ( 1271 , 0 , 0 , 0 )
setObjectScale ( box [ client ], 0.8 )
setElementInterior ( box [ client ], 1 )
setElementDimension ( box [ client ], 1 )
attachElements ( box [ client ], client , - 0.087 , 0.74 , 0.55 )
toggleControl ( client , "walk" , false )
toggleControl ( client , "jump" , false )
toggleControl ( client , "sprint" , false )
toggleControl ( client , "crouch" , false )
setControlState ( client , "walk" , true )
else
setPedAnimation ( client , "CARRY" , "liftup" , 0.0 , false , false , false , false )
end
end )
addEvent ( "monetyMagazynier" , true )
addEventHandler ( "monetyMagazynier" , root , function( ilosc , repa )
local kasa = ilosc
givePlayerMoney ( client , kasa )
triggerClientEvent ( client , "onClientAddNotification" , client , "Za odniesienie skrzyni otrzymujesz " .. kasa .. " $" , "success" )
local reputacja = getElementData ( client , "player:reputation" )
setElementData ( client , "player:reputation" , reputacja + repa )
destroyElement ( box [ client ])
end )
addEvent ( "magazyn" , true )
addEventHandler ( "magazyn" , root , function()
destroyElement ( box [ client ])
toggleControl ( client , "walk" , true )
toggleControl ( client , "jump" , true )
toggleControl ( client , "sprint" , true )
toggleControl ( client , "crouch" , true )
setControlState ( client , "walk" , false )
setPedAnimation ( client , "CARRY" , "liftup" , 0.0 , false , false , false , false )
end )