Wysłany: 2014-10-26, 13:26
SzczepSon1204
Wiek: 29 Na forum: 4247 dni Posty: 24
Nick w MP: SzczepSon
Witam, mam pytanie odno?nie pracy.
Mam prac?, kt?ra dzia?a:
jest marker, wchodz? w niego to mnie teleportuje do tira. Podczepiam naczep? i jad? do celu. W lokalizacji docelowej jest drugi marker kt?ry niszczy mi tira i naczep? oraz daje kas?.
Problem polega na tym, ?e marker pocz?tkowy si? nie odnawia.
Blip owszem, pojawia si? na mapie w lokalizacji pocz?tkowej. Ale nie ma ju? tam markera...
Skrypt jest ca?kowicie po stronie servera.
Ca?y skrypt posiadam z community, bo stwierdzi?em, ?e na gotowych b?dzie mi si? ?atwiej uczy?(ostatnim razem jak pisa?em od zera skrypt, to nie do ko?ca dzia?a? na hostowanym servie. Ale to inny temat).
-- // Made by: MoPoMaN
-- //Tables and other stuff
tableLocationsX = {}
tableLocationsY = {}
tableLocationsZ = {}
tableMoney = {}
locationCount = 4
-- //Location 1
tableLocationsX [ 1 ] = 2253.7
tableLocationsY [ 1 ] = - 84.0
tableLocationsZ [ 1 ] = 25.3
tableMoney [ 1 ] = 500
-- //Location 2
tableLocationsX [ 2 ] = 1093.7
tableLocationsY [ 2 ] = - 931.6
tableLocationsZ [ 2 ] = 41.9
tableMoney [ 2 ] = 550
-- //Location3
tableLocationsX [ 3 ] = - 47.3
tableLocationsY [ 3 ] = - 1137.5
tableLocationsZ [ 3 ] = 0.07
tableMoney [ 3 ] = 500
-- //Location4
tableLocationsX [ 4 ] = 1198
tableLocationsY [ 4 ] = - 1828
tableLocationsZ [ 4 ] = 12.3
tableMoney [ 4 ] = 350
function startScript ()
-- Marker
marker = createMarker ( 2177 , - 2258 , 13.7 , "cylinder" , 1.1 , 255 , 90 , 0 , 255 )
addEventHandler ( "onMarkerHit" , marker , startMission )
-- Objects and Ped
ped = createPed ( 302 , 2176 , - 2259 , 13.7 )
tableObj = createObject ( 2205 , 2173 , - 2259 , 13.7 )
chairObj = createObject ( 2309 , 2174 , - 2259 , 13.7 )
addEventHandler ( "onPedWasted" , getRootElement (), respawnPed )
-- Blip
startBlip = createBlip ( 2177 , - 2258 , 13.7 , 51 )
end
function startMission ( hitElement )
if getElementType ( hitElement ) == "player" then
-- Check team
-- local team = getPlayerTeam ( hitElement )
-- if getTeamName ( team ) ~= "Workers" then
-- local teamName = getTeamName ( team )
-- outputChatBox ( "#ffaa00// #ffffffOnly workers can drive trucks! Press F2 to change the team." , hitElement , 255 , 255 , 255 , true )
-- return false
-- else
-- createThings
TIR = createVehicle ( 514 , 2199.16 , - 2303.61 , 15.46 , 0 , 0 , 135 )
przyczepa = createVehicle ( 435 , 2206.33 , - 2296 , 15.46 , 0 , 0 , 135 )
randomLoc = math . random ( 1 , locationCount )
finish = createMarker ( tableLocationsX [ randomLoc ], tableLocationsY [ randomLoc ], tableLocationsZ [ randomLoc ], "cylinder" , 3 , 0 , 200 , 55 , 255 , hitElement )
blip = createBlip ( tableLocationsX [ randomLoc ], tableLocationsY [ randomLoc ], tableLocationsZ [ randomLoc ], 0 , 2 , 255 , 0 , 0 , 255 , 0 , 10000 , hitElement )
-- addEventHandlers
addEventHandler ( "onTrailerDetach" , getRootElement (), trailerDetach )
addEventHandler ( "onVehicleExit" , getRootElement (), vehicleExit )
addEventHandler ( "onMarkerHit" , finish , reward )
addEventHandler ( "onPlayerQuit" , getRootElement (), onQuit )
-- other
setVehicleLocked ( TIR , true )
destroyElement ( startBlip )
pelaaja = hitElement
outputChatBox ( "Zacz??e? prac? jako kierowca TIRa. Jed? do czerwonego punktu na mapie!" , pelaaja , 255 , 255 , 255 , true )
setElementPosition ( marker , - 406 , - 64 , 2.4 )
setVehicleVariant ( przyczepa , 0 , 0 )
warpPedIntoVehicle ( hitElement , TIR )
-- end
else
return false
end
end
function trailerDetach ()
if source == przyczepa then
-- destroyThings
destroyElement ( TIR )
destroyElement ( przyczepa )
destroyElement ( finish )
destroyElement ( blip )
-- removeEventHandlers
removeEventHandler ( "onTrailerDetach" , getRootElement (), trailerDetach )
removeEventHandler ( "onVehicleExit" , getRootElement (), vehicleExit )
removeEventHandler ( "onPlayerQuit" , getRootElement (), onQuit )
-- other
startBlip = createBlip ( 2177 , - 2258 , 13.7 , 51 )
setElementPosition ( marker , 2177 , - 2258 , 13.7 , 51 )
else
return false
end
end
function vehicleExit ( leaver )
if source == TIR and leaver == pelaaja then
setVehicleLocked ( TIR , false )
outputChatBox ( "Wr?? do pojazdu w ci?gu 10 sekund!!!" , leaver , 255 , 255 , 255 , true )
destroyTimer = setTimer ( destroyVehicle , 10000 , 1 )
addEventHandler ( "onVehicleEnter" , getRootElement (), destrTimer )
else
return false
end
end
function destrTimer ( thePlayer )
if source == TIR and thePlayer == pelaaja then
local team = getPlayerTeam ( thePlayer )
if getTeamName ( team ) == "Freeroam" or getTeamName ( team ) == "The Police" then
return false
else
killTimer ( destroyTimer )
removeEventHandler ( "onVehicleEnter" , getRootElement (), destrTimer )
setVehicleLocked ( TIR , true )
end
else
return false
end
end
function destroyVehicle ()
if destroyTimer then
-- destroyThings
destroyElement ( TIR )
destroyElement ( przyczepa )
destroyElement ( finish )
destroyElement ( blip )
-- removeEventHandlers
removeEventHandler ( "onTrailerDetach" , getRootElement (), trailerDetach )
removeEventHandler ( "onVehicleExit" , getRootElement (), vehicleExit )
removeEventHandler ( "onVehicleEnter" , getRootElement (), destrTimer )
removeEventHandler ( "onPlayerQuit" , getRootElement (), onQuit )
-- other
startBlip = createBlip ( 2177 , - 2258 , 13.7 , 51 )
setElementPosition ( marker , 2177 , - 2258 , 13.7 )
else
return false
end
end
function onQuit ()
if source == pelaaja then
-- destroyThings
destroyElement ( TIR )
destroyElement ( przyczepa )
destroyElement ( finish )
destroyElement ( blip )
-- removeEventHandlers
removeEventHandler ( "onTrailerDetach" , getRootElement (), trailerDetach )
removeEventHandler ( "onVehicleExit" , getRootElement (), vehicleExit )
removeEventHandler ( "onPlayerQuit" , getRootElement (), onQuit )
-- other
startBlip = createBlip ( 2177 , - 2258 , 13.7 , 51 )
setElementPosition ( marker , 2177 , - 2258 , 13.7 , 51 )
end
end
function reward ( hitElement )
if hitElement == TIR then
-- other
startBlip = createBlip ( 2177 , - 2258 , 13.7 , 51 )
outputChatBox ( "Dobra robota, otrzymujesz " .. tableMoney [ randomLoc ] .. "$" , pelaaja , 255 , 255 , 255 , true )
setElementPosition ( marker , 2776.6 , - 2425.5 , 12.6 )
palkittava = getVehicleOccupant ( TIR , 0 )
givePlayerMoney ( palkittava , tableMoney [ randomLoc ])
-- destroyThings
destroyElement ( TIR )
destroyElement ( przyczepa )
destroyElement ( finish )
destroyElement ( blip )
-- removeEventHandlers
removeEventHandler ( "onTrailerDetach" , getRootElement (), trailerDetach )
removeEventHandler ( "onVehicleExit" , getRootElement (), vehicleExit )
removeEventHandler ( "onPlayerQuit" , getRootElement (), onQuit )
else
return false
end
end
function respawnPed ()
if source == ped then
timer = setTimer ( pedRespawn , 5000 , 1 )
else
return false
end
end
function pedRespawn ()
killTimer ( timer )
destroyElement ( ped )
ped = createPed ( 302 , 2176 , - 2259 , 13.7 )
end
addEventHandler ( "onResourceStart" , getResourceRootElement ( getThisResource ()), startScript ) [/quote]
Wysłany: 2014-10-26, 15:43
Jacob
Głupiomądry
Wiek: 28 Na forum: 5502 dni Posty: 967
Nick w MP: Jacob
Piwa : 786
function reward ( hitElement )
if hitElement == TIR then
-- other
startBlip = createBlip ( 2177 , - 2258 , 13.7 , 51 )
outputChatBox ( "Dobra robota, otrzymujesz " .. tableMoney [ randomLoc ] .. "$" , pelaaja , 255 , 255 , 255 , true )
setElementPosition ( marker , 2776.6 , - 2425.5 , 12.6 )
palkittava = getVehicleOccupant ( TIR , 0 )
givePlayerMoney ( palkittava , tableMoney [ randomLoc ])
-- destroyThings
destroyElement ( TIR )
destroyElement ( przyczepa )
destroyElement ( finish )
destroyElement ( blip )
-- removeEventHandlers
removeEventHandler ( "onTrailerDetach" , getRootElement (), trailerDetach )
removeEventHandler ( "onVehicleExit" , getRootElement (), vehicleExit )
removeEventHandler ( "onPlayerQuit" , getRootElement (), onQuit )
else
return false
end
end
Zamie? na
function reward ( hitElement )
if hitElement == TIR then
-- other
startBlip = createBlip ( 2177 , - 2258 , 13.7 , 51 )
outputChatBox ( "Dobra robota, otrzymujesz " .. tableMoney [ randomLoc ] .. "$" , pelaaja , 255 , 255 , 255 , true )
setElementPosition ( marker , 2177 , - 2258 , 13.7 )
palkittava = getVehicleOccupant ( TIR , 0 )
givePlayerMoney ( palkittava , tableMoney [ randomLoc ])
-- destroyThings
destroyElement ( TIR )
destroyElement ( przyczepa )
destroyElement ( finish )
destroyElement ( blip )
-- removeEventHandlers
removeEventHandler ( "onTrailerDetach" , getRootElement (), trailerDetach )
removeEventHandler ( "onVehicleExit" , getRootElement (), vehicleExit )
removeEventHandler ( "onPlayerQuit" , getRootElement (), onQuit )
else
return false
end
end
Wysłany: 2014-10-26, 17:16
SzczepSon1204
Wiek: 29 Na forum: 4247 dni Posty: 24
Nick w MP: SzczepSon
Mi si? wydaje czy zamieniona tylko lokalizacja markera w "setElementPosition" ?
[ Dodano : 2014-10-26, 17:23 ]
OK po finishu dzia?a. Rozumiem, ?e je?li chc? by po uszkodzeniu naczepy itd r?wnie? marker si? odnawial, te? wprowadzi? zmiany te same co w "function finish".
Pytanie, czy b?d? si? musia? grzeba? w rozdzielanie skryptu na client i server, by innym graczom nie znika? marker, gdy ja zaczn? prac?.
[ Dodano : 2014-10-26, 17:57 ]
@EDIT
Ok all dzia?a, z tym, ?e nie wiem czy kto? b?dzie m?g? wej?? w marker je?li kto? ju? we?mie wcze?niej prac?..
[ Dodano : 2014-10-26, 21:14 ]
ref
Wysłany: 2014-10-26, 22:25
Jacob
Głupiomądry
Wiek: 28 Na forum: 5502 dni Posty: 967
Nick w MP: Jacob
Piwa : 786
Funkcje po stronie serwera wykonywane s? dla wszystkich.
Wysłany: 2014-10-26, 22:35
SzczepSon1204
Wiek: 29 Na forum: 4247 dni Posty: 24
Nick w MP: SzczepSon
Okej dzi?ki za info
Jak tylko hosting upora si? z problemem uruchamiam i sprawdzam czy dziala
[ Dodano : 2014-10-27, 18:57 ]
hmm mam kolejny problem.
Gdy jeden gracz we?mie marker, to reszcie znika...
Jak zrobi? ?eby by? uniwersalny?
Tagi: praca :: kierowcy :: tira
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: