kaszanalubizryc
New Member
- Joined
- Sep 10, 2015
- Messages
- 148
- Reaction score
- 1
hey, there is scritp, i need to remove the getstorage and change getstorage to
getplayerskillevel
there is script
and add chance to craft item
like:
if failed then don't give player items
and send modailwindow = "your crafting Failed"
thanks
getplayerskillevel
there is script
Lua:
local recipes = {
[1] = {name = "Ammo",
options = {
[1] = {name = "Arrows", learned = false, learnStorage = 0, storage = {40000}, level = {0}, tries = 1, count = 30, id = 2544,
needed = {
[1] = {name = "iron ingot", id = 18337, count = 1},
[2] = {name = "wood", id = 5901, count = 1}
}
},
}
},
[2] = {name = "Armors",
options = {
[1] = {name = "Albino Plate", learned = false, learnStorage = 0, storage = {40000}, level = {30}, tries = 3, count = 1, id = 21692,
needed = {
[1] = {name = "iron ingots", id = 18337, count = 5}
}
},
}
},
[3] = {name = "Axes",
options = {
[1] = {name = "Angelic Axe", learned = false, learnStorage = 0, storage = {40000}, level = {30}, tries = 3, count = 1, id = 7436,
needed = {
[1] = {name = "raw leather", id = 22539, count = 5}
}
},
}
},
[4] = {name = "Boots",
options = {
[1] = {name = "Boots of Haste", learned = false, learnStorage = 0, storage = {40003, 40004}, level = {60, 20}, tries = 2, count = 1, id = 2195,
needed = {
[1] = {name = "raw leather", id = 22539, count = 6},
[2] = {name = "enchanted chicken wings", id = 5891, count = 4}
}
},
}
},
[5] = {name = "Clubs",
options = {
[1] = {name = "Banana Staff", learned = false, learnStorage = 0, storage = {40000}, level = {10}, tries = 2, count = 1, id = 3966,
needed = {
[1] = {name = "raw leather", id = 22539, count = 6}
}
},
}
},
[6] = {name = "Distance",
options = {
[1] = {name = "Arbalest", learned = false, learnStorage = 0, storage = {40005}, level = {30}, tries = 3, count = 1, id = 5803,
needed = {
[1] = {name = "iron ingots", id = 18337, count = 10}
}
},
}
},
[7] = {name = "Helmets",
options = {
[1] = {name = "Brass Helmet", learned = false, learnStorage = 0, storage = {40000}, level = {10}, tries = 1, count = 1, id = 2460,
needed = {
[1] = {name = "iron ingots", id = 18337, count = 6},
[2] = {name = "gold ore", id = 6547, count = 2}
}
},
}
},
[8] = {name = "Legs",
options = {
[1] = {name = "Blue Legs", learned = false, learnStorage = 0, storage = {40003}, level = {30}, tries = 4, count = 1, id = 7730,
needed = {
[1] = {name = "blue pieces of cloth", id = 5912, count = 50},
[2] = {name = "raw leather", id = 22539, count = 1}
}
},
}
},
[9] = {name = "Necklaces",
options = {
[1] = {name = "Bonfire Amulet", learned = false, learnStorage = 0, storage = {40003, 40004}, level = {40, 20}, tries = 2, count = 1, id = 10218,
needed = {
[1] = {name = "pieces of hell steel", id = 5888, count = 5},
[2] = {name = "glimmering soil", id = 8299, count = 10}
}
},
}
},
[10] = {name = "Rings",
options = {
[1] = {name = "Emerald Bangle", learned = false, learnStorage = 0, storage = {40000}, level = {10}, tries = 2, count = 1, id = 2127,
needed = {
[1] = {name = "gold ingots", id = 9971, count = 4},
[2] = {name = "small emeralds", id = 2149, count = 3},
}
},
}
},
[11] = {name = "Shields",
options = {
[1] = {name = "Battle Shield", learned = false, learnStorage = 0, storage = {40000}, level = {10}, tries = 1, count = 1, id = 2513,
needed = {
[1] = {name = "iron ingots", id = 18337, count = 4}
}
},
}
},
[12] = {name = "Swords",
options = {
[1] = {name = "Assassin Dagger", learned = false, learnStorage = 0, storage = {40004}, level = {20}, tries = 2, count = 1, id = 7404,
needed = {
[1] = {name = "huge chunk of crude iron", id = 5892, count = 1},
[2] = {name = "piece of hell steel", id = 5888, count = 1},
[3] = {name = "pieces of royal steel", id = 5887, count = 3}
}
},
}
},
[13] = {name = "Tools",
options = {
[1] = {name = "Crowbar", learned = false, learnStorage = 0, storage = {40000}, level = {10}, tries = 1, count = 1, id = 2416,
needed = {
[1] = {name = "iron ingots", id = 18337, count = 4},
}
},
}
},
[14] = {name = "Umbral",
options = {
[1] = {name = "Crude Umbral Axe", learned = false, learnStorage = 0, storage = {40004, 40008}, level = {100, 10}, tries = 1, count = 1, id = 22404,
needed = {
[1] = {name = "iron ingot", id = 18337, count = 5},
[2] = {name = "wood", id = 5901, count = 2},
[3] = {name = "dream matter", id = 22397, count = 2}
}
},
}
},
}
local modalId = 1005
local Type = {}
local Option = {}
local training = {
[40000] = "Basic Smithing",
[40001] = "Dwarven Smithing",
[40002] = "Dragon Smithing",
[40003] = "Magic Smithing",
[40004] = "Advanced Smithing",
[40005] = "Legendary Smithing",
[40006] = "Ultimate Smithing",
[40007] = "Demon Smithing",
[40008] = "Umbral Smithing",
}
-- Checks if player has the items required for a recipe - used for bringing the craft option back up after each craft if they have enough to do it again - enables quick, easy crafting
function Player:hasReq(recipe)
for i = 1, #recipe.needed do
if self:getItemCount(recipe.needed[i].id) < recipe.needed[i].count then
return false
end
end
return true
end
function Player:sendSortedWindow(type)
local window = ModalWindow(1011, recipes[type].name, "Expand the item you want to produce to view the requirements.\nYou are trained in the following specialties:\n")
local choices = 0
local temp = 0
for i = 40000, 40008 do
if self:getCSkill(training[i]) >= 10 then
temp = temp + 1
window:setMessage(window:getMessage() .. training[i] .. " (" .. self:getCSkill(training[i]) .. ")\n")
end
end
if temp == 0 then
window:setMessage(window:getMessage() .. "No specialty training.\n")
end
for i = 1, #recipes[type].options do
if (recipes[type].options[i].learned and self:getStorageValue(recipes[type].options[i].learnStorage) >= 1) or not recipes[type].options[i].learned then
if recipes[type].options[i].count > 1 then
window:addChoice(i, recipes[type].options[i].count .. " " .. recipes[type].options[i].name)
else
window:addChoice(i, recipes[type].options[i].name)
end
end
end
window:addButton(1, "Expand")
window:setDefaultEnterButton(1)
window:addButton(2, "Back")
window:setDefaultEscapeButton(2)
window:sendToPlayer(self)
return true
end
function Player:sendEquipmentWindowUpgrading()
local window = ModalWindow(modalId, "Upgrading", "Expand the type of item you want to craft to view the available items.\nYou are trained in the following specialties:\n")
local choices = 0
local temp = 0
for i = 40000, 40008 do
if self:getCSkill(training[i]) >= 10 then
temp = temp + 1
window:setMessage(window:getMessage() .. training[i] .. " (" .. self:getCSkill(training[i]) .. ")\n")
end
end
if temp == 0 then
window:setMessage(window:getMessage() .. "No specialty training.\n")
end
for i = 1, #recipes do
local t = false
for j = 1, #recipes[i].options do
if (recipes[i].options[j].learned and self:getStorageValue(recipes[i].options[j].learnStorage) >= 1) or not recipes[i].options[j].learned then
t = true
break
end
end
if t then
window:addChoice(i, recipes[i].name)
end
end
window:addButton(1, "Expand")
window:setDefaultEnterButton(1)
window:addButton(2, "Exit")
window:setDefaultEscapeButton(2)
window:sendToPlayer(self)
return true
end
function Player:sendERecipeWindow(type, option)
local window = ModalWindow(modalId + 1, recipes[type].options[option].name, "To produce this item, you need:\n")
for i = 1, #recipes[type].options[option].needed do
window:setMessage(window:getMessage() .. recipes[type].options[option].needed[i].count .. " " .. recipes[type].options[option].needed[i].name .. " (" .. self:getItemCount(recipes[type].options[option].needed[i].id) .. ")\n")
end
if recipes[type].options[option].storage then
for i = 1, #recipes[type].options[option].storage do
local lev = self:getCSkill(training[recipes[type].options[option].storage[i]])
window:setMessage(window:getMessage() .. training[recipes[type].options[option].storage[i]] .. " " .. recipes[type].options[option].level[i] .. " (" .. lev .. ")\n")
end
end
for i = 1, #recipes[type].options[option].needed do
if self:getItemCount(recipes[type].options[option].needed[i].id) < recipes[type].options[option].needed[i].count then
return window:addButton(2, "Back"), window:setDefaultEscapeButton(2), window:setDefaultEnterButton(2), window:sendToPlayer(self)
end
end
for i = 1, #recipes[type].options[option].storage do
if self:getCSkill(training[recipes[type].options[option].storage[i]]) < recipes[type].options[option].level[i] then
return window:addButton(2, "Back"), window:setDefaultEscapeButton(2), window:setDefaultEnterButton(2), window:sendToPlayer(self)
end
end
window:addButton(1, "Make It!")
window:setDefaultEnterButton(1)
window:addButton(2, "Back")
window:setDefaultEscapeButton(2)
window:sendToPlayer(self)
return true
end
function Player:sortedWindowChoice(windowId, buttonId, choiceId)
local p = self:getGuid()
if windowId == 1011 then
if buttonId == 1 then
Option[p] = choiceId
self:sendERecipeWindow(Type[p], Option[p])
return true
elseif buttonId == 2 then
self:sendEquipmentWindowUpgrading()
return true
end
return false
end
return false
end
function Player:equipmentWindowChoice(windowId, buttonId, choiceId)
local p = self:getGuid()
if windowId == modalId then
if buttonId == 1 then
Type[p] = choiceId
self:sendSortedWindow(Type[p])
return true
else
Type[p] = nil
Option[p] = nil
return false
end
end
return false
end
function Player:eRecipeWindowChoice(windowId, buttonId, choiceId)
local p = self:getGuid()
if windowId == modalId + 1 then
if buttonId == 1 then
local rand = math.random(1,100000)
local half = false
local chance = (cSkills[training[recipes[Type[p]].options[Option[p]].storage[1]]].bonus * self:getCSkill(training[recipes[Type[p]].options[Option[p]].storage[1]])) * 100
if rand < chance * 1000 then
half = true
end
for i = 1, #recipes[Type[p]].options[Option[p]].needed do
if half then
self:removeItem(recipes[Type[p]].options[Option[p]].needed[i].id, math.ceil(recipes[Type[p]].options[Option[p]].needed[i].count / 2))
else
self:removeItem(recipes[Type[p]].options[Option[p]].needed[i].id, recipes[Type[p]].options[Option[p]].needed[i].count)
end
end
self:addItem(recipes[Type[p]].options[Option[p]].id, recipes[Type[p]].options[Option[p]].count)
if half then
self:sendTextMessage(MESSAGE_INFO_DESCR, "Congratulations! You have crafted " .. recipes[Type[p]].options[Option[p]].count .. " " .. recipes[Type[p]].options[Option[p]].name .. " at half the usual cost!")
else
self:sendTextMessage(MESSAGE_INFO_DESCR, "You have crafted " .. recipes[Type[p]].options[Option[p]].count .. " " .. recipes[Type[p]].options[Option[p]].name .. "!")
end
for i = 1, #recipes[Type[p]].options[Option[p]].storage do
self:addCSkillTries(training[recipes[Type[p]].options[Option[p]].storage[i]], recipes[Type[p]].options[Option[p]].tries)
end
if recipes[Type[p]].options[Option[p]].set then
if self:getStorageValue(sets[recipes[Type[p]].options[Option[p]].set].pieces[recipes[Type[p]].options[Option[p]].piece].storage) ~= 1 then
self:setStorageValue(sets[recipes[Type[p]].options[Option[p]].set].pieces[recipes[Type[p]].options[Option[p]].piece].storage, 1)
end
local tempStore = true
for i = 1, #sets[recipes[Type[p]].options[Option[p]].set].pieces do
if self:getStorageValue(sets[recipes[Type[p]].options[Option[p]].set].pieces[recipes[Type[p]].options[Option[p]].piece].storage) ~= 1 then
tempStore = false
end
end
if tempStore then
self:addAchievement(sets[recipes[Type[p]].options[Option[p]].set].achievement)
end
end
return self:hasReq(recipes[Type[p]].options[Option[p]]) and self:sendERecipeWindow(Type[p], Option[p]) or self:sendSortedWindow(Type[p])
elseif buttonId == 2 then
self:sendSortedWindow(Type[p])
end
return false
end
return false
end
and add chance to craft item
like:
Lua:
local training = {
[40000] = "fist fighting",
[40001] = "sword fighting",
[40002] = "axe fighting",
[40003] = "club fighting",
[40004] = "distance fighting",
[40005] = "fist fighting",
[40006] = "fist fighting",
[40007] = "fist fighting",
[40008] = "axe fighting",
}
Lua:
[1] = {name = "Arrows", learned = false, learnStorage = 0, storage = {40000}, level = {0}, tries = 1, count = 30, id = 2544, chance = 1000, --- 1%
needed = {
[1] = {name = "iron ingot", id = 18337, count = 1},
[2] = {name = "wood", id = 5901, count = 1}
}
},
if failed then don't give player items
and send modailwindow = "your crafting Failed"
thanks
Last edited: