Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function tirarArmaCommandHandler(source, command, cantidad)
- local cooldownTime = 5000 -- 5000 milisegundos = 5 segundos
- if isOnCooldown(source, command, cooldownTime) then
- outputChatBox("Debes esperar antes de volver a usar este comando.", source)
- return
- end
- local DataPJ = exports["MR2_Cuentas"]:getValueOne(source)
- local Inventario = DataPJ.Inventario
- local weaponID = getPedWeapon(source)
- if not (weaponID) then
- return outputChatBox("--------#ffe100No puedo soltar mis puños, no soy Rayman...", source, 255, 255, 255, true)
- end
- outputChatBox(""..weaponID.."", source)
- if not (weaponID > 0) then
- return outputChatBox("#ffe100No puedo soltar mis puños, no soy Rayman...", source, 255, 255, 255, true)
- end
- if (Inventario.Weapons[""..weaponID..""]) then
- local ammoToDrop = tonumber(cantidad) or Inventario.Weapons[""..weaponID..""]
- if (ammoToDrop > Inventario.Weapons[""..weaponID..""] ) then
- return outputChatBox("#ffe100No tengo tanta municion...", source, 255, 255, 255, true)
- end
- Inventario.Weapons[""..weaponID..""] = Inventario.Weapons[""..weaponID..""] - ammoToDrop
- exports["MR2_Cuentas"]:setValue(source, 'Inventario', Inventario)
- takeWeapon(source, weaponID, ammoToDrop)
- -- Obtener la posición del jugador
- local x, y, z = getElementPosition(source)
- local dim = getElementDimension(source)
- local int = getElementInterior(source)
- -- Crear un objeto que represente el arma en el suelo
- local droppedWeapon = createObject(2969, x, y, z - 0.9) -- Ajusta la posición según sea necesario
- local markerArmaTirada = createMarker(x, y, z, "cylinder", 1, 250, 250, 250, 0)
- setElementInterior(droppedWeapon, int)
- setElementInterior(markerArmaTirada, int)
- setElementDimension(droppedWeapon, dim)
- setElementDimension(markerArmaTirada, dim)
- setElementParent( droppedWeapon, markerArmaTirada )
- setElementParent( markerArmaTirada, WeaponsTiradas )
- setElementCollisionsEnabled(droppedWeapon, false)
- weaponsGrounds[markerArmaTirada] = {pos = {x, y, z, int, dim}, wID = weaponID, ammo = ammoToDrop, droppedBy = getPlayerName(source)}
- return outputChatBox("#ffe100He tirado "..ammoToDrop.." balas de "..getWeaponNameFromID(weaponID).."...", source, 255, 255, 255, true)
- else
- takeWeapon(source, weaponID)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement