Wysłany: 2019-02-14, 15:35
Pyrek24
Wiek: 25 Na forum: 3438 dni Posty: 546
Nick w MP: Pyrek
Piwa : 10
Witam ot??, mam spraw? umia? by kto? dorobi? mi element dat? vehicle:efuel, by np tankowa?o si? wi?cej ni? 100litr?w?
Kod
client
mojeW , mojeH = 1360 , 768
sW , sH = guiGetScreenSize ()
w , h = ( sW / mojeW ), ( sH / mojeH )
bar = guiCreateProgressBar ( 370 * w , 552.6 * h , 600 * w , 43 * h , false )
guiSetVisible ( bar , false )
label = guiCreateLabel ( 50 * w , 10 * h , 460 * w , 23 * h , "Paliwo : 100 % | Spacja : Tankowanie" , false , bar )
guiLabelSetColor ( label , 00 , 90 , 255 )
guiLabelSetHorizontalAlign ( label , "center" , false )
guiLabelSetVerticalAlign ( label , "center" )
-- x0 , y0 , z0 = getElementPosition ( m100 )
--[[ addEventHandler ( "onClientResourceStart" , getResourceRootElement ( getThisResource ()),
function()
exports . customblips : createCustomBlip ( - 2029.65 , 156.79 , 28.84 , 56 , "49.png" )
exports . customblips : createCustomBlip ( - 2416.11 , 975.36 , 45.30 , 56 , "49.png" )
exports . customblips : createCustomBlip ( 2149.53 , 2748.28 , 10.50 , 56 , "49.png" )
exports . customblips : createCustomBlip ( 2202.44 , 2475.09 , 10.82 , 56 , "49.png" )
exports . customblips : createCustomBlip ( 2114.87 , 919.88 , 10.50 , 56 , "49.png" )
exports . customblips : createCustomBlip ( 2640.27 , 1106.91 , 10.51 , 56 , "49.png" )
exports . customblips : createCustomBlip ( 611.97 , 1694.90 , 6.99 , 56 , "49.png" )
exports . customblips : createCustomBlip ( - 1328.90 , 2677.17 , 49.74 , 56 , "49.png" )
exports . customblips : createCustomBlip ( - 1470.59 , 1863.39 , 32.31 , 56 , "49.png" )
exports . customblips : createCustomBlip ( 1381.37 , 458.11 , 19.65 , 56 , "49.png" )
exports . customblips : createCustomBlip ( 655.36 , - 565.28 , 16.34 , 56 , "49.png" )
exports . customblips : createCustomBlip ( - 1676.75 , 413.22 , 7.18 , 56 , "49.png" )
end
)--]]
local stacje ={
{- 2029.38 , 157.27 , 28.84 - 0.9 },
{- 1681.69 , 407.07 , 7.18 - 0.8 },
{- 1678.54 , 410.89 , 7.18 - 0.8 },
{- 1672.26 , 416.70 , 7.18 - 0.8 },
}
for _ , v in ipairs ( stacje )do
local marker = createMarker ( v [ 1 ], v [ 2 ], v [ 3 ]- 3.5 , "cylinder" , 3 , 255 , 80 , 0 )
local x , y , z = getElementPosition ( marker )
setElementData ( marker , "stacja" , true )
createBlipAttachedTo ( marker , 56 , 2 , 255 , 0 , 0 , 255 , 1 , 275 )
-- exports . customblips : createCustomBlip ( x , y , 20 , 20 , "49.png" )
end
addEventHandler ( "onClientMarkerHit" , resourceRoot ,function( e )
if e == localPlayer then
if getElementData ( source , "stacja" ) then
if getElementType ( e )== "player" then
if getPedOccupiedVehicle ( e ) then
if getElementData ( getPedOccupiedVehicle ( e ), "vehicle:fuel" ) then
guiSetVisible ( bar , true )
guiSetVisible ( barr , true )
guiSetText ( label , "Paliwo : " .. getElementData ( getPedOccupiedVehicle ( e ), "vehicle:fuel" ).. " L | Spacja : Tankowanie" )
guiProgressBarSetProgress ( bar , getElementData ( getPedOccupiedVehicle ( e ), "vehicle:fuel" ))
bindKey ( "space" , "down" , tankuj )
end
end
end
end
end
end )
addEventHandler ( "onClientMarkerLeave" , resourceRoot ,function( e )
if e == localPlayer then
if getElementData ( source , "stacja" ) then
unbindKey ( "space" , "down" , tankuj )
guiSetVisible ( bar , false )
guiSetVisible ( barr , false )
end
end
end )
function tankuj ()
if getPedOccupiedVehicle ( localPlayer ) then
if getElementData ( getPedOccupiedVehicle ( localPlayer ), "vehicle:fuel" )>= 100 then return end
triggerServerEvent ( "TANKUJ" , localPlayer )
end
end
addEvent ( "TANKUJ" , true )
addEventHandler ( "TANKUJ" , root ,function()
if source == localPlayer then
local fuel = getElementData ( getPedOccupiedVehicle ( source ), "vehicle:fuel" )
setElementData ( getPedOccupiedVehicle ( source ), "vehicle:fuel" , fuel + 1 )
guiSetText ( label , "Paliwo : " .. getElementData ( getPedOccupiedVehicle ( source ), "vehicle:fuel" ).. " L | Spacja : Tankowanie" )
guiProgressBarSetProgress ( bar , getElementData ( getPedOccupiedVehicle ( source ), "vehicle:fuel" ))
end
end )
cpaliwo
--[[
Resource : OURGame
Developers : Split < split . programista @ gmail . com >
Copyright < split . programista @ gmail . com > 2015 - 2016
You have no right to use this code without my permission .
]]
-- Kod odpowiadaj ? cy za odejmowanie paliwa oraz dodawanie paliwa
-- Wszelkie inne rzeczy s ? w systemie pojazd ? w // Split
local time = getTickCount ()
local isBike ={[ 509 ]= true ,[ 481 ]= true ,[ 510 ]= true }
local function naliczaj ( veh )
if getTickCount ()- time > 5000 then
time = getTickCount ()
local fuel = getElementData ( veh , "vehicle:fuel" ) or 0
local mileage = getElementData ( veh , "vehicle:mileage" ) or 0
local vx , vy , vz = getElementVelocity ( veh )
local spd =(( vx ^ 2 + vy ^ 2 + vz ^ 2 )^( 0.5 )/ 2 )
if spd > 0 then
fuel = fuel -( spd * 2 )/ 3
setElementData ( veh , "vehicle:fuel" , fuel )
mileage = mileage +( spd )
setElementData ( veh , "vehicle:mileage" , mileage )
end
end
end
addEventHandler ( "onClientRender" , root , function()
local vehicle = getPedOccupiedVehicle ( localPlayer )
if not vehicle then return end
if isBike [ getElementModel ( vehicle )] then return end
if not getVehicleEngineState ( vehicle ) then return end
if getElementData ( vehicle , "vehicle:fuel" ) and getElementData ( vehicle , "vehicle:fuel" ) or getElementData ( vehicle , "vehicle:mileage" ) and getElementData ( vehicle , "vehicle:mileage" ) then
naliczaj ( vehicle )
if getElementData ( vehicle , "vehicle:fuel" )< 1 then
setVehicleEngineState ( vehicle , false )
end
end
end )
Daje piwko i respekt
Wysłany: 2019-02-14, 18:38
Wilq
Wiek: 24 Na forum: 4428 dni Posty: 3410
Piwa : 739
Musia?e? usun?? warunek sprawdzaj?cy ilo?? paliwa, je?li by? wi?kszy lub r?wna? si? 100 funkcja si? ko?czy?a.
Podmie? client:
mojeW , mojeH = 1360 , 768
sW , sH = guiGetScreenSize ()
w , h = ( sW / mojeW ), ( sH / mojeH )
bar = guiCreateProgressBar ( 370 * w , 552.6 * h , 600 * w , 43 * h , false )
guiSetVisible ( bar , false )
label = guiCreateLabel ( 50 * w , 10 * h , 460 * w , 23 * h , "Paliwo : 100 % | Spacja : Tankowanie" , false , bar )
guiLabelSetColor ( label , 00 , 90 , 255 )
guiLabelSetHorizontalAlign ( label , "center" , false )
guiLabelSetVerticalAlign ( label , "center" )
-- x0 , y0 , z0 = getElementPosition ( m100 )
--[[ addEventHandler ( "onClientResourceStart" , getResourceRootElement ( getThisResource ()),
function()
exports . customblips : createCustomBlip ( - 2029.65 , 156.79 , 28.84 , 56 , "49.png" )
exports . customblips : createCustomBlip ( - 2416.11 , 975.36 , 45.30 , 56 , "49.png" )
exports . customblips : createCustomBlip ( 2149.53 , 2748.28 , 10.50 , 56 , "49.png" )
exports . customblips : createCustomBlip ( 2202.44 , 2475.09 , 10.82 , 56 , "49.png" )
exports . customblips : createCustomBlip ( 2114.87 , 919.88 , 10.50 , 56 , "49.png" )
exports . customblips : createCustomBlip ( 2640.27 , 1106.91 , 10.51 , 56 , "49.png" )
exports . customblips : createCustomBlip ( 611.97 , 1694.90 , 6.99 , 56 , "49.png" )
exports . customblips : createCustomBlip ( - 1328.90 , 2677.17 , 49.74 , 56 , "49.png" )
exports . customblips : createCustomBlip ( - 1470.59 , 1863.39 , 32.31 , 56 , "49.png" )
exports . customblips : createCustomBlip ( 1381.37 , 458.11 , 19.65 , 56 , "49.png" )
exports . customblips : createCustomBlip ( 655.36 , - 565.28 , 16.34 , 56 , "49.png" )
exports . customblips : createCustomBlip ( - 1676.75 , 413.22 , 7.18 , 56 , "49.png" )
end
)--]]
local stacje ={
{- 2029.38 , 157.27 , 28.84 - 0.9 },
{- 1681.69 , 407.07 , 7.18 - 0.8 },
{- 1678.54 , 410.89 , 7.18 - 0.8 },
{- 1672.26 , 416.70 , 7.18 - 0.8 },
}
for _ , v in ipairs ( stacje )do
local marker = createMarker ( v [ 1 ], v [ 2 ], v [ 3 ]- 3.5 , "cylinder" , 3 , 255 , 80 , 0 )
local x , y , z = getElementPosition ( marker )
setElementData ( marker , "stacja" , true )
createBlipAttachedTo ( marker , 56 , 2 , 255 , 0 , 0 , 255 , 1 , 275 )
-- exports . customblips : createCustomBlip ( x , y , 20 , 20 , "49.png" )
end
addEventHandler ( "onClientMarkerHit" , resourceRoot ,function( e )
if e == localPlayer then
if getElementData ( source , "stacja" ) then
if getElementType ( e )== "player" then
if getPedOccupiedVehicle ( e ) then
if getElementData ( getPedOccupiedVehicle ( e ), "vehicle:fuel" ) then
guiSetVisible ( bar , true )
guiSetVisible ( barr , true )
guiSetText ( label , "Paliwo : " .. getElementData ( getPedOccupiedVehicle ( e ), "vehicle:fuel" ).. " L | Spacja : Tankowanie" )
guiProgressBarSetProgress ( bar , getElementData ( getPedOccupiedVehicle ( e ), "vehicle:fuel" ))
bindKey ( "space" , "down" , tankuj )
end
end
end
end
end
end )
addEventHandler ( "onClientMarkerLeave" , resourceRoot ,function( e )
if e == localPlayer then
if getElementData ( source , "stacja" ) then
unbindKey ( "space" , "down" , tankuj )
guiSetVisible ( bar , false )
guiSetVisible ( barr , false )
end
end
end )
function tankuj ()
if getPedOccupiedVehicle ( localPlayer ) then
triggerServerEvent ( "TANKUJ" , localPlayer )
end
end
addEvent ( "TANKUJ" , true )
addEventHandler ( "TANKUJ" , root ,function()
if source == localPlayer then
local fuel = getElementData ( getPedOccupiedVehicle ( source ), "vehicle:fuel" )
setElementData ( getPedOccupiedVehicle ( source ), "vehicle:fuel" , fuel + 1 )
guiSetText ( label , "Paliwo : " .. getElementData ( getPedOccupiedVehicle ( source ), "vehicle:fuel" ).. " L | Spacja : Tankowanie" )
guiProgressBarSetProgress ( bar , getElementData ( getPedOccupiedVehicle ( source ), "vehicle:fuel" ))
end
end )
Więcej szczegółów
Wystawiono 1 piw(a):Pyrek24
Wysłany: 2019-02-14, 23:53
Pyrek24
Wiek: 25 Na forum: 3438 dni Posty: 546
Nick w MP: Pyrek
Piwa : 10
Okey mordko, a pokaza? by? mi co edytowa?e? link?, bym si? nauczy?
Wysłany: 2019-02-15, 06:09
ReDsKill
Wiek: 24 Na forum: 3256 dni Posty: 35
Nick w MP: ReDsKill
Piwa : 1581
"Pyrek24" napisał/a :Okey mordko, a pokaza? by? mi co edytowa?e? link?, bym si? nauczy?
Kolega wy?ej usun?? t? linijk?:
if getElementData ( getPedOccupiedVehicle ( localPlayer ), "vehicle:fuel" )>= 100 then return end
Więcej szczegółów
Wystawiono 1 piw(a):Pyrek24
Wysłany: 2019-02-15, 11:07
Pyrek24
Wiek: 25 Na forum: 3438 dni Posty: 546
Nick w MP: Pyrek
Piwa : 10
Okey, ale ja chce pod element dat? np ?e pod vehicle:fuel150 = 150 litr?w paliwa do zatankowania
vehicle:fuel100 = 100 litr?w oraz vehicle:fuel200 = 200litr?w
Wysłany: 2019-02-15, 12:43
Wilq
Wiek: 24 Na forum: 4428 dni Posty: 3410
Piwa : 739
W funkcji tankuj dodaj:
if? getElementData ( getPedOccupiedVehicle ( localPlayer ), "vehicle:fuel" )>=? limit then ?return? end
W miejsce s?owa limit wpisz liczb?, kt?ra b?dzie limitem paliwa.
Musisz zmodyfikowa? progressBar gdy? on ma limit 100, zr?b sobie
Więcej szczegółów
Wystawiono 1 piw(a):Pyrek24
Wysłany: 2019-02-15, 13:12
Pyrek24
Wiek: 25 Na forum: 3438 dni Posty: 546
Nick w MP: Pyrek
Piwa : 10
Okey, ale ja to che pod 3 element daty, ?e jak zamontujesz element dat? vehicle:fuel150 to bd m?g? 150l zatankowa?
Tagi: pojemność :: baku
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: