Jump to content

[AYUDA] TAXIMETRO ME DA ERROR


LuFeMAR

Recommended Posts

addCommandHandler( "taximetro",
    function( player, commandName )
        local vehiculo = getPedOccupiedVehicle( player ) 
        local vehiculos = getvehiclemodel(vehicle) 
        if vehiculos == 420 then
        if exports.factions:IsPlayerInFaction(player,10) then
        if vehiculo and getVehicleOccupant( vehiculo ) == player then
            setElementData( vehiculo, "distancia", type( getElementData( vehiculo, "distancia" ) ) ~= "number" and 0 or false )
        end
        end
        end
    end
)

function taxi( )
local screenX, screenY = guiGetScreenSize( )
local distancia = getElementData( vehicle, "distancia" )
if distancia then
            texto = ("Taximetro: %.1f$"):format( distancia )
             dxDrawText( texto, 4, 4, screenX, screenY * 0.98 + 2, tocolor( 0, 0, 0, 255 ), 1, "pricedown", "center", "bottom", false, false, true )
end
end

Tengo este taxímetro y yo veo todo bien peor al momento de iniciarlo me dice:  

WARNING: taxidemetro\client.lua:3 Bad argument @ 'getPedOccupiedVehicle' [Expected ped at argument 1, got string 'taximetro']

ERROR: taxidemetro\client.lua:4attempt to call global 'getvehiclemodel' (a nil value

me salta este error y no me funciona, alguna idea?, no se que hacer

Link to comment
13 hours ago, LuFeMAR said:


addCommandHandler( "taximetro",
    function( player, commandName )
        local vehiculo = getPedOccupiedVehicle( player ) 
        local vehiculos = getvehiclemodel(vehicle) 
        if vehiculos == 420 then
        if exports.factions:IsPlayerInFaction(player,10) then
        if vehiculo and getVehicleOccupant( vehiculo ) == player then
            setElementData( vehiculo, "distancia", type( getElementData( vehiculo, "distancia" ) ) ~= "number" and 0 or false )
        end
        end
        end
    end
)

function taxi( )
local screenX, screenY = guiGetScreenSize( )
local distancia = getElementData( vehicle, "distancia" )
if distancia then
            texto = ("Taximetro: %.1f$"):format( distancia )
             dxDrawText( texto, 4, 4, screenX, screenY * 0.98 + 2, tocolor( 0, 0, 0, 255 ), 1, "pricedown", "center", "bottom", false, false, true )
end
end

Tengo este taxímetro y yo veo todo bien peor al momento de iniciarlo me dice:  

WARNING: taxidemetro\client.lua:3 Bad argument @ 'getPedOccupiedVehicle' [Expected ped at argument 1, got string 'taximetro']

ERROR: taxidemetro\client.lua:4attempt to call global 'getvehiclemodel' (a nil value

me salta este error y no me funciona, alguna idea?, no se que hacer

El error te lo está tirando porque no estás usando el  argumento que definiste arriba, cambia vehicle por vehiculo, y además cambia la función que estás usando por https://wiki.multitheftauto.com/wiki/GetElementModel

Edited by Crespo_
Link to comment

Hola , gracias por responder... he intentando lo que me dijiste pero igual sigue tirando Warnings  y sigue sin funcionar.

addCommandHandler( "taximetro",
    function( player, commandName )
        local vehiculo = getPedOccupiedVehicle( player ) 
        local vehiculos = getElementModel(vehiculo) 
        if vehiculos == 420 then
        if exports.factions:IsPlayerInFaction(player,10) then
        if vehiculo and getVehicleOccupant( vehiculo ) == player then
            setElementData( vehiculo, "distancia", type( getElementData( vehiculo, "distancia" ) ) ~= "number" and 0 or false )
        end
        end
        end
    end
)

function taxi( )
local screenX, screenY = guiGetScreenSize( )
local distancia = getElementData( vehicle, "distancia" )
if distancia then
            texto = ("Taximetro: %.1f$"):format( distancia )
             dxDrawText( texto, 4, 4, screenX, screenY * 0.98 + 2, tocolor( 0, 0, 0, 255 ), 1, "pricedown", "center", "bottom", false, false, true )
end
end

 

WARNING: taxidemetro\client.lua:3: Bad argument @ 'getPedOccupiedVehicle' [Expected ped at argument 1, got string 'taximetro']

 

WARNING: taxidemetro\client.lua:4: Bad argument @ 'getElementModelO' [Expected ped at argument 1, got boolean]

 

Link to comment

Prueba asi...
 

addCommandHandler( "taximetro",
    function( player, commandName )
        local vehiculo = getPedOccupiedVehicle ( player )
        local vehiculos =  getVehicleName ( vehiculo ) 
        if vehiculos == "Taxi" then
           if exports.factions:IsPlayerInFaction(player,10) then
                  setElementData( vehiculo, "distancia", type( getElementData( vehiculo, "distancia" ) ) ~= "number" and 0 or false )
           end
        end
    end
  )

o tambien puedes probar asi:
 

addCommandHandler( "taximetro",
    function( theVehicle , commandName )
        local vehiculo = getPedOccupiedVehicle( source ) 
        local vehiculos = getElementModel ( theVehicle ) 
        if vehiculos == 420 then
           if exports.factions:IsPlayerInFaction(player,10) then
              if vehiculo then
                 setElementData( vehiculo, "distancia", type( getElementData( vehiculo, "distancia" ) ) ~= "number" and 0 or false )
              end
           end
        end
    end
)

Puedes mostrar exactamente el codigo en donde te dice el error?

taxidemetro\client.lua: Linea 3

Ejemplo de como deberia de ir la sintaxis del codigo: local theVehicle = getPedOccupiedVehicle ( thePlayer )--- Si el usuario o ped esta dentro de un vehiculo.

taxidemetro\client.lua: Linea 4

Ejemplo:  Deberias de usar esto: local id = getElementModel ( theVehicle ) ---Obtiene la id del vehiculo.

Edited by _.:illus!on:._
Link to comment

Hola, gracias por responder, he probado con el segundo código que me enviaste pero aun me sigue lanzando  WARNINGS

 

WARNING: taxidemetro\client.lua:3: Bad argument @ 'getPedOccupiedVehicle' [Expected ped at argument 1, got nil]

WARNING: taxidemetro\client.lua:4: Bad argument @ 'getElementModelO' [Expected ped at argument 1, got string 'taximetro']

 

 

addCommandHandler( "taximetro",
    function( theVehicle , commandName )
        local vehiculo = getPedOccupiedVehicle( source ) 
        local vehiculos = getElementModel ( theVehicle ) 
        if vehiculos == 420 then
           if exports.factions:IsPlayerInFaction(player,10) then
              if vehiculo then
                 setElementData( vehiculo, "distancia", type( getElementData( vehiculo, "distancia" ) ) ~= "number" and 0 or false )
              end
           end
        end
    end
)

Este fue el que use

Edited by LuFeMAR
Link to comment
7 hours ago, LuFeMAR said:

Hola, gracias por responder, he probado con el segundo código que me enviaste pero aun me sigue lanzando  WARNINGS

 

WARNING: taxidemetro\client.lua:3: Bad argument @ 'getPedOccupiedVehicle' [Expected ped at argument 1, got nil]

WARNING: taxidemetro\client.lua:4: Bad argument @ 'getElementModelO' [Expected ped at argument 1, got string 'taximetro']

 

 


addCommandHandler( "taximetro",
    function( theVehicle , commandName )
        local vehiculo = getPedOccupiedVehicle( source ) 
        local vehiculos = getElementModel ( theVehicle ) 
        if vehiculos == 420 then
           if exports.factions:IsPlayerInFaction(player,10) then
              if vehiculo then
                 setElementData( vehiculo, "distancia", type( getElementData( vehiculo, "distancia" ) ) ~= "number" and 0 or false )
              end
           end
        end
    end
)

Este fue el que use

seguramente es por que tu codigo es lado client, proba con ewto

addCommandHandler( "taximetro",
    function(  )
        local vehiculo = getPedOccupiedVehicle ( localPlayer )
        local vehiculos =  getVehicleName ( vehiculo ) 
        if vehiculos == "Taxi" then
           if exports.factions:IsPlayerInFaction(localPlayer,10) then
                  setElementData( vehiculo, "distancia", type( getElementData( vehiculo, "distancia" ) ) ~= "number" and 0 or false )
           end
        end
    end
  )

 

Link to comment

Hola, gracias por responder... he usado el código que me enviaste:

addCommandHandler( "taximetro",
    function(  )
        local vehiculo = getPedOccupiedVehicle ( localPlayer )
        local vehiculos =  getVehicleName ( vehiculo ) 
        if vehiculos == "Taxi" then
           if exports.factions:IsPlayerInFaction(localPlayer,10) then
                  setElementData( vehiculo, "distancia", type( getElementData( vehiculo, "distancia" ) ) ~= "number" and 0 or false )
           end
        end
    end
  )

pero me dice:  ERROR: taxidemetro\client.lua:6: call failed to call 'factions:IsPlayerInFaction' [string "?"]

 

Link to comment
13 hours ago, LuFeMAR said:

Hola, gracias por responder... he usado el código que me enviaste:


addCommandHandler( "taximetro",
    function(  )
        local vehiculo = getPedOccupiedVehicle ( localPlayer )
        local vehiculos =  getVehicleName ( vehiculo ) 
        if vehiculos == "Taxi" then
           if exports.factions:IsPlayerInFaction(localPlayer,10) then
                  setElementData( vehiculo, "distancia", type( getElementData( vehiculo, "distancia" ) ) ~= "number" and 0 or false )
           end
        end
    end
  )

pero me dice:  ERROR: taxidemetro\client.lua:6: call failed to call 'factions:IsPlayerInFaction' [string "?"]

 

esa linea esta llamando la funcion IsPlayerInFaction del scripts factions si te da ese error es por que el script no esta encendido

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...