-
Posts
155 -
Joined
-
Last visited
-
Days Won
1
Everything posted by xMKHx
-
Bro post the code so we can help !
-
You can see player's Img mods and custom skins and models using your admin panel
-
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
-
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)
-
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 )
- 1 reply
-
- lua
- scripting help
-
(and 1 more)
Tagged with:
-
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
-
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
-
Hello, can you please post your code.
-
Check if the problem in the host or your resources
-
Client and server sides and meta.xml
-
Post your code and meta please
-
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)
-
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)
-
There is a lot of examples on wiki https://wiki.multitheftauto.com/wiki/AddDebugHook
-
You can search for free php inventory templates on internet and use mysql to manage data I made a search and I've found this https://www.sourcecodester.com/php/15419/simple-inventory-management-system-phpoop-free-source-code.html Its just an exmple but you have to make your own efforts
-
What do you exactly want to do ?
-
You may use a glue system Try mine local glues = {} function glue (plr, cmd) local veh = getPedContactElement(plr) if (getElementData(plr, "glue") == false) then -- Boolean again >_< if isElement(veh) and (getElementType(veh) == "vehicle") then local px, py, pz = getElementPosition(plr) local vx, vy, vz = getElementPosition(veh) local sx = px - vx local sy = py - vy local sz = pz - vz local rotpX = 0 local rotpY = 0 local rotpZ = getElementRotation(plr) local rotvX,rotvY,rotvZ = getVehicleRotation(veh) local t = math.rad(rotvX) local p = math.rad(rotvY) local f = math.rad(rotvZ) local ct = math.cos(t) local st = math.sin(t) local cp = math.cos(p) local sp = math.sin(p) local cf = math.cos(f) local sf = math.sin(f) local z = ct*cp*sz + (sf*st*cp + cf*sp)*sx + (-cf*st*cp + sf*sp)*sy local x = -ct*sp*sz + (-sf*st*sp + cf*cp)*sx + (cf*st*sp + sf*cp)*sy local y = st*sz - sf*ct*sx + cf*ct*sy local rotX = rotpX - rotvX local rotY = rotpY - rotvY local rotZ = rotpZ - rotvZ attachElements(plr, veh, x,y,z, rotX, rotY, rotZ) setElementData(plr, "glue", true) glues[plr] = veh end else if (isElement(glues[plr])) then detachElements(plr, glues[plr]) setElementData(plr, "glue", false) end end end addCommandHandler("glue", glue)
-
You can try this addCommandHandler( "brake", function ( thePlayer ) local theVehicle = getPedOccupiedVehicle( thePlayer ) if ( theVehicle ) then if ( isVehicleDamageProof( theVehicle ) ) then outputChatBox("Your vehicle is no longer damageproof!", thePlayer, 0, 255, 0) setVehicleDamageProof( theVehicle, false ) else outputChatBox("Your vehicle is now damageproof!", thePlayer, 0, 255, 0) setVehicleDamageProof( theVehicle, true ) end end end )
-
You can use setElementData For Example: function changeFreq (freq) if getElementData(source, "freq") == freq then return outputChatBox("You're already on "..freq.." frequency !", source, 255, 0, 0) end setElementData(source, "freq", freq) outputChatBox("You are now on "..freq.." frequency.", source, 0, 255, 0) end addCommandHandler("freq", changeFreq) function freqChat(plr, command, ...) if getElementData(plr, "freq") == false then return outputChatBox("Get a frequency first by using /freq <freqNumber>, For example /freq 3", plr, 255, 0, 0) end local freq = "( "..getElementData(plr, "freq").." )" local message = table.concat({...}, " ") local fullMessage = freq.." "..getPlayerName(plr)..": "..message:gsub("#%x%x%x%x%x%x", "") for i, v in ipairs(getElementsByType("player")) do if (getElementData(v, "freq") == getElementData(plr, "freq")) then outputChatBox(fullMessage, v, 255, 255, 255, true) end end end addCommandHandler("fc", freqChat) Note: I didn't test the code
-
LOT_NUM_LIMIT = 10 -- What is the higher lottery number .
-
Hello Community, Hello Legends, How you doing, I hope you're all alright. Well am gonna directly talk hh I've been playing MTA for 10 years since 2010 to 2020 and like most of you we've started like newbies then we upgrade ourselves by the time. As you know most of ppl are focusing on FiveM, no comparison here, quality, cars models and reality..etc. Well I had a server before, I was having fun, we all grown up with MTA and we all have memories, we've made a lot of friends, we've got virtual relations and some ppl got a real one. Well as I can see there's nothing new in MTA, I've spent a lot of time playing and scripting, I made new graphic mods to make the game enjoyable but no results, What I would say that day by day this game is dying, We may have to support the community to improve the game performance, Some ads may help too. Am a lover and a supporter, I would like to get back but work and responsibilities took all ma'time so A message to the community admins, please survive the game and thanks. - Best regards