Alexs Posted March 31, 2012 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?? Developer @ MYVAL
Castillo Posted March 31, 2012 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 San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Alexs Posted March 31, 2012 Author 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 Developer @ MYVAL
Castillo Posted March 31, 2012 Posted March 31, 2012 No hay de que. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Recommended Posts