Jump to content

Airdrop


Recommended Posts

Oi, eu gostaria de deixar os spawns fixos do meu airdrop por exemplo: quando ele cair ele dropar todos itens que estão na lista, porém sempre em quantidades randomicas, ele esta dropando apenas 2 itens por caida 2/3 não consegui retirar isso !

spawnLocations = {
{1453.4388427734,1366.4683837891,11.410042762756},
{1557.2806396484,-2544.9809570313,14.210131645203},
{-1326.8874511719,-107.98781585693,14.809633255005},
{155.93667602539,2488.990234375,17.181993484497},
{1260.1999511719,-2029.9000244141,59.799999237061},
{-218.19999694824,-215.69999694824,1.7999999523163},
{1287.5,250.89999389648,19.799999237061},
{2343.8000488281,-30.10000038147,26.700000762939},
{2782.8000488281,1282.4000244141,11.10000038147},
{2496.3000488281,2509.8000488281,22.200000762939},
{-1495.5,2669.6000976563,56.099998474121},
{-2122.6000976563,-129.10000610352,35.700000762939},
{-2421.8000488281,-608,132.89999389648},
{683.29998779297,-530.70001220703,16.5},
}

lootItems = {
{"M9 SD",50},
}

function math.percentChance(percent,repeatTime)
  local hits = 0
  for i = 1,repeatTime do
	local number = math.random(1,1000)/10
	if number <= percent then
	  hits = hits+1
	end
  end
  return hits
end

respawnAirdropTimer = false
function spawnAirdrop(player)
  if isElement(player) and not isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)),aclGetGroup("Admin"))then
	return
  end
  if isElement(productq) then
	destroyElement(productq)
  end
  if isElement(avialColq) then
	destroyElement(avialColq)
  end
  if isElement(blipq) then
	destroyElement(blipq)
  end
  if isTimer(respawnAirdropTimer)then
	killTimer(respawnAirdropTimer)
  end
  respawnAirdropTimer = setTimer(spawnAirdrop,3600000,1)
  outputChatBox("#FFF000[SUPPLY]: #FF0000A CAIXA COM SUPRIMENTOS [BÁSICOS] FOI LARGADA!", getRootElement(), 255,255,255, true)  
  local item_id = math.random(1,#spawnLocations)
  xq,yq,zq = spawnLocations[item_id][1],spawnLocations[item_id][2],spawnLocations[item_id][3]-0.16
  xpsq,ypsq,zpsq = xq,yq,zq+7,3
  xpvq,ypvq,zpvq = xq-48,yq-16,zq+37
  xsbq,ysbq,zsbq = xq-48,yq-16,zq+41
  xssq,yssq,zssq = xq-528,yq+2,zq+141
  xsdq,ysdq,zsdq = xq+528,yq+2,zq+141
  blipq = createBlip(xq,yq,zq,5)
  aviaNavaq = createObject(1683,xssq,yssq,zssq,0,0,0)
  moveObject(aviaNavaq,8000,xsbq,ysbq,zsbq)
  setTimer(function()
	parasProdq = createObject(2903,xpvq,ypvq,zpvq,0,0,0)
	moveObject(aviaNavaq,8000,xsdq,ysdq,zsdq)
	moveObject(parasProdq,11000,xpsq,ypsq,zpsq)
	triggerClientEvent("playAirdropSound",getRootElement())
  end,8000,1)
  setTimer(destroyElement,16100,1,aviaNavaq)
  setTimer(function()
	destroyElement(parasProdq)
	productq = createObject(2669,xq,yq,zq,0,0,0)
	setElementFrozen(productq,true)
	avialColq = createColSphere(xq,yq,zq,2)
	attachElements(avialColq,productq,0,0,0)
	setElementData(avialColq,"parent",object)
	setElementData(avialColq,"hospitalbox",true)
	setElementData(avialColq,"MAX_Slots",0)
    setElementData(avialColq "M4", 50)
	setElementData(avialColq "M4 Mag",2)
    setElementData(avialColq "CZ 550", 50)
    setElementData(avialColq "CZ 550 Mag", 50)
    setElementData(avialColq "AK-47", 50)
    setElementData(avialColq "AK Mag", 50)
    setElementData(avialColq "Milk", 50)
	for i,item in pairs(lootItems)do
	  local value =  math.percentChance(item[2],1)
	  if value >= 1 then
		setElementData(avialColq,item[1],value)
--		local ammoData,weapID = getWeaponAmmoType(item[1],true)
		if ammoData then
		  local minBullets,maxBullets = math.floor(getAmmoPlus(ammoData)/3),getAmmoPlus(ammoData)*2
		  local ammoQuantity = math.random(minBullets,maxBullets)
		  setElementData(avialColq,ammoData,ammoQuantity)
		end
	  end
	end
  end,23100,1)
end
spawnAirdrop()
addCommandHandler("spawnairdrop",spawnAirdrop) 

addCommandHandler("removeairdrop",function(player)
  if not isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)),aclGetGroup("Admin"))then
	return
  end
  if isElement(productq) then
	destroyElement(productq)
  end
  if isElement(avialColq) then
	destroyElement(avialColq)
  end
  if isElement(blipq) then
	destroyElement(blipq)
  end
  if isTimer(respawnAirdropTimer)then
	killTimer(respawnAirdropTimer)
  end
end) 

 

Link to comment

Quais itens? Eles estão na tabela lootItems? Nela só vejo 1.

Se eu entendi corretamente, é só dar um loop na tabela de itens e mudar a quantidade usando math.random.

EDIT: Da próxima vez faça o post na área correta.

Edited by DNL291
  • Like 1
Link to comment
12 hours ago, DNL291 said:

Quais itens? Eles estão na tabela lootItems? Nela só vejo 1.

Se eu entendi corretamente, é só dar um loop na tabela de itens e mudar a quantidade usando math.random.

EDIT: Da próxima vez faça o post na área correta.

Na tabela lootItems eu adiciono as armas , e as quantidades? aonde eu adiciono? quero que seja padrão , porém quero que somente as armas venham randomicas, por exemplo: num spawn veio SNIPER e os demais itens, no outro não vem pneu, nem Sniper só 1 exemplo

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...