Jump to content
Sign in to follow this  
WVWMK

[Скрипт]Случайный дроп мануфактуры и кулинарии

Recommended Posts

ItemEffect.lua

--Мануфакт
--1
function ItemUse_Mano( role, Item )
   local ItemCanGetSlot = GetChaFreeBagGridNum ( role )
   if ItemCanGetSlot < 1 then
    SystemNotice(role, "У вас не хватает слотов в инвентаре для распаковки сундука!")
    UseItemFailed ( role )
    return
	end
	a = math.random(1,24)
	if a == 1 then 
		GiveItem ( role , 0 , 1135 , 10 , 4 )
	elseif a == 2 then 
		GiveItem ( role , 0 , 1136 , 10 , 4 )
	elseif a == 3 then
		GiveItem ( role , 0 , 1137 , 10 , 4 )
	elseif a == 4 then
		GiveItem ( role , 0 , 1138 , 10 , 4 )
	elseif a == 5 then
		GiveItem ( role , 0 , 1139 , 10 , 4 )
	elseif a == 6 then
		GiveItem ( role , 0 , 1140 , 10 , 4 )
	elseif a == 7 then
		GiveItem ( role , 0 , 1141 , 10 , 4 )
	elseif a == 8 then
		GiveItem ( role , 0 , 1142 , 10 , 4 )
	elseif a == 9 then
		GiveItem ( role , 0 , 1143 , 10 , 4 )
	elseif a == 10 then
		GiveItem ( role , 0 , 1144 , 10 , 4 )
	elseif a == 11 then
		GiveItem ( role , 0 , 1145 , 5 , 4 )
	elseif a == 12 then
		GiveItem ( role , 0 , 1146 , 10 , 4 )
	elseif a == 13 then
		GiveItem ( role , 0 , 1147 , 10 , 4 )
	elseif a == 14 then
		GiveItem ( role , 0 , 1148 , 10 , 4 )
	elseif a == 15 then
		GiveItem ( role , 0 , 1149 , 10 , 4 )
	elseif a == 16 then
		GiveItem ( role , 0 , 1150 , 10 , 4 )
	elseif a == 17 then
		GiveItem ( role , 0 , 1151 , 10 , 4 )
	elseif a == 18 then
		GiveItem ( role , 0 , 1152 , 10 , 4 )
	elseif a == 19 then
		GiveItem ( role , 0 , 2673 , 10 , 4 )
	elseif a == 20 then
		GiveItem ( role , 0 , 2674 , 10 , 4 )
	elseif a == 21 then
		GiveItem ( role , 0 , 2675 , 10 , 4 )
	elseif a == 22 then
		GiveItem ( role , 0 , 2676 , 10 , 4 )
	elseif a == 23 then
		GiveItem ( role , 0 , 2677 , 10 , 4 )
	elseif a == 24 then
		GiveItem ( role , 0 , 2678 , 10 , 4 )
		
	end
 end
--2
function ItemUse_Mand( role, Item )
   local ItemCanGetSlot = GetChaFreeBagGridNum ( role )
   if ItemCanGetSlot < 1 then
    SystemNotice(role, "У вас не хватает слотов в инвентаре для распаковки сундука!")
    UseItemFailed ( role )
    return
	end
	a = math.random(1,24)
	if a == 1 then 
		GiveItem ( role , 0 , 2719 , 10 , 4 )
	elseif a == 2 then 
		GiveItem ( role , 0 , 2720 , 10 , 4 )
	elseif a == 3 then
		GiveItem ( role , 0 , 2721 , 10 , 4 )
	elseif a == 4 then
		GiveItem ( role , 0 , 2722 , 10 , 4 )
	elseif a == 5 then
		GiveItem ( role , 0 , 2723 , 10 , 4 )
	elseif a == 6 then
		GiveItem ( role , 0 , 2724 , 10 , 4 )
	elseif a == 7 then
		GiveItem ( role , 0 , 2725 , 10 , 4 )
	elseif a == 8 then
		GiveItem ( role , 0 , 2726 , 10 , 4 )
	elseif a == 9 then
		GiveItem ( role , 0 , 2727 , 10 , 4 )
	elseif a == 10 then
		GiveItem ( role , 0 , 2728 , 10 , 4 )
	elseif a == 11 then
		GiveItem ( role , 0 , 2729 , 4 , 4 )
	elseif a == 12 then
		GiveItem ( role , 0 , 2730 , 10 , 4 )
	elseif a == 13 then
		GiveItem ( role , 0 , 2731 , 10 , 4 )
	elseif a == 14 then
		GiveItem ( role , 0 , 2732 , 10 , 4 )
	elseif a == 15 then
		GiveItem ( role , 0 , 2733 , 10 , 4 )
	elseif a == 16 then
		GiveItem ( role , 0 , 2734 , 10 , 4 )
	elseif a == 17 then
		GiveItem ( role , 0 , 2735 , 10 , 4 )
	elseif a == 18 then
		GiveItem ( role , 0 , 2736 , 10 , 4 )
	elseif a == 19 then
		GiveItem ( role , 0 , 2737 , 10 , 4 )
	elseif a == 20 then
		GiveItem ( role , 0 , 2738 , 10 , 4 )
	elseif a == 21 then
		GiveItem ( role , 0 , 2739 , 10 , 4 )
	elseif a == 22 then
		GiveItem ( role , 0 , 2740 , 10 , 4 )
	elseif a == 23 then
		GiveItem ( role , 0 , 2741 , 10 , 4 )
	elseif a == 24 then
		GiveItem ( role , 0 , 2742 , 10 , 4 )
		
	end
 end
--3
function ItemUse_Mant( role, Item )
   local ItemCanGetSlot = GetChaFreeBagGridNum ( role )
   if ItemCanGetSlot < 1 then
    SystemNotice(role, "У вас не хватает слотов в инвентаре для распаковки сундука!")
    UseItemFailed ( role )
    return
	end
	a = math.random(1,24)
	if a == 1 then 
		GiveItem ( role , 0 , 2743 , 10 , 4 )
	elseif a == 2 then 
		GiveItem ( role , 0 , 2744 , 10 , 4 )
	elseif a == 3 then
		GiveItem ( role , 0 , 2745 , 10 , 4 )
	elseif a == 4 then
		GiveItem ( role , 0 , 2746 , 10 , 4 )
	elseif a == 5 then
		GiveItem ( role , 0 , 2747 , 10 , 4 )
	elseif a == 6 then
		GiveItem ( role , 0 , 2748 , 10 , 4 )
	elseif a == 7 then
		GiveItem ( role , 0 , 2749 , 10 , 4 )
	elseif a == 8 then
		GiveItem ( role , 0 , 2750 , 10 , 4 )
	elseif a == 9 then
		GiveItem ( role , 0 , 2751 , 10 , 4 )
	elseif a == 10 then
		GiveItem ( role , 0 , 2753 , 3 , 4 )
	elseif a == 11 then
		GiveItem ( role , 0 , 2754 , 10 , 4 )
	elseif a == 12 then
		GiveItem ( role , 0 , 2755 , 10 , 4 )
	elseif a == 13 then
		GiveItem ( role , 0 , 2756 , 10 , 4 )
	elseif a == 14 then
		GiveItem ( role , 0 , 2757 , 10 , 4 )
	elseif a == 15 then
		GiveItem ( role , 0 , 2758 , 10 , 4 )
	elseif a == 16 then
		GiveItem ( role , 0 , 2759 , 10 , 4 )
	elseif a == 17 then
		GiveItem ( role , 0 , 2760 , 10 , 4 )
	elseif a == 18 then
		GiveItem ( role , 0 , 2761 , 10 , 4 )
	elseif a == 19 then
		GiveItem ( role , 0 , 2762 , 10 , 4 )
	elseif a == 20 then
		GiveItem ( role , 0 , 2763 , 10 , 4 )
	elseif a == 21 then
		GiveItem ( role , 0 , 2764 , 10 , 4 )
	elseif a == 22 then
		GiveItem ( role , 0 , 2765 , 10 , 4 )
	elseif a == 23 then
		GiveItem ( role , 0 , 2766 , 10 , 4 )
	elseif a == 24 then
		GiveItem ( role , 0 , 2752 , 10 , 4 )
		
	end
 end
--4
function ItemUse_Manc( role, Item )
   local ItemCanGetSlot = GetChaFreeBagGridNum ( role )
   if ItemCanGetSlot < 1 then
    SystemNotice(role, "У вас не хватает слотов в инвентаре для распаковки сундука!")
    UseItemFailed ( role )
    return
	end
	a = math.random(1,24)
	if a == 1 then 
		GiveItem ( role , 0 , 2767 , 10 , 4 )
	elseif a == 2 then 
		GiveItem ( role , 0 , 2768 , 10 , 4 )
	elseif a == 3 then
		GiveItem ( role , 0 , 2769 , 10 , 4 )
	elseif a == 4 then
		GiveItem ( role , 0 , 2770 , 10 , 4 )
	elseif a == 5 then
		GiveItem ( role , 0 , 2771 , 10 , 4 )
	elseif a == 6 then
		GiveItem ( role , 0 , 2772 , 10 , 4 )
	elseif a == 7 then
		GiveItem ( role , 0 , 2773 , 10 , 4 )
	elseif a == 8 then
		GiveItem ( role , 0 , 2774 , 10 , 4 )
	elseif a == 9 then
		GiveItem ( role , 0 , 2775 , 10 , 4 )
	elseif a == 10 then
		GiveItem ( role , 0 , 2776 , 10 , 4 )
	elseif a == 11 then
		GiveItem ( role , 0 , 2777 , 2 , 4 )
	elseif a == 12 then
		GiveItem ( role , 0 , 2778 , 10 , 4 )
	elseif a == 13 then
		GiveItem ( role , 0 , 2779 , 10 , 4 )
	elseif a == 14 then
		GiveItem ( role , 0 , 2780 , 10 , 4 )
	elseif a == 15 then
		GiveItem ( role , 0 , 2781 , 10 , 4 )
	elseif a == 16 then
		GiveItem ( role , 0 , 2782 , 10 , 4 )
	elseif a == 17 then
		GiveItem ( role , 0 , 2783 , 10 , 4 )
	elseif a == 18 then
		GiveItem ( role , 0 , 2784 , 10 , 4 )
	elseif a == 19 then
		GiveItem ( role , 0 , 2785 , 10 , 4 )
	elseif a == 20 then
		GiveItem ( role , 0 , 2786 , 10 , 4 )
	elseif a == 21 then
		GiveItem ( role , 0 , 2787 , 10 , 4 )
	elseif a == 22 then
		GiveItem ( role , 0 , 2788 , 10 , 4 )
	elseif a == 23 then
		GiveItem ( role , 0 , 2789 , 10 , 4 )
	elseif a == 24 then
		GiveItem ( role , 0 , 2790 , 10 , 4 )
		
	end
 end
--5
function ItemUse_Manv( role, Item )
   local ItemCanGetSlot = GetChaFreeBagGridNum ( role )
   if ItemCanGetSlot < 1 then
    SystemNotice(role, "У вас не хватает слотов в инвентаре для распаковки сундука!")
    UseItemFailed ( role )
    return
	end
	a = math.random(1,24)
	if a == 1 then 
		GiveItem ( role , 0 , 2791 , 10 , 4 )
	elseif a == 2 then 
		GiveItem ( role , 0 , 2792 , 10 , 4 )
	elseif a == 3 then
		GiveItem ( role , 0 , 2793 , 10 , 4 )
	elseif a == 4 then
		GiveItem ( role , 0 , 2794 , 10 , 4 )
	elseif a == 5 then
		GiveItem ( role , 0 , 2795 , 10 , 4 )
	elseif a == 6 then
		GiveItem ( role , 0 , 2796 , 10 , 4 )
	elseif a == 7 then
		GiveItem ( role , 0 , 2797 , 10 , 4 )
	elseif a == 8 then
		GiveItem ( role , 0 , 2798 , 10 , 4 )
	elseif a == 9 then
		GiveItem ( role , 0 , 2799 , 10 , 4 )
	elseif a == 10 then
		GiveItem ( role , 0 , 2800 , 10 , 4 )
	elseif a == 11 then
		GiveItem ( role , 0 , 2801 , 1 , 4 )
	elseif a == 12 then
		GiveItem ( role , 0 , 2802 , 10 , 4 )
	elseif a == 13 then
		GiveItem ( role , 0 , 2803 , 10 , 4 )
	elseif a == 14 then
		GiveItem ( role , 0 , 2804 , 10 , 4 )
	elseif a == 15 then
		GiveItem ( role , 0 , 2805 , 10 , 4 )
	elseif a == 16 then
		GiveItem ( role , 0 , 2806 , 10 , 4 )
	elseif a == 17 then
		GiveItem ( role , 0 , 2807 , 10 , 4 )
	elseif a == 18 then
		GiveItem ( role , 0 , 2808 , 10 , 4 )
	elseif a == 19 then
		GiveItem ( role , 0 , 2809 , 10 , 4 )
	elseif a == 20 then
		GiveItem ( role , 0 , 2810 , 10 , 4 )
	elseif a == 21 then
		GiveItem ( role , 0 , 2811 , 10 , 4 )
	elseif a == 22 then
		GiveItem ( role , 0 , 2812 , 10 , 4 )
	elseif a == 23 then
		GiveItem ( role , 0 , 2813 , 10 , 4 )
	elseif a == 24 then
		GiveItem ( role , 0 , 2814 , 10 , 4 )
		
	end
 end

 

ItemInfo.txt


8637	Производство 2уровня	n0322	10130015	0	0	0	0	0	0	31	0	0	0	0	0	1	1	1	1	200	0	20000	-1,-2,-2,-2	0	-1,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2	0	0	-1,-2,-2,-2,-2,-2,-2,-2,-2,-2	-1,-2,-2,-2,-2,-2,-2,-2,-2,-2	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0	0,0	0,0	0	0	0	0	0	0	0	0	0	ItemUse_Mand	0	0	0	0,0	0	0	Открой и получи случайный предмет 2ур!	0																																																																																														
8638	Производство 3уровня	n0322	10130015	0	0	0	0	0	0	31	0	0	0	0	0	1	1	1	1	200	0	30000	-1,-2,-2,-2	0	-1,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2	0	0	-1,-2,-2,-2,-2,-2,-2,-2,-2,-2	-1,-2,-2,-2,-2,-2,-2,-2,-2,-2	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0	0,0	0,0	0	0	0	0	0	0	0	0	0	ItemUse_Mant	0	0	0	0,0	0	0	Открой и получи случайный предмет 3ур!	0																																																																																														
8639	Производство 4уровня	n0322	10130015	0	0	0	0	0	0	31	0	0	0	0	0	1	1	1	1	200	0	40000	-1,-2,-2,-2	0	-1,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2	0	0	-1,-2,-2,-2,-2,-2,-2,-2,-2,-2	-1,-2,-2,-2,-2,-2,-2,-2,-2,-2	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0	0,0	0,0	0	0	0	0	0	0	0	0	0	ItemUse_Manc	0	0	0	0,0	0	0	Открой и получи случайный предмет 4ур!	0																																																																																														
8640	Производство 5уровня	n0322	10130015	0	0	0	0	0	0	31	0	0	0	0	0	1	1	1	1	200	0	50000	-1,-2,-2,-2	0	-1,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2	0	0	-1,-2,-2,-2,-2,-2,-2,-2,-2,-2	-1,-2,-2,-2,-2,-2,-2,-2,-2,-2	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0	0,0	0,0	0	0	0	0	0	0	0	0	0	ItemUse_Manv	0	0	0	0,0	0	0	Открой и получи случайный предмет 5ур!	0																																																																																														
8641	Кулинария	n0322	10130015	0	0	0	0	0	0	31	0	0	0	0	0	1	1	1	1	200	0	50000	-1,-2,-2,-2	0	-1,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2	0	0	-1,-2,-2,-2,-2,-2,-2,-2,-2,-2	-1,-2,-2,-2,-2,-2,-2,-2,-2,-2	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0	0,0	0,0	0	0	0	0	0	0	0	0	0	ItemUse_Kul	0	0	0	0,0	0	0	Открой и получи случайное блюдо!	0																																																																																														

 


Делай добро и бросай его в воду

Share this post


Link to post
Share on other sites

Думаю с массивами выглядело бы приятнее и добавлять предметы проще.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Чтобы не быть голословным, накидал примерный вид..

Возможно есть ошибки (не тестировал на живом сервере).

-- Массив для функции ItemUse_Mano
ItemsM = {}
-- {ID предмета, кол-во, тип предмета}
ItemsM[1] = {1135, 10, 4}
ItemsM[2] = {1136, 10, 4}
ItemsM[3] = {1137, 10, 4}
ItemsM[4] = {1138, 10, 4}
ItemsM[5] = {1139, 10, 4}

function ItemUse_Mano( role, Item )
    local ItemCanGetSlot = GetChaFreeBagGridNum ( role )
    -- Проверка на кол-во слотов
	if ItemCanGetSlot < 1 then
		SystemNotice(role, "У вас не хватает слотов в инвентаре для распаковки сундука!")
		UseItemFailed ( role )
		return
	end
	-- Переменная для случайного числа
	local FCData = math.random(1,table.length(ItemsM))
	-- Ищем в массиве и выдаем вещь.
	for FCData in ItemsM do
		GiveItem ( role , 0 , ItemsM[FCData][1]  , ItemsM[FCData][2] , ItemsM[FCData][3] )
	end
end

 

Edited by Graf
  • Thanks 1

Share this post


Link to post
Share on other sites

Привет, @Graf!

 

Заменить:

local FCData = math.random(1, table.length(ItemsM))

на:

local FCData = math.random(1, table.getn(ItemsM))

 

Заменить:

for FCData in ItemsM do
	GiveItem ( role , 0 , ItemsM[FCData][1]  , ItemsM[FCData][2] , ItemsM[FCData][3] )
end

на:

GiveItem(role, 0, ItemsM[FCData][1], ItemsM[FCData][2], ItemsM[FCData][3])

и скрипт должен отлично работать.

 

1) Для получения размера массива в lua используется функция getn();

2) Для поиска предмета в массиве не нужно использовать цикл. На прошлом шаге ты получил случайный индекс массива, его и нужно использовать для выбора элемента с предметом.

 

Здесь можно тестировать lua-скрипты прямо в браузере.

  • Thanks 1

Share this post


Link to post
Share on other sites

 

17 часов назад, V3ct0r сказал:

 

Здесь можно тестировать lua-скрипты прямо в браузере.

Есть бот, который поможет тестировать прям в чате TG. 
https://t.me/hand_onbot

При работе в команде в чате можно обсуждать ту или иную реализацию или разрешать споры. Бот поддерживает редактирование сообщений. Используем этого бота давно и нареканий нет. 

Для запуска используйте команду /run


Контакты:
Сайт: https://magicseaonline.com/
Telegram:
https://t.me/magicsea_online - здесь мы публикуем последние новости по разработке
Группа VK:
https://vk.cc/chjbzd
Чат VK: https://vk.cc/chjc8L
Discord: 
https://discord.gg/nqkv76YVbj
Форум: https://forum.magicseaonline.com
YouTube: https://goo-gl.me/vfqtA

С уважением, Magicsea Team

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...