Jump to content

xMKHx

Members
  • Posts

    154
  • Joined

  • Last visited

  • Days Won

    1

xMKHx last won the day on February 28

xMKHx had the most liked content!

1 Follower

About xMKHx

  • Birthday 04/02/2000

Details

  • Gang
    NoGang
  • Location
    Tunisia
  • Occupation
    Lua Programmer
  • Interests
    Nothing :)

Recent Profile Visitors

3,693 profile views

xMKHx's Achievements

Busta

Busta (15/54)

23

Reputation

  1. You can see player's Img mods and custom skins and models using your admin panel
  2. You can search in the community, follow this link: https://community.multitheftauto.com/index.php?p=resources&s=list&name=save&descr=&category=&web_form_name=[object+HTMLInputElement]&web_form_page=https%3A%2F%2Fcommunity.multitheftauto.com%2Findex.php%3Fp%3Dresources&page=1
  3. Try this one Client.lua local inventario = { ["THC"] = 0, ["LSD"] = 0, ["Cocaina"] = 0, ["Heroina"] = 0 } local productosVendedor = {"THC", "LSD", "Cocaina", "Heroina"} local precios = { ["THC"] = 500, ["LSD"] = 500, ["Cocaina"] = 500, ["Heroina"] = 500 } local ventana, lista, usarButton, cerrarButton -- Función para abrir el menú de compra function abrirMenuDeCompra() ventana = guiCreateWindow(0.3, 0.3, 0.4, 0.5, "Menu de Compra", true) lista = guiCreateGridList(0.1, 0.2, 0.8, 0.5, true, ventana) local columnaProducto = guiGridListAddColumn(lista, "Producto", 0.6) local columnaPrecio = guiGridListAddColumn(lista, "Precio", 0.3) for i, producto in ipairs(productosVendedor) do local row = guiGridListAddRow(lista) guiGridListSetItemText(lista, row, columnaProducto, producto, false, false) guiGridListSetItemText(lista, row, columnaPrecio, "$"..precios[producto], false, false) end local comprarButton = guiCreateButton(0.1, 0.75, 0.8, 0.1, "Comprar Producto", true, ventana) guiSetProperty(comprarButton, "NormalTextColour", "FF0000FF") -- Botón en rojo cerrarButton = guiCreateButton(0.1, 0.88, 0.8, 0.1, "Cerrar", true, ventana) guiSetProperty(cerrarButton, "NormalTextColour", "FFFFFFFF") -- Botón de cerrar -- Evento para comprar productos addEventHandler("onClientGUIClick", comprarButton, function() local selectedItem = guiGridListGetSelectedItem(lista) if selectedItem ~= -1 then local producto = guiGridListGetItemText(lista, selectedItem, columnaProducto) triggerServerEvent("comprarProducto", resourceRoot, producto) end end, false) addEventHandler("onClientGUIClick", cerrarButton, function() if isElement(ventana) then destroyElement(ventana) showCursor(false) end end, false) showCursor(true) end addEvent("abrirMenuDeCompra", true) addEventHandler("abrirMenuDeCompra", resourceRoot, abrirMenuDeCompra) -- Función para agregar el producto al inventario del jugador function agregarProductoAlInventario(producto) if inventario[producto] then inventario[producto] = inventario[producto] + 1 else inventario[producto] = 1 end actualizarPanelDeInventario() end addEvent("agregarProductoAlInventario", true) addEventHandler("agregarProductoAlInventario", resourceRoot, agregarProductoAlInventario) -- Función para mostrar mensaje de compra fallida function mostrarMensajeCompraFallida() outputChatBox("No tienes suficiente dinero para comprar este producto.", 255, 0, 0, true) end addEvent("mostrarMensajeCompraFallida", true) addEventHandler("mostrarMensajeCompraFallida", resourceRoot, mostrarMensajeCompraFallida) -- Función para mostrar mensaje de compra exitosa function mostrarMensajeCompraExitosa(producto) outputChatBox("Compra exitosa de " .. producto .. ". ¡Gracias por tu compra!", 0, 255, 0, true) end addEvent("mostrarMensajeCompraExitosa", true) addEventHandler("mostrarMensajeCompraExitosa", resourceRoot, mostrarMensajeCompraExitosa) -- Función para abrir/cerrar el panel de inventario (F2) function togglePanelDeInventario() if isElement(ventana) then destroyElement(ventana) showCursor(false) else ventana = guiCreateWindow(0.3, 0.3, 0.4, 0.5, "Inventario de Drogas", true) lista = guiCreateGridList(0.1, 0.2, 0.8, 0.5, true, ventana) local columnaProducto = guiGridListAddColumn(lista, "Producto", 0.6) local columnaCantidad = guiGridListAddColumn(lista, "Cantidad", 0.3) for producto, cantidad in pairs(inventario) do local row = guiGridListAddRow(lista) guiGridListSetItemText(lista, row, columnaProducto, producto, false, false) guiGridListSetItemText(lista, row, columnaCantidad, tostring(cantidad), false, false) if cantidad == 0 then guiGridListSetItemColor(lista, row, columnaCantidad, 255, 255, 255) -- Texto blanco else guiGridListSetItemColor(lista, row, columnaCantidad, 0, 0, 0) -- Texto negro end end usarButton = guiCreateButton(0.1, 0.75, 0.8, 0.1, "Usar Producto", true, ventana) guiSetProperty(usarButton, "NormalTextColour", "FF0000FF") -- Botón en rojo cerrarButton = guiCreateButton(0.1, 0.88, 0.8, 0.1, "Cerrar", true, ventana) guiSetProperty(cerrarButton, "NormalTextColour", "FFFFFFFF") -- Botón de cerrar addEventHandler("onClientGUIClick", usarButton, function() local selectedItem = guiGridListGetSelectedItem(lista) if selectedItem ~= -1 then local producto = guiGridListGetItemText(lista, selectedItem, columnaProducto) if inventario[producto] > 0 then usarProducto(producto) inventario[producto] = inventario[producto] - 1 actualizarPanelDeInventario() else outputChatBox("Debes ir al vendedor para comprar " .. producto, 255, 0, 0, true) end end end, false) addEventHandler("onClientGUIClick", cerrarButton, function() if isElement(ventana) then destroyElement(ventana) showCursor(false) end end, false) showCursor(true) end end bindKey("F2", "down", togglePanelDeInventario) -- Función para usar el producto seleccionado function usarProducto(producto) if producto == "THC" then outputChatBox("Usaste THC", 255, 0, 0, true) -- Aplica efectos de THC elseif producto == "LSD" then outputChatBox("Usaste LSD", 0, 255, 0, true) -- Aplica efectos de LSD elseif producto == "Cocaina" then outputChatBox("Usaste Cocaina", 255, 255, 0, true) -- Aplica efectos de Cocaina elseif producto == "Heroina" then outputChatBox("Usaste Heroina", 128, 0, 128, true) -- Aplica efectos de Heroina end end -- Función para actualizar el panel de inventario function actualizarPanelDeInventario() if isElement(ventana) then destroyElement(ventana) togglePanelDeInventario() end end Server.lua -- Crea un vendedor en una ubicación específica local vendedor = createPed(50, 2165.93, 1696.37, 10.82) -- Congela el vendedor para que no se mueva ni muera setElementFrozen(vendedor, true) setElementData(vendedor, "invincible", true) -- Crea un marker (área de interacción) cerca del vendedor local marketMarker = createMarker(2165.93, 1696.37, 10.10, "cylinder", 1.5, 255, 0, 0, 150) -- Función para mostrar el menú de compra function mostrarMenuDeCompra(player) triggerClientEvent(player, "abrirMenuDeCompra", resourceRoot) end -- Función para manejar la compra de productos function comprarProducto(player, producto) local precio = 500 if getPlayerMoney(player) >= precio then takePlayerMoney(player, precio) triggerClientEvent(player, "agregarProductoAlInventario", resourceRoot, producto) triggerClientEvent(player, "mostrarMensajeCompraExitosa", resourceRoot, producto) else triggerClientEvent(player, "mostrarMensajeCompraFallida", resourceRoot) end end -- Evento para mostrar el menú de compra cuando el jugador entra en el marker addEventHandler("onMarkerHit", marketMarker, function(player) if getElementType(player) == "player" then mostrarMenuDeCompra(player) end end) -- Evento para manejar la compra de productos addEvent("comprarProducto", true) addEventHandler("comprarProducto", resourceRoot, comprarProducto) -- Hacer al ped invulnerable addEventHandler("onPedWasted", root, function() if source == vendedor then cancelEvent() end end) addEventHandler("onClientPedDamage", root, function() if source == vendedor then cancelEvent() end end)
  4. addEventHandler("onResourceStart", resourceRoot, function() -- Replace the car model (ID 411 is the Infernus model, you can change it) local modelID = 411 -- Model ID to replace (e.g., 411 for Infernus) local dffFile = "path/to/your/car.dff" -- Path to the DFF file local txdFile = "path/to/your/car.txd" -- Path to the TXD file -- Load the TXD file local txd = engineImportTXD(txdFile) engineReplaceModel(txd, modelID) -- Load the DFF file local dff = engineLoadDFF(dffFile, modelID) engineReplaceModel(dff, modelID) end )
  5. I've used DeepSeek to fix your code, there is this result: -- Define the bomb function function bomb(player) local car = getPedOccupiedVehicle(player) if getElementModel(car) == 520 then outputChatBox("Сброс бомб", player) local x, y, z = getElementPosition(player) setTimer(AirstrikeThrow, 51, 1, player, x, y, z) end end -- Bind the "3" key to the bomb function for each player when they spawn or enter the vehicle function bindBombKey(player) bindKey(player, "3", "down", bomb) end -- Add event handlers to bind the key when the player spawns or enters a vehicle addEventHandler("onPlayerJoin", root, bindBombKey) addEventHandler("onVehicleEnter", root, function(player) bindBombKey(player) end) -- Define the AirstrikeThrow function function AirstrikeThrow(player, x, y, z) triggerClientEvent(getRootElement(), "AirstrikeThrowDo", getRootElement(), player) end
  6. Client-Side: -- Function to check ammo and reload function checkAmmoAndReload() -- Get the player's current weapon local weapon = getPedWeapon(localPlayer) -- Get the ammo in the player's clip local ammoInClip = getPedAmmoInClip(localPlayer) -- Get the total ammo the player has for the current weapon local totalAmmo = getPedTotalAmmo(localPlayer) -- If the clip is empty but the player has more ammo, reload the weapon if ammoInClip == 0 and totalAmmo > 0 then triggerServerEvent("onPlayerReloadWeapon", localPlayer) end end -- Event handler for when the player fires a weapon addEventHandler("onClientPlayerWeaponFire", localPlayer, checkAmmoAndReload) Server-Side: -- Event to handle weapon reloading addEvent("onPlayerReloadWeapon", true) addEventHandler("onPlayerReloadWeapon", root, function() -- Get the player's current weapon local weapon = getPedWeapon(source) -- Reload the weapon setPedWeaponSlot(source, getPedWeaponSlot(source)) end) I don't know if it's working, I just asked DeepSeek and this is the result.. Have fun
  7. Hello, can you please post your code.
  8. Check if the problem in the host or your resources
  9. Client and server sides and meta.xml
  10. I didn't try to code at first But I made some change, I think it will work now I've changed the col location to test, you can change it later Try this one server side greenzone = createColRectangle ( 1400.2144775391,1425.1593017578, 100, 100 ) greenzoneradar = createRadarArea ( 1400.2144775391,1425.1593017578, 100, 100, 255, 255, 0, 150 ) function Col_Enter ( thePlayer, matchingDimension ) if getElementType ( thePlayer ) == "player" then setElementData(thePlayer, "isInGreenZone", true) setRadarAreaFlashing ( greenzoneradar, true ) setTimer(giveMoneyToPlayers, 1000, 0, thePlayer) outputChatBox( "#FFFFFF* #00FF00You've entered the money zone!", thePlayer, 255, 255, 109, true ) end end addEventHandler ( "onColShapeHit", greenzone, Col_Enter ) function Col_Exit ( thePlayer, matchingDimension ) if getElementType ( thePlayer ) == "player" then setElementData(thePlayer, "isInGreenZone", false) setRadarAreaFlashing ( greenzoneradar, false ) outputChatBox ( "#FFFFFF* #FF0000You've left the money zone!", playerSource, 255, 255, 109, true ) end end addEventHandler ( "onColShapeLeave", greenzone, Col_Exit ) function giveMoneyToPlayers (thePlayer) if getElementData(thePlayer, "isInGreenZone") == false then return false end givePlayerMoney(thePlayer, 5) end I've re-checked the code and found an issue Try this version I hope it helps you greenzone = createColRectangle ( 1400.2144775391,1425.1593017578, 100, 100 ) greenzoneradar = createRadarArea ( 1400.2144775391,1425.1593017578, 100, 100, 255, 255, 0, 150 ) function Col_Enter ( thePlayer, matchingDimension ) if getElementType ( thePlayer ) == "player" then setElementData(thePlayer, "isInGreenZone", true) setRadarAreaFlashing ( greenzoneradar, true ) outputChatBox( "#FFFFFF* #00FF00You've entered the money zone!", thePlayer, 255, 255, 109, true ) end end addEventHandler ( "onColShapeHit", greenzone, Col_Enter ) function Col_Exit ( thePlayer, matchingDimension ) if getElementType ( thePlayer ) == "player" then setElementData(thePlayer, "isInGreenZone", false) setRadarAreaFlashing ( greenzoneradar, false ) outputChatBox ( "#FFFFFF* #FF0000You've left the money zone!", playerSource, 255, 255, 109, true ) resetTimer(timer) end end addEventHandler ( "onColShapeLeave", greenzone, Col_Exit ) timer = setTimer(function(thePlayer) for i, v in ipairs(getElementsByType("player")) do if getElementData(v, "isInGreenZone") == false then return false end givePlayerMoney(v, 5) end end ,1000, 0, thePlayer)
  11. Try this local greenzone = createColRectangle ( 1995.224609375, 1516.697265625, 11, 45 ) local greenzoneradar = createRadarArea ( 1993.91796875, 1567.671875, 50, -100, 255, 255, 0, 150 ) function Col_Enter ( thePlayer, matchingDimension ) if getElementType ( thePlayer ) == "player" then setElementData(thePlayer, "isInGreenZone", true) setRadarAreaFlashing ( greenzoneradar, true ) outputChatBox( "#FFFFFF* #00FF00You've entered the money zone!", thePlayer, 255, 255, 109, true ) end end addEventHandler ( "onColShapeHit", greenzone, Col_Enter ) function Col_Exit ( thePlayer, matchingDimension ) if getElementType ( thePlayer ) == "player" then setElementData(thePlayer, "isInGreenZone", false) setRadarAreaFlashing ( greenzoneradar, false ) outputChatBox ( "#FFFFFF* #FF0000You've left the money zone!", playerSource, 255, 255, 109, true ) end end addEventHandler ( "onColShapeLeave", greenzone, Col_Exit ) setTimer(function() for i,v in ipairs(getElementsByType("player")) do if getElementData(v, "isInGreenZone") == false then return false end givePlayerMoney(v, 5) end end, 1000, 1)
  12. There is a lot of examples on wiki https://wiki.multitheftauto.com/wiki/AddDebugHook
×
×
  • Create New...