Jump to content

Ayuda


Arsilex

Recommended Posts

addCommandHandler( "nearbycars", 
    function( player, commandName ) 
        if hasObjectPermissionTo( player, "command.kick", false ) or hasObjectPermissionTo( player, "command.deletecar", false ) then 
            local x, y, z = getElementPosition( player ) 
            local dimension = getElementDimension( player ) 
            local interior = getElementInterior( player ) 
            local vehicles = getElementInterior( player ) 
             
            outputChatBox( "Nearby Coches:", player, 255, 255, 0 ) 
            for key, value in pairs( vehicles ) do 
                if isElement( key ) and getElementDimension( key ) == dimension and getElementVehicle( key ) == interior then 
                    local distance = getDistanceBetweenPoints3D( x, y, z, getElementPosition( key ) ) 
                    if distance < 20 then 
                        outputChatBox( "  Coche " .. value .. " - Type: " .. tostring( vehicles ) .. ".", player, 255, 255, 0 ) 
                    end 
                end 
            end 
        end 
    end 
) 

Tengo este script pero no me dice el ID de los coches cercano como lo ago funcionar :S

Link to comment
addCommandHandler( "nearbycars", 
    function( player, commandName ) 
        if hasObjectPermissionTo( player, "command.kick", false ) or hasObjectPermissionTo( player, "command.deletecar", false ) then 
            local x, y, z = getElementPosition( player ) 
            local dimension = getElementDimension( player ) 
local interior = getElementInterior( player ) 
local vehicles = getElementsByType("vehicle") 
            
            outputChatBox( "Nearby Coches:", player, 255, 255, 0 ) 
            for key, value in pairs( vehicles ) do 
                if isElement( key ) and getElementDimension( key ) == dimension and getElementVehicle( key ) == interior then 
                    local distance = getDistanceBetweenPoints3D( x, y, z, getElementPosition( key ) ) 
                    if distance < 20 then 
                        outputChatBox( "  Coche " .. value .. " - Type: " .. tostring( vehicles ) .. ".", player, 255, 255, 0 ) 
                    end 
                end 
            end 
        end 
    end 
) 

Link to comment

Revisa esto

if isElement( key ) and getElementDimension( key ) == dimension and getElementVehicle( key ) == interior then

local distance = getDistanceBetweenPoints3D( x, y, z, getElementPosition( key ) )

y pon

if isElement( value ) and getElementDimension( value ) == dimension and getElementVehicle( value ) == interior then

local distance = getDistanceBetweenPoints3D( x, y, z, getElementPosition( value ) )

Link to comment

outputChatBox( " Coche " .. value .. " - Type: " .. tostring( vehicles ) .. ".", player, 255, 255, 0 )

cambia por

outputChatBox( " Coche " .. value .. " - Type: " .. tostring( getElementModel (value) ) .. ".", player, 255, 255, 0 )

y tambien, getElementVehicle no existe... es getElementsByType("vehicle")

Link to comment

grax por la ayuda pero tengo otra duda

añadi esto y no funciona ahora :S

addCommandHandler( "nearbycars", 
    function( player, commandName ) 
        if hasObjectPermissionTo( player, "command.kick", false ) or hasObjectPermissionTo( player, "command.deletecar", false ) then 
            local x, y, z = getElementPosition( player ) 
            local dimension = getElementDimension( player ) 
            local interior = getElementInterior( player ) 
            local vehicles = getElementsByType( "vehicle" ) 
            
            outputChatBox( "Nearby Coches:", player, 255, 255, 0 ) 
            for key, value in pairs( vehicles ) do 
                local vehicleID = vehicles[ vehicle ] and vehicles[ vehicle ].vehicleID 
                if vehicleID then 
                    local distance = getDistanceBetweenPoints3D( x, y, z, getElementPosition( value ) ) 
                    if distance < 20 then 
                        outputChatBox( " Coche " .. getElementModel(value) .. "ID".. vehicleID.. ".", player, 255, 255, 0 ) 
                    end 
                end 
            end 
        end 
    end 
) 

Ningun error pero no sale el chat :S

Link to comment

Puedes optar por

local vehicleID = vehicles[ vehicle ] and vehicles[ vehicle ].vehicleID

a

local vehicleID = vehicles[ value ] and vehicles[ value ].vehicleID

o simplemente...

outputChatBox( " Coche " .. getElementModel(value) .. "ID".. vehicleID.. ".", player, 255, 255, 0 )

por...

outputChatBox( " Coche " .. getElementModel(value) .. ".", getRootElement(), 255, 255, 0 )

¿Para qué quieres el vehicle ID?

Link to comment
Nada sigue igual para que me diga el ID de mi coche es que en mi server es mysql y para borrar o abrir coches con admin tienes que saber el ID del coche

Revisa que edité para que modifiques algo

local vehicleID = vehicles[ vehicle ] and vehicles[ vehicle ].vehicleID

a

local vehicleID = vehicles[ value ] and vehicles[ value ].vehicleID

Link to comment

no no funciona puse

addCommandHandler( "nearbycars", 
    function( player, commandName ) 
        if hasObjectPermissionTo( player, "command.kick", false ) or hasObjectPermissionTo( player, "command.deletecar", false ) then 
            local x, y, z = getElementPosition( player ) 
            local dimension = getElementDimension( player ) 
            local interior = getElementInterior( player ) 
            local vehicles = getElementsByType( "vehicle" ) 
            
            outputChatBox( "Nearby Coches:", player, 255, 255, 0 ) 
            for key, value in pairs( vehicles ) do 
                local vehicleID = vehicles[ value ] and vehicles[ value ].vehicleID 
                if vehicleID then 
                    local distance = getDistanceBetweenPoints3D( x, y, z, getElementPosition( value ) ) 
                    if distance < 20 then 
                        outputChatBox( " Coche " .. getElementModel(value) .. "ID".. vehicleID.. ".", player, 255, 255, 0 ) 
                    end 
                end 
            end 
        end 
    end 
) 

Link to comment

Revisa el DebugScript. Si nada sale quiere decir que el error se halla aquí:

local vehicleID = vehicles[ value ] and vehicles[ value ].vehicleID

Además, claro que no funcionará. Te retorna únicamente los vehicles. No creas que los vehicles a su vez son tablas con distintos atributos!.

Hazme caso y bórralo al menos por ahora o dejalo en comentarios

Link to comment

En fin, como te digo. No funcionará de esa forma. La única será usando un setElementData para el ID,o algo así. Porque desde ya es erróneo. Si bien el vector vehicles posee todos los vehículos. Este, asi mismo, no es otro vector (sería bidimensional). Si no que simplemente, el vehicle puedes conseguir los datos con determinadas funciones. Lo mejor será, o usar setElementData, o ayudarte con la BD

Link to comment

mira tengo estoo

addCommandHandler( { "vehicleid", "thisvehicle" }, 
    function( player, commandName ) 
        local vehicle = getPedOccupiedVehicle( player ) 
        if vehicle then 
            local vehicleID = vehicles[ vehicle ] and vehicles[ vehicle ].vehicleID 
            if vehicleID then 
                outputChatBox( "El ID de este  " .. getVehicleName( vehicle ) .. " is " .. vehicleID .. ".", player, 0, 255, 0 ) 
            else 
                outputChatBox( "Este " .. getVehicleName( vehicle ) .. " no tiene ID.", player, 255, 0, 0 ) 
            end 
        else 
            outputChatBox( "No estas en ninguno coche.", player, 255, 0, 0 ) 
        end 
    end 
) 
  
addCommandHandler( { "oldvehicleid", "oldvehicle" }, 
    function( player, commandName ) 
        local vehicle = p[ player ] and p[ player ].oldVehicle 
        if vehicle and isElement( vehicle ) then 
            local vehicleID = vehicles[ vehicle ] and vehicles[ vehicle ].vehicleID 
            if vehicleID then 
                outputChatBox( "El ID de tu viejo vehiculo es " .. getVehicleName( vehicle ) .. " is " .. vehicleID .. ".", player, 0, 255, 0 ) 
            else 
                outputChatBox( "This " .. getVehicleName( vehicle ) .. " has no ID.", player, 255, 0, 0 ) 
            end 
        else 
            outputChatBox( "You haven't been in any vehicle.", player, 255, 0, 0 ) 
        end 
    end 
) 

Es lo que saca el ID de el coche como pasarlo a mi script?

Link to comment

Server:

addCommandHandler("mirarid", 
function ( playerSource ) 
setElementData(playerSource, "mirarid.on", true) 
end 
) 
  
addEventHandler("onPlayerContact", getRootElement(), 
function (prev, act) 
if ( getElementType(act) == "vehicle" ) and ( getElementData( source, "mirarid.on") == true ) then 
       local vehicleID = vehicles[ act ] and vehicles[ act ].vehicleID 
                if vehicleID then 
outputChatBox( "ID de Este Vehiculo: "..vehicleID, source, 255,255,0, true) 
             end 
        end 
  end 
) 

Link to comment
  • Recently Browsing   0 members

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