Guest Posted October 24, 2008 Share Posted October 24, 2008 function carStart ( commandName, playerSource ) local theVehicle = getPlayerOccupiedVehicle ( playerSource ) local theDriver = getVehicleController ( theVehicle ) local chance = { 1, 2 } if ( theDriver == playerSource ) then local enginestate = getVehicleEngineState( theVehicle ) if( enginestate == true ) then outputChatBox( "The vehicle is already on.", playerSource, 0, 255, 0 ) else setTimer( setVehicleEngineState ( theVehicle, true ), 2000, 1 ) local success = math.rand( 1, #chance ) if( success == 1 ) then setTimer( setVehicleEngineState ( theVehicle, true ), 2000, 1 ) setTimer( call( getThisResource(), "sendLocalDoAction", "The vehicle's engine starts.", sourcePlayer ) ) elseif( success == 2 ) then call( getThisResource(), "sendLocalMeAction", "attempts to turn on their vehicle.", sourcePlayer ) setTimer( call( getThisResource(), "sendLocalDoAction", "The vehicle does not start.", sourcePlayer ) ) end end else outputChatBox ( "You are not the driver.", playerSource, 125, 125, 125 ) end end addCommandHandler ("startcar", carStart) ------------Car-Stop-------------- function carStop ( commandName, playerSource ) local theVehicle = getPlayerOccupiedVehicle ( playerSource ) local theDriver = getVehicleController ( theVehicle ) if ( theDriver == playerSource ) then local enginestate = getVehicleEngineState( theVehicle ) if( enginestate == false ) then outputChatBox( "The vehicle is already off.", playerSource, 255, 0, 0 ) else setVehicleEngineState( theVehicle, false ) call( getThisResource(), "sendLocalMeAction", "turns their engine off.", playerSource ) end else outputChatBox ( "You are not the driver.", playerSource, 125, 125, 125 ) end end addCommandHandler ("stopcar", carStop) ---------------------------------- It just tells me You are not the driver. Also, I get nil values for local enginestate = getVehicleEngineState ( theVehicle ) please help me fix any errors you see! thanks[/code] Link to comment
robhol Posted October 24, 2008 Share Posted October 24, 2008 Wrong section. Also, the problem appears to be that you have written the arguments to the function the wrong way. it's Source, Command, Argument 1, Arg. 2, etc, not Command, source. Link to comment
Recommended Posts