Kalizman
Wiek: 23 Na forum: 3651 dni Posty: 1394
Piwa : 4619
Witam.
Mam pytanie. Co dorobi? w skrypcie (tzn pracy dorywczej) ?eby dla danej grupy ACL dostawa?a wi?cej?
Za???my, i? ?eby grupa ACL 'Premium' dostawa?a wi?cej za dojechanie do punktu (np. praca autobus?w) np. 19 PLN, a zwyk?y gracz 9 PLN. Moje pytanie skierowa?em do Was bo sie sam zastanawiam jak to zrobi?.
Dam tutaj przyk?adowy kod np. niech b?dzie to praca bus?w z YWG (czy tam YNL).
Oto kod strony clienta:
local districtsBus = {
{- 1735.86 , 935.60 , 24.74 },
{- 1856.70 , 934.15 , 35.02 },
{- 1976.56 , 929.94 , 45.30 },
{- 2010.05 , 889.21 , 45.30 },
{- 2007.90 , 687.83 , 45.49 },
{- 2009.29 , 164.41 , 27.73 },
{- 2008.72 , - 47.67 , 35.36 },
{- 2024.01 , - 311.14 , 35.52 },
{- 2181.06 , - 314.15 , 35.43 },
{- 2205.83 , - 200.09 , 35.47 },
{- 2338.28 , - 188.65 , 35.36 },
{- 2371.03 , - 75.48 , 35.44 },
{- 2017.15 , - 72.04 , 35.36 },
{- 2005.12 , 48.98 , 31.51 },
{- 1991.66 , 138.80 , 27.73 },
{- 2001.05 , 313.72 , 35.21 },
{- 2000.35 , 594.87 , 35.22 },
{- 2000.49 , 844.61 , 45.49 },
{- 1902.01 , 842.09 , 35.21 },
{- 1897.27 , 916.37 , 35.21 },
{- 1795.58 , 921.17 , 24.93 },
{- 1766.85 , 950.46 , 24.93 },
}
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 ( "#919191Zako?czy?e?/a? prac?." , 255 , 255 , 255 , true )
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 , 0 , 0 , 255 )
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 ( "#919191Rozpocz??e?/a? prac?." , 255 , 255 , 255 , true )
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 ( "#919191Zako?czy?e?/a? prac?." , 255 , 255 , 255 , true )
end
end
end )
...a oto kod strony serwera:
createBlip (- 1755.05 , 951.73 , 23.74 , 52 , 2 , 255 , 0 , 0 , 255 , 0 , 400 )
local m1 = createMarker (- 1755.05 , 951.73 , 23.74 , "cylinder" , 4.0 , 255 , 0 , 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 ( "error" , 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 ( 437 , x , y , z , 0.0 , 360.0 , 269.9 )
setElementData ( bus , "zrespilGracz" , el )
setElementData ( bus , "pojazd_paliwo" , 50 )
setElementData ( bus , "pojazd_przebieg" , 1 )
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 )
Za ch?tn? pomoc stawiam zimne piwo oraz respekt.