Wysłany: 2019-01-28, 17:30
serigorro
Wiek: 28 Na forum: 2847 dni Posty: 41
Nick w MP: Igorro
Piwa : 3
Witam, stworzy?em skrypt kt?ry po wej?ciu w marker tworzy poci?g Streak i wagon Brownstreak. S? one ze sob? po??czone. Problem w tym ?e gdy wychodz? z poci?gu albo wychodz? z gry to znika tylko sam poci?g a wagon zostaje. Wie kto? jak naprawi?? Za pomoc piwko
Wysłany: 2019-01-28, 17:49
Wilq
Wiek: 24 Na forum: 4429 dni Posty: 3410
Piwa : 739
Mo?esz spr?bowa? u?y? funkcji
i niszcz zwr?cony wagon (je?li funkcja go zwr?ci) tak samo jak poci?g.
Więcej szczegółów
Wystawiono 1 piw(a):serigorro
Wysłany: 2019-01-28, 19:27
serigorro
Wiek: 28 Na forum: 2847 dni Posty: 41
Nick w MP: Igorro
Piwa : 3
Nie chce dzia?a?
Wysłany: 2019-01-28, 19:47
Wilq
Wiek: 24 Na forum: 4429 dni Posty: 3410
Piwa : 739
W jaki spos?b tworzysz wagon i podpinasz go do poci?gu?
Wystarczy jedna linijka kodu, w mi?dzyczasie mo?esz spr?bowa?:
pobierz elementy przy poci?gu
i w p?tli na powy?ej zwr?conej tabeli usuwaj elementy za pomoc?
Je?li przyczepiony jest tylko jeden element mo?esz u?y?
i wtedy od razu u?y? destroyElement na tym elemencie:
destroyElement ( getElementAttachedTo ( pociag ))
Oczywi?cie nie gwarantuje dzia?ania, warto spr?bowa?.
Więcej szczegółów
Wystawiono 1 piw(a):serigorro
Wysłany: 2019-01-28, 21:00
serigorro
Wiek: 28 Na forum: 2847 dni Posty: 41
Nick w MP: Igorro
Piwa : 3
Dalej nie dzia?a, ?apcie s-side:
Kod: createBlip(-1968.82,111.41,27.69,46,2,255,0,0,255,0,100)
local m1 = createMarker(-1968.82,111.41,27.69-1, "cylinder", 1.5, 35, 142, 35,100)
local t = createElement('text')
setElementPosition(t,-1968.82,111.41,27.69)
setElementData(t,"name","PRACA: Maszynista\nPoci?gu")
local vehs = {}
local code = "Pociagi"
local zone = createColSphere( -1751.31,951.90,25.89, 6 )
addEventHandler("onMarkerHit", m1, function(el, md)
--if getElementData(el, "vehicle_job_owner") then
--return
--end
if getElementData(el,"player:license:pjC") == 1 or getElementData(el,"player:license:pjB") == 1 or getElementData(el,"player:license:pjA") == 1 then
triggerClientEvent(el, "STARTJobTrain", resourceRoot, pociag)
else
outputChatBox("* Nie mo?esz tu pracowa?, poniewa? nie posiadasz prawa jazdy.", el, 255, 0, 0)
cancelEvent()
triggerClientEvent("finishJob", resourceRoot, el)
return
end
if getElementData(el,"player:srp") >= 1000 then
triggerClientEvent(el, "STARTJobTrain", resourceRoot, pociag)
else
outputChatBox("* Nie mo?esz tu pracowa?, poniewa? nie posiadasz 1000 Punkt?w Gold.", el, 255, 0, 0)
cancelEvent()
triggerClientEvent("finishJob", resourceRoot, el)
return
end
if not md or getElementType(el) ~= "player" or getPedOccupiedVehicle(el) then return end
if getElementData(el,"player:job") then return end
if #getElementsWithinColShape(zone,"vehicle") >= 1 then outputChatBox("[#00ff00INFORMACJA#ffffff]Kto? ju? zajmuje to miejsce, poczekaj a? odjedzie.",el,255,255,255,true) return end
local x,y,z = getElementPosition(el)
local pociag = createVehicle(538, -1942.70,157.62,25.72, 0.00, 0, 270 )
local wagon = createVehicle(570, -1942.70,157.62,25.72)
attachTrailerToVehicle(pociag, wagon)
setElementFrozen(el,true)
--setElementData(pociag,"vehicle:desc","Praca dorywcza\n Kierowca autobusu")
setElementData(pociag, "vehicle_job_owner", el)
setElementData(pociag, "vehicle:fuel", 100)
setElementData(pociag, "vehicle:mileage", 0)
setVehicleHandling(pociag, "maxVelocity", 80.0)
setElementData(el,"player:job",code)
--warpPedIntoVehicle( el, autobus)
setTimer(warpPedIntoVehicle,200,1,el,pociag)
setTimer(setElementFrozen,1000,1,el, false)
triggerClientEvent(el, "STARTJobTrain", resourceRoot, pociag)
vehs[el] = pociag
end)
addEvent("STOPJobBus", true)
addEventHandler("STOPJobBus", resourceRoot, function()
local pojazd = getPedOccupiedVehicle(localPlayer)
if pojazd then
destroyElement(pojazd)
end
if getAttachedElements(wagon) then
destroyElement(getElementAttachedTo(pociag))
end
end)
addEvent("destroyVeh", true)
addEventHandler("destroyVeh", getRootElement(),
function()
if vehs[source] then
if isElement(vehs[source]) then destroyElement(vehs[source]) end
end
if getAttachedElements(wagon) then
destroyElement(getElementAttachedTo(pociag))
end
end)
addEvent("onPlayerQuit", true)
addEventHandler ( "onPlayerQuit", getRootElement(), function()
if vehs[source] then
if isElement(vehs[source]) then destroyElement(vehs[source]) end
end
if getAttachedElements(wagon) then
destroyElement(getElementAttachedTo(pociag))
end
end)
Wysłany: 2019-01-28, 21:40
Wilq
Wiek: 24 Na forum: 4429 dni Posty: 3410
Piwa : 739
Mo?esz podes?a? klient?
Mam pewne w?tpliwo?ci co do nazewnictwa eventu po stronie servera, dok?adnie: "STOPJobBus". Wy?ej triggerujesz do klienta "STARTJobTrain", chcia?em wszystko dopasowa? do kodu.
Gotowy kod:
createBlip (- 1968.82 , 111.41 , 27.69 , 46 , 2 , 255 , 0 , 0 , 255 , 0 , 100 )
local m1 = createMarker (- 1968.82 , 111.41 , 26.69 , "cylinder" , 1.5 , 35 , 142 , 35 , 100 )
local t = createElement ( "text" )
setElementPosition ( t , - 1968.82 , 111.41 , 27.69 )
setElementData ( t , "name" , "PRACA: Maszynista\nPoci?gu" )
local pociagi = {}
local wagony = {}
local code = "Pociagi"
local zone = createColSphere (- 1751.31 , 951.90 , 25.89 , 6 )
addEventHandler ( "onMarkerHit" , m1 , function( el , md )
if ( not md ) or ( getElementType ( el ) ~= "player" ) or ( getPedOccupiedVehicle ( el )) then
return
end
if ( getElementData ( el , "player:license:pjC" ) ~= 1 ) or ( getElementData ( el , "player:license:pjB" ) ~= 1 ) or ( getElementData ( el , "player:license:pjA" ) ~= 1 ) then
outputChatBox ( "* Nie mo?esz tu pracowa?, poniewa? nie posiadasz prawa jazdy." , el , 255 , 0 , 0 )
triggerClientEvent ( "finishJob" , resourceRoot , el )
return
end
if getElementData ( el , "player:srp" ) < 1000 then
outputChatBox ( "* Nie mo?esz tu pracowa?, poniewa? nie posiadasz 1000 Punkt?w Gold." , el , 255 , 0 , 0 )
triggerClientEvent ( "finishJob" , resourceRoot , el )
return
end
if getElementData ( el , "player:job" ) then return end
if ( #getElementsWithinColShape(zone, "vehicle") >= 1) then
outputChatBox ( "[#00ff00INFORMACJA#ffffff]Kto? ju? zajmuje to miejsce, poczekaj a? odjedzie." , el , 255 , 255 , 255 , true )
return
end
local x , y , z = getElementPosition ( el )
pociagi [ el ] = createVehicle ( 538 , - 1942.70 , 157.62 , 25.72 , 0.00 , 0 , 270 )
wagony [ el ] = createVehicle ( 570 , - 1942.70 , 157.62 , 25.72 )
attachTrailerToVehicle ( pociagi [ el ], wagony [ el ])
setElementFrozen ( el , true )
-- setElementData ( pociagi [ el ], "vehicle:desc" , "Praca dorywcza\n Kierowca autobusu" )
-- setElementData ( pociagi [ el ], "vehicle_job_owner" , el )
setElementData ( pociagi [ el ], "vehicle:fuel" , 100 )
setElementData ( pociagi [ el ], "vehicle:mileage" , 0 )
setVehicleHandling ( pociagi [ el ], "maxVelocity" , 80.0 )
setElementData ( el , "player:job" , code )
setTimer ( warpPedIntoVehicle , 200 , 1 , el , pociagi [ el ])
setTimer ( setElementFrozen , 1000 , 1 , el , false )
triggerClientEvent ( el , "STARTJobTrain" , resourceRoot , pociagi [ el ])
end )
addEvent ( "STOPJobBus" , true )
addEventHandler ( "STOPJobBus" , resourceRoot , function()
if getAttachedElements ( pociagi [ client ]) then
for _ , v in ipairs ( getAttachedElements ( pociagi [ client ])) do
destroyElement ( v )
end
wagony [ client ] = nil
end
if pociagi [ client ] and isElement ( pociagi [ client ]) then
destroyElement ( pociagi [ client ])
pociagi [ client ] = nil
end
end )
addEvent ( "destroyVeh" , true )
addEventHandler ( "destroyVeh" , getRootElement (), function()
if getAttachedElements ( pociagi [ client ]) then
for _ , v in ipairs ( getAttachedElements ( pociagi [ client ])) do
destroyElement ( v )
end
wagony [ client ] = nil
end
if pociagi [ client ] and isElement ( pociagi [ client ]) then
destroyElement ( pociagi [ client ])
pociagi [ client ] = nil
end
end )
addEvent ( "onPlayerQuit" , true )
addEventHandler ( "onPlayerQuit" , getRootElement (), function()
if getAttachedElements ( pociagi [ source ]) then
for _ , v in ipairs ( getAttachedElements ( pociagi [ source ])) do
destroyElement ( v )
end
wagony [ source ] = nil
end
if pociagi [ source ] and isElement ( pociagi [ source ]) then
destroyElement ( pociagi [ source ])
pociagi [ source ] = nil
end
end )
Powodem mog?o by?:
- najpierw usuwa?e? pojazd, dopiero potem usuwa?e? elementy doczepione do wcze?niej USUNI?TEGO elementu;
- z ka?dym stworzeniem poci?gu i WAGONU warto?ci si??nadpisywa?y, teraz s? to dwie tabele:
wagony
pociagi,
w ka?dej tworzy si? sub-tabela przeznaczona dla jednego gracza pod indeksem zmiennej owego gracza.
Wgraj kod i zobacz czy dzia?a, je?li b?dzie mo?liwo?? - prosz? o podes?anie klienta.
Do kodu wprowadzi?em r?wnie? ?ad (tabulatory).
Więcej szczegółów
Wystawiono 1 piw(a):serigorro
Wysłany: 2019-01-28, 22:02
serigorro
Wiek: 28 Na forum: 2847 dni Posty: 41
Nick w MP: Igorro
Piwa : 3
Nadal nie dzia?a, z klienta nie uzyskasz du?o informacji ale prosz?:
Kod: --[[
Praca busa
]]--
local code = "Pociagi"
local districtsTrain
local districtsTrain = {
{1812.61,-1890.64,14.54},
{1819.40,-1912.29,14.53},
{1872.78,-1934.10,14.52},
{1940.16,-1934.15,14.52},
{1959.78,-1960.39,14.89},
{1959.53,-2020.01,14.53},
{1959.17,-2096.39,14.53},
{2003.22,-2112.30,14.51},
{2071.59,-2112.30,14.47},
{2152.19,-2126.66,14.47},
{2193.43,-2163.11,14.52},
{2240.48,-2211.24,14.46},
{2281.89,-2251.83,14.33},
{2301.38,-2262.51,14.53},
{2324.90,-2245.30,14.48},
{2383.97,-2191.99,14.51},
{2460.19,-2169.35,14.58},
{2537.76,-2168.44,14.43},
{2634.17,-2168.51,12.27},
{2742.95,-2166.00,12.07},
{2811.57,-2125.64,12.07},
{2835.28,-2014.85,12.07},
{2835.68,-1936.85,12.08},
{2837.75,-1859.30,12.05},
{2847.75,-1776.56,12.01},
{2861.91,-1705.47,12.01},
{2889.56,-1612.32,12.01},
{2911.49,-1538.56,12.01},
{2923.99,-1429.49,12.01},
{2905.74,-1302.46,12.02},
{2889.86,-1183.74,12.02},
{2885.97,-1066.08,12.01},
{2888.73,-951.08,12.01},
{2891.91,-835.18,12.01},
{2894.81,-754.47,11.97},
{2898.38,-679.03,11.97},
{2900.07,-567.48,13.11},
{2872.41,-460.55,11.34},
{2842.93,-395.43,10.08},
{2836.36,-319.02,8.61},
{2800.59,-240.00,12.77},
{2857.55,-171.09,19.96},
{2876.89,-99.50,23.60},
{2879.61,-16.23,17.90},
{2815.82,45.09,21.19},
{2712.69,46.33,24.66},
{2629.30,45.74,27.39},
{2482.84,44.33,27.48},
{2406.73,43.73,27.42},
{2396.66,73.83,27.46},
{2354.60,92.53,27.47},
{2346.88,112.14,27.48},
{2346.43,189.57,27.47},
{2307.02,214.37,25.88},
{2216.12,226.44,15.66},
{2117.18,248.80,17.46},
{2032.30,305.34,27.91},
{1964.13,353.51,24.23},
{1865.12,366.60,20.88},
{1729.76,388.07,20.93},
{1605.31,385.12,21.02},
{1440.91,417.10,21.02},
{1322.08,476.17,21.02},
{1225.52,524.68,21.02},
{1109.94,577.45,21.02},
{1022.41,485.98,21.03},
{955.99,387.07,21.02},
{860.76,352.25,21.02},
{767.14,329.43,21.02},
{643.93,313.86,21.02},
{561.69,278.79,18.22},
{491.01,219.66,13.45},
{412.27,152.83,9.22},
{335.39,92.97,5.05},
{268.90,58.26,3.23},
{231.44,11.61,3.57},
{231.63,-71.48,2.57},
{231.67,-163.06,2.57},
{231.44,-259.27,2.55},
{206.33,-308.69,2.61},
{240.20,-369.62,9.51},
{355.81,-396.32,20.29},
{437.27,-408.20,28.92},
{510.05,-416.99,29.76},
{616.02,-416.13,19.16},
{639.00,-473.10,17.33},
{599.01,-497.56,17.32},
{626.58,-530.84,17.33},
{639.03,-565.00,17.33},
{664.18,-600.46,17.32},
{679.14,-641.49,17.33},
{680.97,-747.92,21.17},
{691.93,-837.83,44.26},
{769.32,-907.73,44.41},
{793.19,-1020.89,27.53},
{824.99,-1044.51,26.09},
{895.12,-986.54,38.30},
{982.69,-968.21,40.76},
{1123.46,-953.23,43.72},
{1255.46,-934.01,43.71},
{1385.91,-943.83,35.33},
{1476.93,-957.65,37.27},
{1614.76,-974.21,39.32},
{1723.33,-989.32,38.54},
{1837.68,-1013.35,37.26},
{1961.22,-1028.24,34.81},
{2091.26,-1059.32,29.70},
{2193.49,-1115.44,26.11},
{2254.20,-1145.82,27.61},
{2301.19,-1178.86,26.89},
{2301.56,-1281.36,24.98},
{2301.66,-1373.88,25.00},
{2328.97,-1384.28,24.97},
{2340.83,-1416.63,24.94},
{2340.33,-1484.17,24.97},
{2340.19,-1573.91,24.97},
{2341.57,-1639.09,16.38},
{2285.80,-1656.29,16.07},
{2228.97,-1648.82,16.44},
{2188.81,-1672.81,15.46},
{2183.63,-1737.48,14.51},
{2123.57,-1749.69,14.55},
{2013.92,-1749.99,14.52},
{1897.35,-1750.08,14.52},
{1838.90,-1749.76,14.51},
{1820.08,-1776.66,14.52},
{1819.60,-1835.03,14.56},
{1811.75,-1889.64,14.52},
{1789.36,-1911.38,14.55},
}
local districtsTrain2 = {
{-1733.64,917.26,24.13},
{-1717.35,902.06,24.13},
{-1716.75,878.72,24.14},
{-1717.41,830.37,24.13},
{-1717.47,786.37,24.12},
{-1717.43,741.62,24.12},
{-1717.38,691.34,24.12},
{-1717.34,648.67,24.13},
{-1723.84,620.53,24.11},
{-1770.04,608.13,28.08},
{-1825.25,609.15,34.42},
{-1881.57,609.40,34.42},
{-1932.01,608.53,34.40},
{-1977.80,608.80,34.41},
{-2007.15,599.02,34.42},
{-2023.33,567.90,34.41},
{-2052.18,569.21,34.41},
{-2085.86,568.99,34.41},
{-2132.67,569.11,34.41},
{-2174.05,569.43,34.41},
{-2218.92,568.64,34.41},
{-2277.60,568.97,34.41},
{-2329.60,569.45,28.56},
{-2375.52,569.00,24.13},
{-2413.49,568.38,24.13},
{-2474.61,569.06,17.55},
{-2512.59,568.66,13.86},
{-2543.88,569.20,13.85},
{-2577.43,569.59,13.85},
{-2629.37,569.21,13.85},
{-2671.04,569.10,13.85},
{-2715.22,569.60,13.84},
{-2752.82,563.57,13.79},
{-2751.64,545.81,13.06},
{-2736.01,522.49,9.71},
{-2720.33,504.31,7.09},
{-2710.42,485.10,4.31},
{-2740.27,468.78,4.00},
{-2763.52,469.26,4.61},
{-2798.67,468.53,4.70},
{-2833.81,467.81,3.72},
{-2845.27,492.66,3.76},
{-2835.62,519.56,4.18},
{-2825.65,549.01,4.64},
{-2821.80,590.02,4.84},
{-2821.10,633.40,8.66},
{-2823.69,670.01,16.88},
{-2837.40,703.23,24.65},
{-2856.88,731.12,29.18},
{-2865.87,756.10,31.04},
{-2861.96,787.09,34.76},
{-2839.06,825.29,40.88},
{-2821.37,871.03,43.29},
{-2822.38,919.53,43.29},
{-2829.40,967.64,43.30},
{-2857.41,997.74,40.37},
{-2872.41,1019.86,36.50},
{-2879.43,1072.54,30.36},
{-2879.97,1114.63,24.55},
{-2877.83,1178.42,8.92},
{-2858.63,1220.62,4.89},
{-2830.04,1251.23,4.83},
{-2802.22,1276.16,4.84},
{-2764.39,1286.32,5.58},
{-2714.45,1285.23,6.44},
{-2674.51,1286.02,6.43},
{-2630.76,1299.50,6.44},
{-2600.75,1326.56,6.42},
{-2559.79,1361.81,6.41},
{-2518.40,1373.48,6.42},
{-2455.80,1373.60,6.43},
{-2383.63,1374.22,6.49},
{-2341.50,1369.91,6.40},
{-2294.28,1341.39,6.46},
{-2223.52,1328.67,6.43},
{-2165.92,1328.90,6.43},
{-2114.89,1328.45,6.42},
{-2058.65,1306.03,6.54},
{-1992.40,1283.75,6.42},
{-1941.70,1284.51,6.42},
{-1895.99,1304.01,6.44},
{-1857.67,1338.59,6.42},
{-1821.30,1355.64,6.42},
{-1782.14,1349.96,6.42},
{-1735.06,1313.87,6.42},
{-1697.87,1276.01,6.43},
{-1638.32,1216.39,6.43},
{-1611.72,1174.45,6.48},
{-1607.77,1111.91,6.42},
{-1607.40,1042.99,6.43},
{-1598.30,1001.27,6.43},
{-1566.49,954.96,6.43},
{-1588.64,933.22,6.93},
{-1628.99,933.46,10.93},
{-1677.41,932.17,24.14},
{-1743.14,934.15,24.13},
{-1776.26,942.53,24.12},
{-1767.85,951.71,24.13},
}
local districtsTrain3 = {
{-1741.67,934.68,24.12},
{-1776.24,934.18,24.14},
{-1818.83,933.44,24.33},
{-1881.43,934.08,34.92},
{-1928.69,934.18,37.21},
{-1962.81,933.64,43.36},
{-1988.44,933.25,44.69},
{-2002.15,950.19,44.69},
{-2000.05,994.57,49.15},
{-2000.52,1030.92,55.08},
{-2010.83,1078.30,54.98},
{-2037.33,1080.04,54.96},
{-2074.07,1080.18,54.95},
{-2113.32,1079.78,54.96},
{-2162.82,1080.10,54.97},
{-2218.84,1080.06,54.97},
{-2281.42,1080.02,54.97},
{-2327.41,1083.40,54.95},
{-2383.02,1102.79,54.98},
{-2432.29,1115.87,54.98},
{-2487.41,1117.84,54.97},
{-2540.04,1121.23,54.96},
{-2584.04,1122.59,54.91},
{-2590.74,1098.62,55.51},
{-2600.32,1080.72,59.67},
{-2605.00,1058.50,65.72},
{-2607.52,1034.10,72.46},
{-2608.03,1016.94,77.03},
{-2594.01,1002.63,77.52},
{-2572.20,1003.03,77.53},
{-2545.96,1002.95,77.53},
{-2527.97,992.58,77.51},
{-2528.54,964.40,72.05},
{-2528.13,937.40,64.26},
{-2527.84,915.50,64.22},
{-2503.45,906.40,64.14},
{-2476.48,906.38,62.53},
{-2440.79,906.71,53.47},
{-2411.21,906.94,44.84},
{-2390.30,896.12,44.68},
{-2389.65,859.31,41.54},
{-2390.52,817.22,34.28},
{-2390.07,777.38,34.41},
{-2389.86,735.78,34.41},
{-2389.76,697.76,34.41},
{-2389.96,652.51,34.41},
{-2390.16,609.97,29.50},
{-2388.19,554.78,24.13},
{-2375.47,507.93,28.46},
{-2353.86,469.19,30.33},
{-2334.90,444.72,33.30},
{-2327.23,404.25,34.41},
{-2348.62,383.39,34.40},
{-2373.60,356.71,34.41},
{-2398.87,321.69,34.41},
{-2413.57,291.35,34.37},
{-2418.09,251.65,34.41},
{-2418.80,205.45,34.40},
{-2421.74,162.00,34.41},
{-2423.41,105.28,34.41},
{-2423.21,57.51,34.41},
{-2422.96,-0.52,34.56},
{-2423.74,-46.45,34.56},
{-2400.95,-72.96,34.57},
{-2360.30,-72.24,34.56},
{-2313.09,-72.50,34.56},
{-2270.53,-72.24,34.55},
{-2227.31,-72.29,34.56},
{-2183.45,-72.25,34.56},
{-2169.03,-93.14,34.57},
{-2169.24,-134.80,34.56},
{-2195.69,-187.55,34.55},
{-2247.36,-187.26,34.56},
{-2251.67,-162.38,34.58},
{-2251.43,-127.83,34.56},
{-2251.52,-89.59,34.57},
{-2251.83,-57.39,34.57},
{-2251.33,-23.44,34.56},
{-2251.37,7.06,34.56},
{-2250.77,52.32,34.57},
{-2250.28,99.65,34.56},
{-2249.49,147.61,34.56},
{-2249.82,199.64,34.57},
{-2249.71,254.18,34.55},
{-2271.55,384.06,33.75},
{-2262.46,408.58,34.41},
{-2235.89,440.27,34.41},
{-2225.05,469.27,34.41},
{-2224.75,522.26,34.41},
{-2225.12,557.41,34.40},
{-2186.97,562.98,34.41},
{-2124.51,563.37,34.41},
{-2050.84,562.27,34.41},
{-2001.11,563.20,34.43},
{-2001.75,584.94,34.40},
{-2000.95,631.02,36.43},
{-2001.34,689.85,44.69},
{-2001.18,742.93,44.67},
{-2001.17,800.62,44.72},
{-2001.17,854.02,44.69},
{-2001.17,895.99,44.69},
{-1988.86,917.81,44.69},
{-1955.85,916.91,42.08},
{-1921.11,916.48,35.84},
{-1880.52,917.25,34.40},
{-1830.54,917.31,27.70},
{-1805.92,918.44,24.13},
{-1769.96,948.74,24.13},
}
local jobTarget
local jobMarker
local jobVehicle -- wydaje mi si? ?e chyba tu jest problem
local maxTarget = #districtsTrain
function finishJob()
if jobMarker and isElement(jobMarker) then
destroyElement(jobMarker)
jobMarker = nil
end
if jobTarget and isElement(jobTarget) then
destroyElement(jobTarget)
jobTarget = nil
jobTarget = 0
end
if getElementData(localPlayer,"player:job") == code then
setElementData(localPlayer,"player:job",false)
end
triggerServerEvent("destroyVeh", localPlayer)
end
addEventHandler ( "onClientPlayerWasted", getLocalPlayer(),finishJob)
addEvent("finishJob",true)
addEventHandler("finishJob",root,function(plr)
if plr ~= localPlayer then return end
finishJob()
end)
function trainDriver(el, md)
if el ~= localPlayer or not md then return end
if jobTarget > maxTarget and getPedOccupiedVehicle(el) then return end
if jobTarget == maxTarget and not getPedOccupiedVehicle(el) then return end
if jobTarget == #districtsTrain then
finishJob()
playSoundFrontEnd(2)
--outputChatBox("#ffffff[#41E0FFInformacja#ffffff]#41E0FF Zako?czy?e?/a? prac?.",255,255,255,true)
addEventHandler("onClientRender",root,render3)
setTimer(renderstop3,2000,1)
else
kasa = math.random(4,10)
showMarker()
playSoundFrontEnd(12)
if getElementData(el,"player:premium") then
--outputChatBox("* Zidentyfikowa?e?(a?) punkt i otrzymujesz 100 PLN.")
triggerServerEvent("givePlayerMoney", el, kasa*1.25, 0)
setElementData(el,"player:srp", getElementData(el,"player:srp")+math.random(1,6))
addEventHandler("onClientRender",root,render2)
setTimer(renderstop2,1000,1)
else
--outputChatBox("* Zidentyfikowa?e?(a?) punkt i otrzymujesz 75 PLN.")
triggerServerEvent("givePlayerMoney", el, kasa, 0)
setElementData(el,"player:srp", getElementData(el,"player:srp")+math.random(0,3))
addEventHandler("onClientRender",root,render2)
setTimer(renderstop2,1000,1)
end
end
end
function showMarker()
if jobMarker and isElement(jobMarker) then
destroyElement(jobMarker)
jobMarker = nil
end
jobTarget = jobTarget + 1
jobMarker = createMarker(districtsTrain[jobTarget][1], districtsTrain[jobTarget][2], districtsTrain[jobTarget][3], "checkpoint", 4, 0, 255, 255)
if districtsTrain[jobTarget+1] then
ile = districtsTrain[jobTarget+1]
setMarkerTarget(jobMarker, ile[1], ile[2], ile[3])
end
addEventHandler("onClientMarkerHit", jobMarker, trainDriver)
end
addEvent("STARTJobTrain", true)
addEventHandler("STARTJobTrain", resourceRoot, function(veh)
trasa = math.random(1,3)
if trasa==1 then
districtsTrain = districtsTrain
elseif trasa==2 then
districtsTrain = districtsTrain2
elseif trasa==3 then
districtsTrain = districtsTrain3
end
maxTarget = #districtsTrain
addEventHandler("onClientRender",root,render1)
setTimer(renderstop1,4000,1)
--outputChatBox("* Rozpocz??e?/a? prac? StreetView.")
--outputChatBox("* Je?dzij po punktach i uzupe?niaj map?.")
jobVehicle = veh
jobTarget = 0
showMarker()
end)
addEventHandler("onClientResourceStop", resourceRoot, function()
if jobVehicle and getElementData(localPlayer, "player:job") then
setElementData(localPlayer, "player:job", false)
end
end)
addEventHandler("onClientVehicleExit", resourceRoot, function(plr, seat)
if seat == 0 then
if plr == localPlayer then
finishJob()
--outputChatBox("#ffffff[#41E0FFInformacja#ffffff]#41E0FF Zako?czy?e? prac?",255,255,255,true)
addEventHandler("onClientRender",root,render3)
setTimer(renderstop3,2000,1)
end
end
end)
local screenW, screenH = guiGetScreenSize()
function render1()
dxDrawText("Rozpocz??e?/a? prac? Kierowcy Autobusu. \n Przydzielono ci lini? nr:"..trasa, screenW * 0.3656, screenH * 1.3553, screenW * 0.6273, screenH * 0.3193, tocolor(255, 255, 255, 255), 1.5, "default", "center", "center", false, false, false, false, false)
end
function render2()
dxDrawText("Za przejazd otrzymujesz "..kasa.."PLN", screenW * 0.3656, screenH * 1.3553, screenW * 0.6273, screenH * 0.3193, tocolor(255, 255, 255, 255), 1.5, "default", "center", "center", false, false, false, false, false)
end
function render3()
dxDrawText("Zako?czy?e?/a? prac? kierowcy autobusu.", screenW * 0.3656, screenH * 1.3553, screenW * 0.6273, screenH * 0.3193, tocolor(255, 255, 255, 255), 1.5, "default", "center", "center", false, false, false, false, false)
end
function render4()
dxDrawText("Zako?czy?e?/a? prace kierowcy autobusu.", screenW * 0.3656, screenH * 1.3553, screenW * 0.6273, screenH * 0.3193, tocolor(255, 255, 255, 255), 1.5, "default", "center", "center", false, false, false, false, false)
end
function render5()
dxDrawText("Posiadasz ju? aktywn? prac?.", screenW * 0.3656, screenH * 1.3553, screenW * 0.6273, screenH * 0.3193, tocolor(255, 255, 255, 255), 1.5, "default", "center", "center", false, false, false, false, false)
end
function renderstop1()
removeEventHandler("onClientRender",root,render1)
end
function renderstop2()
removeEventHandler("onClientRender",root,render2)
end
function renderstop3()
removeEventHandler("onClientRender",root,render3)
end
function renderstop4()
removeEventHandler("onClientRender",root,render4)
end
function renderstop5()
removeEventHandler("onClientRender",root,render5)
end
Wysłany: 2019-01-28, 22:25
Wilq
Wiek: 24 Na forum: 4429 dni Posty: 3410
Piwa : 739
Podmie? kod i daj zna?, czy poci?g si? usuwa i czy wagon si? usuwa:
SERVER
createBlip (- 1968.82 , 111.41 , 27.69 , 46 , 2 , 255 , 0 , 0 , 255 , 0 , 100 )
local m1 = createMarker (- 1968.82 , 111.41 , 26.69 , "cylinder" , 1.5 , 35 , 142 , 35 , 100 )
local t = createElement ( "text" )
setElementPosition ( t , - 1968.82 , 111.41 , 27.69 )
setElementData ( t , "name" , "PRACA: Maszynista\nPoci?gu" )
local pociagi = {}
local wagony = {}
local zone = createColSphere (- 1751.31 , 951.90 , 25.89 , 6 )
addEventHandler ( "onMarkerHit" , m1 , function( el , md )
if ( not md ) or ( getElementType ( el ) ~= "player" ) or ( getPedOccupiedVehicle ( el )) then
return
end
if ( getElementData ( el , "player:license:pjC" ) ~= 1 ) or ( getElementData ( el , "player:license:pjB" ) ~= 1 ) or ( getElementData ( el , "player:license:pjA" ) ~= 1 ) then
outputChatBox ( "* Nie mo?esz tu pracowa?, poniewa? nie posiadasz prawa jazdy." , el , 255 , 0 , 0 )
triggerClientEvent ( "finishJob" , resourceRoot , el )
return
end
if getElementData ( el , "player:srp" ) < 1000 then
outputChatBox ( "* Nie mo?esz tu pracowa?, poniewa? nie posiadasz 1000 Punkt?w Gold." , el , 255 , 0 , 0 )
triggerClientEvent ( "finishJob" , resourceRoot , el )
return
end
if getElementData ( el , "player:job" ) then return end
if ( #getElementsWithinColShape(zone, "vehicle") >= 1) then
outputChatBox ( "[#00ff00INFORMACJA#ffffff]Kto? ju? zajmuje to miejsce, poczekaj a? odjedzie." , el , 255 , 255 , 255 , true )
return
end
local x , y , z = getElementPosition ( el )
pociagi [ el ] = createVehicle ( 538 , - 1942.70 , 157.62 , 25.72 , 0.00 , 0 , 270 )
wagony [ el ] = createVehicle ( 570 , - 1942.70 , 157.62 , 25.72 )
attachTrailerToVehicle ( pociagi [ el ], wagony [ el ])
setElementFrozen ( el , true )
setElementData ( pociagi [ el ], "vehicle:fuel" , 100 )
setElementData ( pociagi [ el ], "vehicle:mileage" , 0 )
setVehicleHandling ( pociagi [ el ], "maxVelocity" , 80.0 )
setElementData ( el , "player:job" , "Pociagi" )
setTimer ( warpPedIntoVehicle , 200 , 1 , el , pociagi [ el ])
setTimer ( setElementFrozen , 1000 , 1 , el , false )
triggerClientEvent ( el , "STARTJobTrain" , resourceRoot , pociagi [ el ])
end )
addEvent ( "destroyVeh" , true )
addEventHandler ( "destroyVeh" , getRootElement (), function()
if wagony [ client ] and isElement ( wagony [ client ]) then
destroyElement ( wagony [ client ])
wagony [ client ] = nil
end
if pociagi [ client ] and isElement ( pociagi [ client ]) then
destroyElement ( pociagi [ client ])
pociagi [ client ] = nil
end
end )
addEventHandler ( "onPlayerQuit" , getRootElement (), function()
if wagony [ source ] and isElement ( wagony [ source ]) then
destroyElement ( wagony [ source ])
wagony [ source ] = nil
end
if pociagi [ source ] and isElement ( pociagi [ source ]) then
destroyElement ( pociagi [ source ])
pociagi [ source ] = nil
end
end )
Więcej szczegółów
Wystawiono 1 piw(a):serigorro
Wysłany: 2019-01-28, 22:40
serigorro
Wiek: 28 Na forum: 2847 dni Posty: 41
Nick w MP: Igorro
Piwa : 3
Dzia?a, dzi?ki wielkie trzymaj zas?u?one piwa i rep
Tagi: pociąg :: trailery
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: