STOPseba
Emeryt na scenie MTA
Wiek: 25 Na forum: 3771 dni Posty: 448
Nick w MP: STOPseba
Piwa : 5014
Witam chcia?bym si? dowiedzie? jak zrobi? ?eby gracz kt?ry ma np 100rp m?g? pracowa? na busach a gracz kt?ry ma mniej nie m?g?.
Przyk?ad pracy:
local m1 = createMarker ( 1799.74 ,- 1934.21 , 13.49 - 0.9 , "cylinder" , 1 , 0 , 255 , 0 )
vehs = {}
function removePreviousVehicles ( plr )
for i , v in ipairs ( getElementsByType ( "vehicle" , resourceRoot )) do
local sby = getElementData ( v , "zrespilGracz" )
if sby and sby == plr and getPedOccupiedVehicle ( plr ) ~= v then
destroyElement ( v )
end
end
end
addEventHandler ( "onMarkerHit" , m1 , function( el , md )
if getElementData ( el , "zrespilGracz" ) then
outputChatBox ( "praca w trakcie poprawek" , el )
return
end
if not md or getElementType ( el ) ~= "player" or getPedOccupiedVehicle ( el ) then return end
local x , y , z = getElementPosition ( el )
local bus = createVehicle ( 431 , 1795.26 ,- 1930.91 , 13.49 , 359.5 , 360.0 , 0.5 )
setElementData ( bus , "zrespilGracz" , el )
setElementData ( bus , "vehicle:fuel" , 100 )
setElementData ( bus , "vehicle:mileage" , 69000 )
setElementData ( bus , "vehicle:desc" , "Praca Dorywcza\nKierowca Autobusu\nCel:Gie?da" )
warpPedIntoVehicle ( el , bus )
removePreviousVehicles ( el )
triggerClientEvent ( el , "STARTJobBus" , resourceRoot , bus )
vehs [ el ] = bus
end )
addEvent ( "STOPJobBus" , true )
addEventHandler ( "STOPJobBus" , resourceRoot , function()
local pojazd = getPedOccupiedVehicle ( localPlayer )
if pojazd then
destroyElement ( pojazd )
end
end )
addEvent ( "destroyVeh" , true )
addEventHandler ( "destroyVeh" , getRootElement (),
function()
if vehs [ source ] then
if isElement ( vehs [ source ]) then destroyElement ( vehs [ source ]) end
end
end )
addEvent ( "STOPJobBus" , true )
addEventHandler ( "STOPJobBus" , resourceRoot , function()
local pojazd = getPedOccupiedVehicle ( localPlayer )
if pojazd then
destroyElement ( pojazd )
end
end )
addEvent ( "destroyVeh" , true )
addEventHandler ( "destroyVeh" , getRootElement (),
function()
if vehs [ source ] then
if isElement ( vehs [ source ]) then destroyElement ( vehs [ source ]) end
end
end )
addEvent ( "onPlayerQuit" , true )
addEventHandler ( "onPlayerQuit" , getRootElement (), function()
if vehs [ source ] then
if isElement ( vehs [ source ]) then destroyElement ( vehs [ source ]) end
end
end )
local t = createElement ( "text" )
setElementData ( t , "scale" , 1.2 )
setElementData ( t , "name" , "Praca Kierowcy Autobusu\n10PLN za przystanek!" )
setElementPosition ( t , 1799.74 ,- 1934.21 , 13.49 )
createBlip ( 1799.74 ,- 1934.21 , 13.49 , 19 , 2 , 0 , 255 , 0 , 255 , 0 , 99999 )
local districtsBus = {
{ 1817.91 ,- 1917.31 , 13.38 },
{ 1916.32 ,- 1936.04 , 13.38 },
{ 1985.46 ,- 1936.26 , 13.38 },
{ 2085.96 ,- 1915.64 , 13.38 },
{ 2085.63 ,- 1852.60 , 13.38 },
{ 2085.70 ,- 1806.89 , 13.38 },
{ 2114.49 ,- 1693.73 , 13.38 },
{ 2116.98 ,- 1581.85 , 25.96 },
{ 2116.56 ,- 1442.89 , 23.83 },
{ 2086.14 ,- 1380.24 , 23.83 },
{ 2076.03 ,- 1281.49 , 23.83 },
{ 2075.67 ,- 1172.02 , 23.66 },
{ 2019.02 ,- 1131.67 , 24.79 },
{ 1927.82 ,- 1131.63 , 25.01 },
{ 1862.59 ,- 1157.71 , 23.69 },
{ 1795.70 ,- 1170.01 , 23.65 },
{ 1607.47 ,- 1156.67 , 23.91 },
{ 1514.15 ,- 1156.63 , 23.91 },
{ 1450.54 ,- 1265.07 , 13.38 },
{ 1450.02 ,- 1418.88 , 13.38 },
{ 1425.29 ,- 1573.70 , 13.36 },
{ 1425.43 ,- 1671.88 , 13.38 },
{ 1429.87 ,- 1736.51 , 13.38 },
{ 1629.79 ,- 1736.56 , 13.38 },
{ 1781.05 ,- 1736.39 , 13.38 },
{ 1817.39 ,- 1788.47 , 13.38 },
{ 1817.38 ,- 1870.58 , 13.41 },
}
local jobTarget
local jobMarker
local jobVehicle
local maxTarget = #districtsBus
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
triggerServerEvent ( "destroyVeh" , localPlayer )
end
function busDriver ( 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 == #districtsBus then
finishJob ()
playSoundFrontEnd ( 5 )
outputChatBox ( "Rozpocz??e? Prace Kierowyc Autobusu.Zarobki 10 PLN Za Przystanek!" )
else
showMarker ()
playSoundFrontEnd ( 12 )
triggerServerEvent ( "givePlayerMoney" , localPlayer , 5 , 0 )
end
end
function showMarker ()
if jobMarker and isElement ( jobMarker ) then
destroyElement ( jobMarker )
jobMarker = nil
end
jobTarget = jobTarget + 1
jobMarker = createMarker ( districtsBus [ jobTarget ][ 1 ], districtsBus [ jobTarget ][ 2 ], districtsBus [ jobTarget ][ 3 ], "checkpoint" , 4 , 128 , 255 , 0 )
if districtsBus [ jobTarget + 1 ] then
ile = districtsBus [ jobTarget + 1 ]
setMarkerTarget ( jobMarker , ile [ 1 ], ile [ 2 ], ile [ 3 ])
end
addEventHandler ( "onClientMarkerHit" , jobMarker , busDriver )
end
addEvent ( "STARTJobBus" , true )
addEventHandler ( "STARTJobBus" , resourceRoot , function( veh )
outputChatBox ( "Rozpocz??e? Prace Kierowyc Autobusu.Zarobki 10 PLN Za Przystanek!" )
jobVehicle = veh
jobTarget = 0
showMarker ()
end )
addEventHandler ( "onClientResourceStop" , resourceRoot , function()
if jobVehicle and getElementData ( localPlayer , "gracz_praca" ) then
setElementData ( localPlayer , "gracz_praca" , false )
end
end )
addEventHandler ( "onClientVehicleExit" , resourceRoot , function( plr , seat )
if seat == 0 then
if plr == localPlayer then
finishJob ()
outputChatBox ( "Gratuluje Zako?czy?e? Prace Kierowcy Autobusu!" )
end
end
end )