Jump to content

[AYUDA]Con taximetro


Recommended Posts

Posted

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?

Posted
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 :_

Posted

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

Posted

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

Posted
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 o.O

Posted

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?

Posted
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

Posted
@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
Posted (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 by Guest
Posted

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.

Posted

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?

Posted

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.

Posted
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 ) 

Posted

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 ) 

Posted (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 by Guest
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...