Wysłany: 2011-12-19, 10:08
LENKO
Wiek: 29 Na forum: 5525 dni Posty: 67
Nick w MP: LENKO*
Piwa : 73
Hi mam problem ze skryptem na odpalanie silnika. Gdy wlacze skrypt i wejde do pojazdu wszystko jest ok ale gdy chce wlaczyc silnik lub swiatla klawisze nie reaguja. Oto kod:
Kod: vehicleEngine = { false }
vehicleLights = { false }
function Script_onPlayerJoin( )
bindKey ( source, "k", "down", Engine )
bindKey ( source, "l", "down", Lights )
end
addEventHandler ( "onPlayerJoin", getRootElement(), Script_onPlayerJoin )
function Script_onVehicleEnter( thePlayer, seat )
if seat == 0 then
if not getVehicleEngineState( source ) then
vehicleEngine[ source ]=true
setVehicleEngineState ( source, false )
else
vehicleEngine[ source ]=true
setVehicleEngineState ( source, true )
end
if vehicleLights[ source ] then
vehicleLights[ source ]=true
setVehicleOverrideLights ( car, 2 )
else
vehicleLights[ source ]=true
setVehicleOverrideLights ( car, 1 )
end
end
end
addEventHandler ( "onVehicleEnter", getRootElement(), Script_onVehicleEnter )
function Script_onVehicleExit( thePlayer, seat )
if ( seat==0 ) then
if not getVehicleEngineState( source ) then
setVehicleEngineState ( source, false )
vehicleEngine[ source ]=false
else
setVehicleEngineState ( source, true )
vehicleEngine[ source ]=true
end
if vehicleLights[ source ] then
setVehicleOverrideLights ( car, 2 )
vehicleLights[ source ]=true
else
setVehicleOverrideLights ( car, 1 )
vehicleLights[ source ]=false
end
end
end
addEventHandler ( "onVehicleExit", getRootElement(), Script_onVehicleExit )
function Engine ( source )
car = getPlayerOccupiedVehicle ( source )
if ( car ) then
if not getVehicleEngineState( car ) then
setVehicleEngineState ( car, true )
vehicleEngine[ car ]=true
else
setVehicleEngineState ( car, false )
vehicleEngine[ car ]=false
end
end
end
function Lights ( source )
car = getPlayerOccupiedVehicle ( source )
if ( car ) then
if not vehicleLights[ car ] then
setVehicleOverrideLights ( car, 2 )
vehicleLights[ car ]=true
else
setVehicleOverrideLights ( car, 1 )
vehicleLights[ car ]=false
end
end
end
function getVehicleEngineState( vehicle )
return vehicleEngine[ vehicle ]
end
Podpis
Stary wilk sceny MTA. Niegdyś o mentalności słabego psychicznie młodego człowieka. Dziś poważny i silny człowiek z wielkim worem doświadczeń.
Wysłany: 2011-12-19, 10:46
44fitr
Wiek: 29 Na forum: 5285 dni Posty: 8
Nick w MP: 44fitr/kuban.
Kto? tu sobie lubi utrudnia? ?ycie...
Kod: function Engine ()
local veh = getPedOccupiedVehicle (source)
if (getVehicleEngineState (veh) == true) then
setVehicleEngineState (veh, false)
else
setVehicleEngineState (veh, true)
end
end
function Lights()
local veh = getPedOccupiedVehicle (source)
if (getVehicleOverrideLights (veh) ~= 2) then
setVehicleOverrideLights (veh, 2)
else
setVehicleOverrideLights (veh, 1)
end
end
Poeksperymentuj z tym
Wysłany: 2011-12-19, 14:34
LENKO
Wiek: 29 Na forum: 5525 dni Posty: 67
Nick w MP: LENKO*
Piwa : 73
Nie dzia?a.
Podpis
Stary wilk sceny MTA. Niegdyś o mentalności słabego psychicznie młodego człowieka. Dziś poważny i silny człowiek z wielkim worem doświadczeń.
Wysłany: 2011-12-19, 14:45
Jacob
Głupiomądry
Wiek: 28 Na forum: 5502 dni Posty: 967
Nick w MP: Jacob
Piwa : 786
Kod: function Engine ()
local veh = getPedOccupiedVehicle (source)
if (getVehicleEngineState (veh) == true) then
setVehicleEngineState (veh, false)
else
setVehicleEngineState (veh, true)
end
end
bindKey(source, "K", "down", Engine)
function Lights()
local veh = getPedOccupiedVehicle (source)
if (getVehicleOverrideLights (veh) ~= 2) then
setVehicleOverrideLights (veh, 2)
else
setVehicleOverrideLights (veh, 1)
end
end
bindKey(source, "L", "down", Lights)
Nie wiem, czy zadzia?a.
Wysłany: 2011-12-19, 14:51
LENKO
Wiek: 29 Na forum: 5525 dni Posty: 67
Nick w MP: LENKO*
Piwa : 73
Tak?e nie chce dzia?a? ani ze starym kodem ani samo bez ?adnych innych.
Podpis
Stary wilk sceny MTA. Niegdyś o mentalności słabego psychicznie młodego człowieka. Dziś poważny i silny człowiek z wielkim worem doświadczeń.
Wysłany: 2011-12-19, 16:26
Jacob
Głupiomądry
Wiek: 28 Na forum: 5502 dni Posty: 967
Nick w MP: Jacob
Piwa : 786
LENKO , umie?ci?e? po stronie client czy server?
Wysłany: 2011-12-19, 17:30
LENKO
Wiek: 29 Na forum: 5525 dni Posty: 67
Nick w MP: LENKO*
Piwa : 73
Nie zrobi?em normalnie. Czyli:
Kod: <script src="script.lua" />
Podpis
Stary wilk sceny MTA. Niegdyś o mentalności słabego psychicznie młodego człowieka. Dziś poważny i silny człowiek z wielkim worem doświadczeń.
Wysłany: 2011-12-19, 18:16
Piorun
Wiek: 32 Na forum: 6712 dni Posty: 1837
Nick w MP: Piorun
Piwa : 516
Korzystaj?c z gotowca masz:
Kod: function switchEngine ( playerSource )
local theVehicle = getPedOccupiedVehicle ( playerSource )
-- Check if the player is in any vehicle and if he is the driver
if theVehicle and getVehicleController ( theVehicle ) == playerSource then
local state = getVehicleEngineState ( theVehicle )
setVehicleEngineState ( theVehicle, not state )
end
end
addCommandHandler ( "switchengine", switchEngine )
Przeanalizuj i ewentualnie popraw b??dy u siebie. Pami?taj - po stronie serwera (musisz doda? w meta.xml typ do pliku ?r?d?owego).
Wysłany: 2011-12-20, 07:01
44fitr
Wiek: 29 Na forum: 5285 dni Posty: 8
Nick w MP: 44fitr/kuban.
Cytat: Przeanalizuj i ewentualnie popraw b??dy u siebie. Pami?taj - po stronie serwera (musisz doda? w meta.xml typ do pliku ?r?d?owego).
My?l? ?e w?a?nie to mo?e by? prawdziwa przyczyna,
poniewa? powy?sze wys?ane przez nas kody zbyt wiele si? nie r??ni?
Wysłany: 2011-12-22, 11:38
LENKO
Wiek: 29 Na forum: 5525 dni Posty: 67
Nick w MP: LENKO*
Piwa : 73
No nadal nie dzia?a pisa?em do kumpla m?wi? ?e kod jest w porz?dku. Umie?ci?em to po stronie serwera. W debugu pokazuje jedynie "Bad argument: 'setVehicleOverrideLights' ale do ko?ca nie jarze o co kaman. Kod jest taki jak poda?em w pierwszym po?cie.
Podpis
Stary wilk sceny MTA. Niegdyś o mentalności słabego psychicznie młodego człowieka. Dziś poważny i silny człowiek z wielkim worem doświadczeń.
Wysłany: 2011-12-22, 19:20
Piorun
Wiek: 32 Na forum: 6712 dni Posty: 1837
Nick w MP: Piorun
Piwa : 516
W og?le ca?y skrypt jest do kosza, bo po pierwsze powiniene? u?y? zamiast setVehicleOverrideLights, http://wiki.multitheftaut...hicleLightState !!
Po drugie skrypt dzia?a od g?ry do do?u, wi?c jak co? zadeklarujesz na dole to tego nie mo?esz wykorzystywa? wy?ej (chodzi mi o zmienn? 'car').
Powodzenia.
Tagi: skrypt :: silnik
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: