funkcja repeat, zamykanie

0

Witam, zrobilismy funkcje repeat, ze jeśli jest jaka kolwiek amunicja w eq to usuwa klamke, odrodzenie stopuje usuwanie broni, ale funkcja nie chce sie zatrzymac i usuwa caly czas klamke jaka kolwiek sie dostanie (kod jest od skryptu do fivem)

	elseif itemType == 'item_weapon' then
    if amount == nil then amount = 0 end
    sourceXPlayer.addWeapon   (itemName, amount)
    TriggerClientEvent('esx:showNotification', _source, _U('you_confiscated_weapon', ESX.GetWeaponLabel(itemName), targetXPlayer.name, amount))
    TriggerClientEvent('esx:showNotification', target,  _U('got_confiscated_weapon', ESX.GetWeaponLabel(itemName), amount, sourceXPlayer.name))
		local result = MySQL.Sync.fetchAll("SELECT	isDead FROM users   WHERE identifier=@identifier",
		{
			['@identifier'] = GetPlayerIdentifiers(target)[1],
		})
		local dead = result[1].isDead
		
    repeat
      Citizen.Wait(5000)
      if amount >= 1 then
				jest = false
				targetXPlayer.removeWeapon(itemName, amount)
				TriggerClientEvent('esx:showNotification', target,  '~h~~r~Zabrało')
				if result[1].isDead == 0 then
					amount = nil 
				end	
			elseif	amount == nil then
				jest = true 
				TriggerClientEvent('esx:showNotification', target,  '~h~~r~Działa')
        break
      end
    until jest       
    

    
    
		
	end
end)

mógłby ktoś doradzić jak dorobić do tego funkcje zamykania Tego?

0

0 a nil to dwa rozne stany. sa w sumie 3 stany 1, 0 , null
jesli robisz elseif amount == nil a amount == 0 to moze nie wpadac do tego warunku

1 użytkowników online, w tym zalogowanych: 0, gości: 1