Jump to content

Ayuda script no reconocido por el server


Recommended Posts

hola necesito ayuda este script lo hize yo pero por alguna razon no es detectado en el servidor de mta

este es el .lua

local marker = nil -- Variable para almacenar el marcador del garage
local vehiclePositions = {} -- Almacena las posiciones de los vehículos en el garage

-- Función para guardar el tuning del vehículo
local function saveTuning(vehicle)
    local tuning = getVehicleUpgrades(vehicle) -- Obtiene el tuning del vehículo
    vehiclePositions[vehicle] = {tuning = tuning, position = {getElementPosition(vehicle)}} -- Guarda el tuning y la posición del vehículo
end

-- Función para restaurar el tuning del vehículo
local function restoreTuning(vehicle)
    local data = vehiclePositions[vehicle] -- Obtiene los datos guardados del vehículo
    if data then
        setVehicleUpgrades(vehicle, data.tuning) -- Restaura el tuning del vehículo
        setElementPosition(vehicle, unpack(data.position)) -- Restaura la posición del vehículo
    end
end

-- Función para crear el marcador en un lugar aleatorio
local function createRandomMarker()
    if marker then
        destroyElement(marker) -- Destruye el marcador existente
    end
    local x, y, z = math.random(-2000, 2000), math.random(-2000, 2000), math.random(0, 200) -- Genera coordenadas aleatorias
    marker = createMarker(x, y, z, "cylinder", 1.5, 255, 0, 0, 150) -- Crea el marcador en la ubicación aleatoria con color rojo
    setMarkerColor(marker, 0, 0, 0, 255) -- Establece el color de los bordes a negro
end

-- Evento al entrar al marcador del garage
addEventHandler("onMarkerHit", marker, function(hitElement, matchingDimension)
    if matchingDimension and getElementType(hitElement) == "vehicle" then
        saveTuning(hitElement) -- Guarda el tuning del vehículo al entrar al garage
    end
end)

-- Evento al salir del marcador del garage
addEventHandler("onMarkerLeave", marker, function(leftElement, matchingDimension)
    if matchingDimension and getElementType(leftElement) == "vehicle" then
        restoreTuning(leftElement) -- Restaura el tuning del vehículo al salir del garage
    end
end)

-- Crea el marcador aleatorio al iniciar el recurso
addEventHandler("onResourceStart", resourceRoot, function()
    createRandomMarker()
end)

-- Crea un nuevo marcador aleatorio cada 30 minutos (1800000 milisegundos)
setTimer(createRandomMarker, 1800000, 0)
 

 

este el .xml

 

<meta>
    <info author="ThomasShelby" description="Script de garage para MTA" />
    <script src="garage_script.lua" />
</meta>
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...