depato123 Posted July 18, 2013 Share Posted July 18, 2013 Hola quería que me ayuden a hacer un resource de taximetro que si el conductor del taxi dice /taximetro a los pasajeros le resten dinero por cada 50 segundos que pase dentro del auto ¿como se podria hacer? Link to comment
AlvareZ_ Posted July 18, 2013 Share Posted July 18, 2013 seat getPlayerMoney takePlayerMoney setTimer "addComandHandler" Link to comment
depato123 Posted July 18, 2013 Author Share Posted July 18, 2013 function taximetro(pasajero, seat, jacked) theVehicleID = getElementModel ( source ) if (theVehicleID == 420) and ( seat ~= 0 ) then local money = getPlayerMoney(thePlayer) if (money > 50) then -- No se como comprobar si el usuario tiene el dinero en este caso 50$ driver = getVehicleOccupant(source, 0) setTimer ( function() takePlayerMoney ( pasajero, 50) end, 60000, 1 ) end end addCommandHandler ( "taximetro", taximetro ) Intente hacer esto pero en el if de getMoney no se como corroborar si el usuario (pasajero) tiene el dinero pero si si tiene mas de 50 necesito ayuda con eso y tampoco me funciono el resource :_ Link to comment
AlvareZ_ Posted July 18, 2013 Share Posted July 18, 2013 No defines pasajero, no defines thePlayer o source, Tienes que usar solo 1 si es thePlayer es thePlayer si es source es source, en ese script estas verificando si el que esta en el asiento 0 creo que es el conductor tiene 50 de dinero para luego tomar el dinero de el pasajero que no lo defines Link to comment
depato123 Posted July 18, 2013 Author Share Posted July 18, 2013 Oye ¿me das un ejemplo? Link to comment
AlvareZ_ Posted July 18, 2013 Share Posted July 18, 2013 Prueba esto, aca tomara a el pasajero 50 de dinero (No Probado) function dinero(theVehicle, seat, jacked) local id = getElementModel ( theVehicle ) if (id == 420) and ( seat ~= 0 ) then local pasajero = getVehicleOccupant ( source, 1 ) takePlayerMoney(pasajero, 50) end end addCommandHandler ( "taximetro", taximetro ) -- EDIT: Arreglado una cosa Link to comment
Sensacion Posted July 18, 2013 Share Posted July 18, 2013 Prueba esto, aca tomara a el pasajero 50 de dinero (No Probado) function dinero(theVehicle, seat, jacked) local id = getElementModel ( theVehicle ) if (id == 420) and ( seat ~= 0 ) then local pasajero = getVehicleOccupant ( source, 1 ) takePlayerMoney(pasajero, 50) end end addCommandHandler ( "taximetro", taximetro ) -- EDIT: Arreglado una cosa con eso quieres decir que el vehículo va a escribir /taximetro Link to comment
depato123 Posted July 18, 2013 Author Share Posted July 18, 2013 Intente arreglarlo pero el hice desastre function dinero(theVehicle, seat, jacked) local id = getElementModel ( theVehicle ) if (id == 420) and ( seat ~= 0 ) then local pasajero = getVehicleOccupant ( theVehicle, 1 ) takePlayerMoney(pasajero, 50) setTimer ( function() takePlayerMoney(pasajero, 50) end, 5000, 1 ) end end addCommandHandler ( "taximetro", taximetro ) ¿Alguien sabe como solucionarlo? Link to comment
Sensacion Posted July 18, 2013 Share Posted July 18, 2013 Intente arreglarlo pero el hice desastre function dinero(theVehicle, seat, jacked) local id = getElementModel ( theVehicle ) if (id == 420) and ( seat ~= 0 ) then local pasajero = getVehicleOccupant ( theVehicle, 1 ) takePlayerMoney(pasajero, 50) setTimer ( function() takePlayerMoney(pasajero, 50) end, 5000, 1 ) end end addCommandHandler ( "taximetro", taximetro ) ¿Alguien sabe como solucionarlo? @depato123, el primer argumento de addCommandHandler es para el que ejecuta el comando, osea el jugador y al ver theVehicle pienso que quieres obtener el modelo del auto, para obtener el auto primero debes verificar si está en el auto con isPedInVehicle, luego obtener el auto con getPedOccupiedVehicle Link to comment
depato123 Posted July 18, 2013 Author Share Posted July 18, 2013 @depato123, el primer argumento de addCommandHandler es para el que ejecuta el comando, osea el jugador y al ver theVehicle pienso que quieres obtener el modelo del auto, para obtener el auto primero debes verificar si está en el auto con isPedInVehicle, luego obtener el auto con getPedOccupiedVehicle si, porque quería que solamente el comando pueda usarse en el vehiculo 420 pero luego no se como usar el setTimer Link to comment
Sensacion Posted July 18, 2013 Share Posted July 18, 2013 (edited) function taximetro( thePlayer ) if isPedInVehicle ( thePlayer ) then local taxi = getPedOccupiedVehicle ( thePlayer ) if ( getElementModel ( taxi ) == 420 ) then BLOQUE.. end end end addCommandHandler( "taximetro", taximetro) Con eso ya verificas que está en un auto y que el id es el 420 Edited July 18, 2013 by Guest Link to comment
depato123 Posted July 18, 2013 Author Share Posted July 18, 2013 Con eso ya verificas que está en un auto y que el id es el 420 ¿Y luego pongo getPlayerMoney takePlayerMoney setTimer ? Link to comment
Sensacion Posted July 18, 2013 Share Posted July 18, 2013 Con eso ya verificas que está en un auto y que el id es el 420 ¿Y luego pongo getPlayerMoney takePlayerMoney setTimer ? Si, te faltaría obtener si es el driver, que le quite dinero a todos los del auto y se los de al conductor, como tu server es rol, también podrías fijar una cantidad de dinero, digamos /taximetro 20 y que cobre 20 y así, depende de como lo quieras. Link to comment
depato123 Posted July 18, 2013 Author Share Posted July 18, 2013 Intente definir "driver" asi function taximetro( thePlayer ) driver = getVehicleOccupant(source, 0) ------ aqui if isPedInVehicle ( thePlayer ) then local taxi = getPedOccupiedVehicle ( thePlayer ) if ( getElementModel ( taxi ) == 420) then BLOQUE.. end end end addCommandHandler( "taximetro", taximetro) Si esta bien ¿me podrías ayudar con lo de SetTimer? Link to comment
Sensacion Posted July 18, 2013 Share Posted July 18, 2013 la función se lee de arriba a abajo, pusiste "driver = getVehicleOccupant(source, 0)", eso te dará error porque en el primer argumento va el vehículo y aún no lo definiste, el vehículo está definido abajo con la variable taxi, además pones source, ahí debes poner el vehículo, osea taxi. Link to comment
depato123 Posted July 18, 2013 Author Share Posted July 18, 2013 ¿Me das un ejemplo de como definir el driver? Link to comment
Sensacion Posted July 18, 2013 Share Posted July 18, 2013 function taximetro( thePlayer ) if isPedInVehicle ( thePlayer ) then local taxi = getPedOccupiedVehicle ( thePlayer ) local driver = getVehicleOccupant ( taxi, 0 ) if ( getElementModel ( taxi ) == 44 and driver ) then end end end addCommandHandler( "taximetro", taximetro ) Link to comment
depato123 Posted July 18, 2013 Author Share Posted July 18, 2013 Gracias pero sigue sin funcionar :_ agregué lo que faltaba como el setTimer y el takePlayerMoney pero no le saca el dinero al pasajero function taximetro( thePlayer ) if isPedInVehicle ( thePlayer ) then local taxi = getPedOccupiedVehicle ( thePlayer ) local driver = getVehicleOccupant ( taxi, 0 ) if ( getElementModel ( taxi ) == 44 and driver ) then setTimer ( function() takePlayerMoney ( pasajero, 50) end, 60000, 1 ) end end end addCommandHandler( "taximetro", taximetro ) Link to comment
Sensacion Posted July 18, 2013 Share Posted July 18, 2013 local occupants = getVehicleOccupants( taxi ) for i, v in ipairs( occupants ) do takePlayerMoney ( v, 50) end Link to comment
depato123 Posted July 18, 2013 Author Share Posted July 18, 2013 ¿Debo remplazarlo por eso o lo agrego? Link to comment
Sensacion Posted July 18, 2013 Share Posted July 18, 2013 (edited) Esto debería quitar 50 cada 5 sec, prueba si funciona: local t = {} function taximetro( thePlayer ) if isPedInVehicle ( thePlayer ) then local taxi = getPedOccupiedVehicle ( thePlayer ) local driver = getVehicleOccupant ( taxi, 0 ) if ( getElementModel ( taxi ) == 420 and driver ) then t[ thePlayer ] = setTimer ( function() local occupants = getVehicleOccupants( taxi ) if ( #occupants >= 1 ) then for i, v in ipairs( occupants ) do takePlayerMoney ( v, 50 ) end else if isTimer( t[ thePlayer ] ) then killTimer( t[ thePlayer ] ) end end end, 5000, 0 ) end end end addCommandHandler( "taximetro", taximetro ) Edited July 18, 2013 by Guest Link to comment
depato123 Posted July 18, 2013 Author Share Posted July 18, 2013 No funciona, no resta el dinero al pasajero Link to comment
Sensacion Posted July 18, 2013 Share Posted July 18, 2013 copialo de nuevo, y si no funciona dime que te sale en el debug Link to comment
depato123 Posted July 18, 2013 Author Share Posted July 18, 2013 Sigue sin funcionar y no sale ningun error en el debugscript Link to comment
Sensacion Posted July 18, 2013 Share Posted July 18, 2013 copia de nuevo, había puesto 44 en getElementModel en vez de 420, y le modifiqué algo, revisa de nuevo si funciona, y si no, miras el debug. Link to comment
Recommended Posts