aski Posted April 2, 2014 Share Posted April 2, 2014 Mam takowy problem ponieważ światła działają a silnik nie chociaż napis na czacie się wyświetla że silnik włączono tutaj debug: vehicleEngine = { false } vehicleLights = { false } function Script_onPlayerJoin( ) bindKey ( source,"k", "down", Engine ) bindKey ( source, ";", "down", Lights ) end addEventHandler ( "onPlayerJoin", getRootElement(), Script_onPlayerJoin) function Script_onVehicleEnter( thePlayer, seat ) if seat == 0 then if not getVehicleEngineState( source ) then vehicleEngine[ source ]=false setVehicleEngineState ( source, false ) else vehicleEngine[ source ]=true setVehicleEngineState ( source, true ) end if vehicleLights[ source ] then vehicleLights[ source ]=true setVehicleOverrideLights ( car, 2 ) else vehicleLights[ source ]=false 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 ( player ) car = getPedOccupiedVehicle ( player ) if ( car ) then if not getVehicleEngineState( car ) then setVehicleEngineState ( car, true ) outputChatBox("Silnik auta został wlaczony.",player, 102, 255, 51, true ) vehicleEngine[ car ]=true else setVehicleEngineState ( car, false ) outputChatBox("Silnik auta został wyłaczony.",player, 102, 255, 51, true ) vehicleEngine[ car ]=false end end end function Lights ( player ) car = getPedOccupiedVehicle ( player ) if ( car ) then if not vehicleLights[ car ] then setVehicleOverrideLights ( car, 2 ) outputChatBox("Swiatla auta zostały wlaczone.",player, 102, 255, 51, true ) vehicleLights[ car ]=true else outputChatBox("Swiatla auta zostały wylaczone.",player, 102, 255, 51, true ) setVehicleOverrideLights ( car, 1 ) vehicleLights[ car ]=false end end end function getVehicleEngineState( vehicle ) return vehicleEngine[ vehicle ] end Link to comment
dzek (varez) Posted April 3, 2014 Share Posted April 3, 2014 słyszałeś kiedyś o wcięciach w kodzie? pisząc taki kod bardzo łatwo o błąd. po co nadpisujesz `getEngineVehicleState`? po co Ci te dziwne zmienne `vehicleLights` i `vehicleEngine`? Link to comment
mommytellme Posted April 7, 2014 Share Posted April 7, 2014 Ten kod wygląda co najmniej dziwnie Da się prościej zrobić, chyba że to kod z jakichś pierwszych wersji. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now