[25/04/2014 23:37:11] [Error - Action Interface]
[25/04/2014 23:37:11] data/actions/scripts/other/rust.lua:onUse
[25/04/2014 23:37:11] Description:
[25/04/2014 23:37:11] data/actions/scripts/other/rust.lua:74: attempt to compare number with nil
[25/04/2014 23:37:11] stack traceback:
[25/04/2014 23:37:11] data/actions/scripts/other/rust.lua:74: in function <data/actions/scripts/other/rust.lua:6>
[25/04/2014 23:37:23] [Error - Action Interface]
[25/04/2014 23:37:23] data/actions/scripts/other/rust.lua:onUse
[25/04/2014 23:37:23] Description:
[25/04/2014 23:37:23] data/actions/scripts/other/rust.lua:74: attempt to compare number with nil
[25/04/2014 23:37:23] stack traceback:
[25/04/2014 23:37:23] data/actions/scripts/other/rust.lua:74: in function <data/actions/scripts/other/rust.lua:6>
-- Made by Leon Zawodowiec --
-- Rusty Remover --
-- Only Armors & Legs (Thanks Mooosie) --
-- VersioN 3.0 --
-- I don\'t let the copy of this on other forums with the exception of OTsoft.pl --
function onUse(cid, item, frompos, item2, topos)
local effect_broke = 3
local effect_renew = 28
local wylosowany = 0
local const = item2.itemid
local pos = getCreaturePosition(cid)
local itemy = {
[9808] = {
[1] = {id = 2464, name = "Chain Armor", szansa = 33},
[2] = {id = 2483, name = "Scale Armor", szansa = 25},
[3] = {id = 2465, name = "Brass Armor", szansa = 10},
[4] = {id = 2463, name = "Plate Armor", szansa = 2}
},
[9809] = {
[1] = {id = 2464, name = "Chain Armor", szansa = 16},
[2] = {id = 2465, name = "Brass Armor", szansa = 14},
[3] = {id = 2483, name = "Scale Armor", szansa = 13},
[4] = {id = 2463, name = "Plate Armor", szansa = 10},
[5] = {id = 2476, name = "Knight Armor", szansa = 6},
[6] = {id = 8891, name = "Paladin Armor", szansa = 3},
[7] = {id = 2487, name = "Crown Armor", szansa = 1}
},
[9810] = {
[1] = {id = 2464, name = "Chain Armor", szansa = 20},
[2] = {id = 2465, name = "Brass Armor", szansa = 17},
[3] = {id = 2483, name = "Scale Armor", szansa = 15},
[4] = {id = 2463, name = "Plate Armor", szansa = 12},
[5] = {id = 2476, name = "Knight Armor", szansa = 10},
[6] = {id = 8891, name = "Paladin Armor", szansa = 5},
[7] = {id = 2487, name = "Crown Armor", szansa = 4},
[8] = {id = 2466, name = "Golden Armor", szansa = 2},
[9] = {id = 2472, name = "Magic Plate Armor", szansa = 1}
},
[9811] = {
[1] = {id = 2468, name = "Studded Legs", szansa = 33},
[2] = {id = 2648, name = "Chain Legs", szansa = 25},
[3] = {id = 2478, name = "Brass Legs", szansa = 10},
[4] = {id = 2647, name = "Plate Legs", szansa = 2}
},
[9812] = {
[1] = {id = 2468, name = "Studded Legs", szansa = 16},
[2] = {id = 2648, name = "Chain Legs", szansa = 14},
[3] = {id = 2478, name = "Brass Legs", szansa = 13},
[4] = {id = 2647, name = "Plate Legs", szansa = 10},
[5] = {id = 2477, name = "Knight Legs", szansa = 6},
[7] = {id = 2488, name = "Crown Legs", szansa = 1}
},
[9813] = {
[2] = {id = 2478, name = "Brass Legs", szansa = 17},
[4] = {id = 2647, name = "Plate Legs", szansa = 12},
[5] = {id = 2477, name = "Knight Legs", szansa = 10},
[7] = {id = 2488, name = "Crown Legs", szansa = 4},
[8] = {id = 2470, name = "Golden Legs", szansa = 2}
}
}
if itemy[const] then
local random_item = math.random(1, 100)
for i = 1, #itemy[const] do
if random_item <= itemy[const].szansa then
wylosowany = i
end
end
if wylosowany > 0 then
doSendMagicEffect(topos, effect_renew)
doTransformItem(item2.uid, itemy[const][wylosowany].id)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have renewed the ".. itemy[const][wylosowany].name .." !")
doRemoveItem(item.uid, 1)
else
doSendMagicEffect(topos, effect_broke)
doRemoveItem(item2.uid, 1)
doRemoveItem(item.uid, 1)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your Rusty Remover has broken.")
return 0
end
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Use it on Rusty Items (Common, Semi-Rare or Rare: Armors or Legs).")
return 0
end
return true
end
local breakChance = 60
local rustyItems = {
[9808] = {2464, 2465, 2483, 2463, 2476}, --common rusty armor
[9809] = {2464, 2465, 2483, 2463, 2476, 8891, 2487}, --semi-rare rusty armor
[9810] = {2465, 2463, 2476, 8891, 2487, 2466, 2492, 2472}, --rare rusty armor
[9811] = {2468, 2648, 2478, 2647, 2477}, --common rusty legs
[9812] = {2468, 2648, 2478, 2647, 2477, 2488}, --semi-rare rusty legs
[9813] = {2468, 2648, 2478, 2647, 2477, 2488, 2470}, --rare rusty legs
[9814] = {2511, 2510, 2530, 2509, 2513, 2515}, --common rusty shield
[9815] = {2511, 2510, 2530, 2509, 2513, 2515, 2516, 2519}, --semi-rare rusty shield
[9816] = {2511, 2510, 2530, 2509, 2513, 2515, 2516, 2519, 2520, 2514}, --rare rusty shield
[9817] = {2643, 3982, 5462, 7457}, --common rusty boots
[9818] = {2643, 3982, 5462, 7457, 2195}, --semi-rare rusty boots
[9819] = {2643, 3982, 5462, 7457, 2195, 2645}, --rare rusty boots
[9820] = {2458, 2460, 2480, 2481, 2457, 2491}, --common rusty helmet
[9821] = {2458, 2460, 2480, 2481, 2457, 2491, 2497}, --semi rare rusty helmet
[9822] = {2458, 2460, 2480, 2481, 2457, 2491, 2497, 2475, 2498}, --rare rusty helmet
[9805] = {2376, 2377, 2383, 2409, 2413, 7386}, --common rusty stick
[9806] = {2376, 2377, 2383, 2409, 2413, 7386, 7383}, --semi rare rusty stick
[9807] = {2376, 2377, 2383, 2409, 2413, 7386, 7383, 7390, 6528} --rare rusty stick
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local tpos = getThingPos(itemEx.uid)
if rustyItems[itemEx.itemid] ~= nil then
if math.random(100) <= breakChance then
doRemoveItem(itemEx.uid)
if toPosition.x == CONTAINER_POSITION or toPosition.x == 0 and toPosition.y == 0 and toPosition.z == 0 then
doCreatureSay(cid, "This item was damaged so badly that it broke when you tried to clean it.", TALKTYPE_MONSTER_YELL, false, cid, (getCreaturePosition(cid)))
else
doCreatureSay(cid, "This item was damaged so badly that it broke when you tried to clean it.", TALKTYPE_MONSTER_YELL, false, cid, toPosition)
end
doSendMagicEffect(tpos,CONST_ME_BLOCKHIT)
else
local newId = rustyItems[itemEx.itemid][math.random(#rustyItems[itemEx.itemid])]
doTransformItem(itemEx.uid,newId)
doSendMagicEffect(tpos,CONST_ME_MAGIC_GREEN)
end
doRemoveItem(item.uid,1)
return true
end
return false
end
Code:local breakChance = 60 local rustyItems = { [9808] = {2464, 2465, 2483, 2463, 2476}, --common rusty armor [9809] = {2464, 2465, 2483, 2463, 2476, 8891, 2487}, --semi-rare rusty armor [9810] = {2465, 2463, 2476, 8891, 2487, 2466, 2492, 2472}, --rare rusty armor [9811] = {2468, 2648, 2478, 2647, 2477}, --common rusty legs [9812] = {2468, 2648, 2478, 2647, 2477, 2488}, --semi-rare rusty legs [9813] = {2468, 2648, 2478, 2647, 2477, 2488, 2470}, --rare rusty legs [9814] = {2511, 2510, 2530, 2509, 2513, 2515}, --common rusty shield [9815] = {2511, 2510, 2530, 2509, 2513, 2515, 2516, 2519}, --semi-rare rusty shield [9816] = {2511, 2510, 2530, 2509, 2513, 2515, 2516, 2519, 2520, 2514}, --rare rusty shield [9817] = {2643, 3982, 5462, 7457}, --common rusty boots [9818] = {2643, 3982, 5462, 7457, 2195}, --semi-rare rusty boots [9819] = {2643, 3982, 5462, 7457, 2195, 2645}, --rare rusty boots [9820] = {2458, 2460, 2480, 2481, 2457, 2491}, --common rusty helmet [9821] = {2458, 2460, 2480, 2481, 2457, 2491, 2497}, --semi rare rusty helmet [9822] = {2458, 2460, 2480, 2481, 2457, 2491, 2497, 2475, 2498}, --rare rusty helmet [9805] = {2376, 2377, 2383, 2409, 2413, 7386}, --common rusty stick [9806] = {2376, 2377, 2383, 2409, 2413, 7386, 7383}, --semi rare rusty stick [9807] = {2376, 2377, 2383, 2409, 2413, 7386, 7383, 7390, 6528} --rare rusty stick } function onUse(cid, item, fromPosition, itemEx, toPosition) local tpos = getThingPos(itemEx.uid) if rustyItems[itemEx.itemid] ~= nil then if math.random(100) <= breakChance then doRemoveItem(itemEx.uid) if toPosition.x == CONTAINER_POSITION or toPosition.x == 0 and toPosition.y == 0 and toPosition.z == 0 then doCreatureSay(cid, "This item was damaged so badly that it broke when you tried to clean it.", TALKTYPE_MONSTER_YELL, false, cid, (getCreaturePosition(cid))) else doCreatureSay(cid, "This item was damaged so badly that it broke when you tried to clean it.", TALKTYPE_MONSTER_YELL, false, cid, toPosition) end doSendMagicEffect(tpos,CONST_ME_BLOCKHIT) else local newId = rustyItems[itemEx.itemid][math.random(#rustyItems[itemEx.itemid])] doTransformItem(itemEx.uid,newId) doSendMagicEffect(tpos,CONST_ME_MAGIC_GREEN) end doRemoveItem(item.uid,1) return true end return false end
Try using this one, found it in one of my datapacks
local effect_broke = 3
local effect_renew = 28
local wylosowany = 0
local itemy = {
[9808] = {
[1] = {id = 2464, name = "Chain Armor", szansa = 33},
[2] = {id = 2483, name = "Scale Armor", szansa = 25},
[3] = {id = 2465, name = "Brass Armor", szansa = 10},
[4] = {id = 2463, name = "Plate Armor", szansa = 2}
},
[9809] = {
[1] = {id = 2464, name = "Chain Armor", szansa = 16},
[2] = {id = 2465, name = "Brass Armor", szansa = 14},
[3] = {id = 2483, name = "Scale Armor", szansa = 13},
[4] = {id = 2463, name = "Plate Armor", szansa = 10},
[5] = {id = 2476, name = "Knight Armor", szansa = 6},
[6] = {id = 8891, name = "Paladin Armor", szansa = 3},
[7] = {id = 2487, name = "Crown Armor", szansa = 1}
},
[9810] = {
[1] = {id = 2464, name = "Chain Armor", szansa = 20},
[2] = {id = 2465, name = "Brass Armor", szansa = 17},
[3] = {id = 2483, name = "Scale Armor", szansa = 15},
[4] = {id = 2463, name = "Plate Armor", szansa = 12},
[5] = {id = 2476, name = "Knight Armor", szansa = 10},
[6] = {id = 8891, name = "Paladin Armor", szansa = 5},
[7] = {id = 2487, name = "Crown Armor", szansa = 4},
[8] = {id = 2466, name = "Golden Armor", szansa = 2},
[9] = {id = 2472, name = "Magic Plate Armor", szansa = 1}
},
[9811] = {
[1] = {id = 2468, name = "Studded Legs", szansa = 33},
[2] = {id = 2648, name = "Chain Legs", szansa = 25},
[3] = {id = 2478, name = "Brass Legs", szansa = 10},
[4] = {id = 2647, name = "Plate Legs", szansa = 2}
},
[9812] = {
[1] = {id = 2468, name = "Studded Legs", szansa = 16},
[2] = {id = 2648, name = "Chain Legs", szansa = 14},
[3] = {id = 2478, name = "Brass Legs", szansa = 13},
[4] = {id = 2647, name = "Plate Legs", szansa = 10},
[5] = {id = 2477, name = "Knight Legs", szansa = 6},
[7] = {id = 2488, name = "Crown Legs", szansa = 1}
},
[9813] = {
[2] = {id = 2478, name = "Brass Legs", szansa = 17},
[4] = {id = 2647, name = "Plate Legs", szansa = 12},
[5] = {id = 2477, name = "Knight Legs", szansa = 10},
[7] = {id = 2488, name = "Crown Legs", szansa = 4},
[8] = {id = 2470, name = "Golden Legs", szansa = 2}
}
}
function onUse(cid, item, frompos, item2, topos)
local const = item2.itemid
local pos = getCreaturePosition(cid)
if itemy[const] then
local random_item = math.random(1, 100)
for i = 1, #itemy[const] do
if random_item <= itemy[const][i].szansa then -- this is where the problem was, [i] was missing
wylosowany = i
end
end
if wylosowany > 0 then
doSendMagicEffect(topos, effect_renew)
doTransformItem(item2.uid, itemy[const][wylosowany].id)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have renewed the ".. itemy[const][wylosowany].name .." !")
doRemoveItem(item.uid, 1)
else
doSendMagicEffect(topos, effect_broke)
doRemoveItem(item2.uid, 1)
doRemoveItem(item.uid, 1)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your Rusty Remover has broken.")
return false
end
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Use it on Rusty Items (Common, Semi-Rare or Rare: Armors or Legs).")
return false
end
return true
end
Now it works, however rusty armors never breakFixed your current script, should work now. I commented the error so you can learn from it. Oh and I tabbed it cuz it was disgusting.
Code:local effect_broke = 3 local effect_renew = 28 local wylosowany = 0 local itemy = { [9808] = { [1] = {id = 2464, name = "Chain Armor", szansa = 33}, [2] = {id = 2483, name = "Scale Armor", szansa = 25}, [3] = {id = 2465, name = "Brass Armor", szansa = 10}, [4] = {id = 2463, name = "Plate Armor", szansa = 2} }, [9809] = { [1] = {id = 2464, name = "Chain Armor", szansa = 16}, [2] = {id = 2465, name = "Brass Armor", szansa = 14}, [3] = {id = 2483, name = "Scale Armor", szansa = 13}, [4] = {id = 2463, name = "Plate Armor", szansa = 10}, [5] = {id = 2476, name = "Knight Armor", szansa = 6}, [6] = {id = 8891, name = "Paladin Armor", szansa = 3}, [7] = {id = 2487, name = "Crown Armor", szansa = 1} }, [9810] = { [1] = {id = 2464, name = "Chain Armor", szansa = 20}, [2] = {id = 2465, name = "Brass Armor", szansa = 17}, [3] = {id = 2483, name = "Scale Armor", szansa = 15}, [4] = {id = 2463, name = "Plate Armor", szansa = 12}, [5] = {id = 2476, name = "Knight Armor", szansa = 10}, [6] = {id = 8891, name = "Paladin Armor", szansa = 5}, [7] = {id = 2487, name = "Crown Armor", szansa = 4}, [8] = {id = 2466, name = "Golden Armor", szansa = 2}, [9] = {id = 2472, name = "Magic Plate Armor", szansa = 1} }, [9811] = { [1] = {id = 2468, name = "Studded Legs", szansa = 33}, [2] = {id = 2648, name = "Chain Legs", szansa = 25}, [3] = {id = 2478, name = "Brass Legs", szansa = 10}, [4] = {id = 2647, name = "Plate Legs", szansa = 2} }, [9812] = { [1] = {id = 2468, name = "Studded Legs", szansa = 16}, [2] = {id = 2648, name = "Chain Legs", szansa = 14}, [3] = {id = 2478, name = "Brass Legs", szansa = 13}, [4] = {id = 2647, name = "Plate Legs", szansa = 10}, [5] = {id = 2477, name = "Knight Legs", szansa = 6}, [7] = {id = 2488, name = "Crown Legs", szansa = 1} }, [9813] = { [2] = {id = 2478, name = "Brass Legs", szansa = 17}, [4] = {id = 2647, name = "Plate Legs", szansa = 12}, [5] = {id = 2477, name = "Knight Legs", szansa = 10}, [7] = {id = 2488, name = "Crown Legs", szansa = 4}, [8] = {id = 2470, name = "Golden Legs", szansa = 2} } } function onUse(cid, item, frompos, item2, topos) local const = item2.itemid local pos = getCreaturePosition(cid) if itemy[const] then local random_item = math.random(1, 100) for i = 1, #itemy[const] do if random_item <= itemy[const][i].szansa then -- this is where the problem was, [i] was missing wylosowany = i end end if wylosowany > 0 then doSendMagicEffect(topos, effect_renew) doTransformItem(item2.uid, itemy[const][wylosowany].id) doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have renewed the ".. itemy[const][wylosowany].name .." !") doRemoveItem(item.uid, 1) else doSendMagicEffect(topos, effect_broke) doRemoveItem(item2.uid, 1) doRemoveItem(item.uid, 1) doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your Rusty Remover has broken.") return false end else doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Use it on Rusty Items (Common, Semi-Rare or Rare: Armors or Legs).") return false end return true end