Advertisement
TheBakkeseKing

Bug armas

Jan 25th, 2024
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.83 KB | Gaming | 0 0
  1. function tirarArmaCommandHandler(source, command, cantidad)
  2. local cooldownTime = 5000 -- 5000 milisegundos = 5 segundos
  3. if isOnCooldown(source, command, cooldownTime) then
  4. outputChatBox("Debes esperar antes de volver a usar este comando.", source)
  5. return
  6. end
  7.  
  8. local DataPJ = exports["MR2_Cuentas"]:getValueOne(source)
  9. local Inventario = DataPJ.Inventario
  10. local weaponID = getPedWeapon(source)
  11. if not (weaponID) then
  12. return outputChatBox("--------#ffe100No puedo soltar mis puños, no soy Rayman...", source, 255, 255, 255, true)
  13. end
  14. outputChatBox(""..weaponID.."", source)
  15. if not (weaponID > 0) then
  16. return outputChatBox("#ffe100No puedo soltar mis puños, no soy Rayman...", source, 255, 255, 255, true)
  17. end
  18. if (Inventario.Weapons[""..weaponID..""]) then
  19. local ammoToDrop = tonumber(cantidad) or Inventario.Weapons[""..weaponID..""]
  20. if (ammoToDrop > Inventario.Weapons[""..weaponID..""] ) then
  21. return outputChatBox("#ffe100No tengo tanta municion...", source, 255, 255, 255, true)
  22. end
  23.  
  24. Inventario.Weapons[""..weaponID..""] = Inventario.Weapons[""..weaponID..""] - ammoToDrop
  25. exports["MR2_Cuentas"]:setValue(source, 'Inventario', Inventario)
  26. takeWeapon(source, weaponID, ammoToDrop)
  27. -- Obtener la posición del jugador
  28. local x, y, z = getElementPosition(source)
  29. local dim = getElementDimension(source)
  30. local int = getElementInterior(source)
  31.  
  32. -- Crear un objeto que represente el arma en el suelo
  33. local droppedWeapon = createObject(2969, x, y, z - 0.9) -- Ajusta la posición según sea necesario
  34. local markerArmaTirada = createMarker(x, y, z, "cylinder", 1, 250, 250, 250, 0)
  35. setElementInterior(droppedWeapon, int)
  36. setElementInterior(markerArmaTirada, int)
  37. setElementDimension(droppedWeapon, dim)
  38. setElementDimension(markerArmaTirada, dim)
  39. setElementParent( droppedWeapon, markerArmaTirada )
  40. setElementParent( markerArmaTirada, WeaponsTiradas )
  41. setElementCollisionsEnabled(droppedWeapon, false)
  42. weaponsGrounds[markerArmaTirada] = {pos = {x, y, z, int, dim}, wID = weaponID, ammo = ammoToDrop, droppedBy = getPlayerName(source)}
  43. return outputChatBox("#ffe100He tirado "..ammoToDrop.." balas de "..getWeaponNameFromID(weaponID).."...", source, 255, 255, 255, true)
  44. else
  45. takeWeapon(source, weaponID)
  46. end
  47. end
Tags: lua MTA SA
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement