Alexs Posted March 31, 2012 Share Posted March 31, 2012 Hola a Todos, estoy viendo como se usa el script "Fuel" que esta en la comunidad y para un uso mas simple queria cambiar el comando /engine por la letra O pero al hacer esto (Fue mi 5to intento) pasa lo siguiente: function switchEngine(playerSource) local theVehicle = getPedOccupiedVehicle(playerSource); if theVehicle and getVehicleController(theVehicle) == playerSource then local state = getVehicleEngineState(theVehicle) if state then setVehicleEngineState(theVehicle, false); outputChatBox('Vehiculo Apagado.',playerSource); else if getCarFuel(theVehicle) <= 0 then return end setVehicleEngineState(theVehicle, true); outputChatBox('Vehiculo Encendido.',playerSource); end end end bindKey (playerSource,"O","down", switchEngine ); dice "Bad Argument @ bindKey" Que debo hacer para que la funcion se active con la letra O y no con el comando /engine?? Link to comment
Castillo Posted March 31, 2012 Share Posted March 31, 2012 Es porque bindKey se usa diferente en scripts server-side. addEventHandler ( "onPlayerJoin", root, function ( ) bindKey ( source, "O", "down", switchEngine ) end ) addEventHandler ( "onResourceStart", resourceRoot, function ( ) for index, player in ipairs ( getElementsByType ( "player" ) ) do bindKey ( player, "O", "down", switchEngine ) end end ) function switchEngine ( playerSource ) local theVehicle = getPedOccupiedVehicle ( playerSource ) if ( theVehicle and getVehicleController ( theVehicle ) == playerSource ) then local state = getVehicleEngineState ( theVehicle ) if ( state ) then setVehicleEngineState ( theVehicle, false ) outputChatBox ( 'Vehiculo Apagado.', playerSource ) else if ( getCarFuel ( theVehicle ) <= 0 ) then return end setVehicleEngineState ( theVehicle, true ) outputChatBox ( 'Vehiculo Encendido.', playerSource ) end end end Link to comment
Alexs Posted March 31, 2012 Author Share Posted March 31, 2012 Es porque bindKey se usa diferente en scripts server-side. addEventHandler ( "onPlayerJoin", root, function ( ) bindKey ( source, "O", "down", switchEngine ) end ) addEventHandler ( "onResourceStart", resourceRoot, function ( ) for index, player in ipairs ( getElementsByType ( "player" ) ) do bindKey ( player, "O", "down", switchEngine ) end end ) function switchEngine ( playerSource ) local theVehicle = getPedOccupiedVehicle ( playerSource ) if ( theVehicle and getVehicleController ( theVehicle ) == playerSource ) then local state = getVehicleEngineState ( theVehicle ) if ( state ) then setVehicleEngineState ( theVehicle, false ) outputChatBox ( 'Vehiculo Apagado.', playerSource ) else if ( getCarFuel ( theVehicle ) <= 0 ) then return end setVehicleEngineState ( theVehicle, true ) outputChatBox ( 'Vehiculo Encendido.', playerSource ) end end end Gracias, Funciona a la Perfeccion Link to comment
Recommended Posts