Wysłany: 2017-12-03, 15:09
NoKill1997
Online
Wiek: 28 Na forum: 3224 dni Posty: 183
Nick w MP: Mefedroniarz.PDW
Piwa : 778
Witam mam problem z CollidableWith. Mianowicie chdzi mi o to ze chce zrobic aby pojazdy przenikaly przez siebie w pracy.. Ale po dodaniu funkcji CollidableWith nie tepa gracza do pojazdu. Kod jest robiony po stronie serwera. Za pomoc daje
i
Kod:
local m1 = createMarker ( 1227.81 , 181.58 , 20.41 - 1 , "cylinder" , 1.5 , 0 , 138 , 255 , 0 )
local t = createElement ( 'text' )
setElementData ( m1 , "custom_prace" , true )
setElementPosition ( t , 1227.81 , 181.58 , 20.41 + 1.2 )
setElementData ( t , "name" , "Praca Dorywcza\nKierowca Autobusu\nZarobek: 150PLN" )
local vehs = {}
local code = "Autobusy"
local zone = createColCuboid ( 1178.59167 , - 1806.40845 , 12.57031 , 8.710205078125 , 25.461059570313 , 4.6140350341797 )
local linie = { 2 , 4 , 8 }
addEventHandler ( "onMarkerHit" , m1 , function( el , md )
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("*Parking zaj?ty czekaj a? wyjedzie!",el) return end
local x , y , z = getElementPosition ( el )
local autbus = createVehicle ( 431 , 1220.41 , 190.85 , 19.98 , 354.6 , 360.0 , 336.4 )
setElementFrozen ( el , true )
local linia = math . random ( 1 , #linie)
setElementData ( autbus , "vehicle:linia" , linie [ linia ])
setElementData ( autbus , "vehicle_job_owner" , el )
setElementData ( autbus , "vehicle:fuel" , 69 )
setElementData ( autbus , "vehicle:mileage" , math . random ( 50000 , 80000 ))
setVehicleHandling ( autbus , "maxVelocity" , 80.0 )
setElementData ( el , "player:job" , code )
setElementCollidableWith ( vehicle , autbus , false )
setTimer ( warpPedIntoVehicle , 2000 , 1 , el , autbus )
setTimer ( setElementFrozen , 2000 , 1 , el , false )
triggerClientEvent ( el , "STARTJobBus" , resourceRoot , autbus , linie [ linia ])
vehs [ el ] = autbus
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 )
Podpis
Aktualny projekt: LSgame
Na scenie MTA od: 2015 roku.
Discord: Chwilowoo, brak
Wysłany: 2017-12-03, 15:46
neku^
Wiek: 24 Na forum: 3522 dni Posty: 461
Nick w MP: neku^
Piwa : 1186
Przeczyta? by? Wiki to by? si? dowiedzia?
Funkcja ta jest tylko po stronie clienta, a ty u?ywasz jej po stronie serwera, musisz pobawi? si? triggerem
Wysłany: 2017-12-04, 23:18
Eitho
Wiek: 24 Na forum: 3489 dni Posty: 330
Nick w MP: Eitho
Piwa : 746
A jak nie chcesz si? bawi? triggerami, to mo?esz zrobi? tak.
P??niej po stronie klienta daj sobie mniej wi?cej takie co?:
function duszki ()
local pojazd = getPedOccupiedVehicle ( localPlayer )
for i , v in pairs ( getElementsByType ( 'vehicle' , resourceRoot )) do
setElementCollidableWith ( v , pojazd , false )
end
end
setTimer ( duszki , 1000 , 0 )
Mo?na to zrobi? mniej obci??aj?c serwer - triggerami, ale zawsze mam z tym problem, tak?e nie pomog? XD
Tagi: nie :: dziala :: collidablewith
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: