• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Action Rust Remover

nsanee

Member
Senator
Joined
Apr 13, 2008
Messages
669
Reaction score
20
Yo.

This little action script will reveal (or break) all the rusty items out there.

The base was made by AGS from OTFans / OTland :), I modified it in a way, so now it is harder to get better items, instead of it being completely random. You can set the chance for the item to break on use as well as how hard it is to get the best items. The values I left as default work good for me.

TFS 0.3.x

actions.xml:

Code:
<action itemid="9930" event="script" value="tools/ruster.lua"/>
data/actions/scripts/tools/ruster.lua:

Code:
-- break chance on use, comes into play before any other calculations
local breakChance = 40

-- 1-100 range for difficulty. The higher it is, the less likely it is that player will get a good item
local difficulty = 50

local rustyItems = {
    [9808] = {2464, 2465, 2483, 2463, 2476}, --common rusty armor
    [9809] = {2464, 2465, 2483, 2463, 2476, 8891}, --semi-rare rusty armor
    [9810] = {2464, 2465, 2483, 2463, 2476, 8891, 2487, 2466, 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
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if rustyItems[itemEx.itemid] ~= nil then
        if math.random(100) <= breakChance then
            doRemoveItem(itemEx.uid)
            doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You broke it.")
        else
            local q = #rustyItems[itemEx.itemid]
            local z = rustyItems[itemEx.itemid]
            local newId
            for i = 1, q do
                local x = math.random(100)
                if (x < difficulty) then
                    newId = z[i]
                    break
                elseif (i >= q) then 
                    newId = z[q]
                end    
            end
            
            doTransformItem(itemEx.uid,newId)
            doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You removed the rust, revealing a "..getItemNameById(newId))
        end
        doRemoveItem(item.uid,1)
        return TRUE
    end
    return FALSE
end


TFS 0.2.x

Code:
<action itemid="9930" script="tools/ruster.lua"/>


data/actions/scripts/tools/ruster.lua should be the same. If it doesn't work try changing getItemNameById to getItemName, otherwise I can't see the difference.

Well you can rep
me if this has helped you :)
 
Last edited:
Can u tell me if now if u use 100 of them on a rusty armor it will only take on, because it took all of them before on AGS' version.
 
Can u tell me if now if u use 100 of them on a rusty armor it will only take on, because it took all of them before on AGS' version.

Yes it will take only one rust remover.
 
!!error!!

I'm getting this error message with TFS 0.3.1

Code:
[28/04/2009 15:47:01] Lua Script Error: [Action Interface] 
[28/04/2009 15:47:01] data/actions/scripts/Custom/ruster.lua:onUse

[28/04/2009 15:47:01] data/actions/scripts/Custom/ruster.lua:23: attempt to compare number with nil
[28/04/2009 15:47:01] stack traceback:
[28/04/2009 15:47:01] 	data/actions/scripts/Custom/ruster.lua:23: in function <data/actions/scripts/Custom/ruster.lua:21>

This is the script:
PHP:
local difficulty = 50

local rustyItems = {
    [9808] = {2656, 3968, 2486, 2476}, --common rusty armor
    [9809] = {2656, 3968, 2486, 2476, 8891}, --semi-rare rusty armor
    [9810] = {2656, 3968, 2486, 2476, 8891, 2487, 2466, 2472}, --rare rusty armor
    [9811] = {7730, 7464, 2477}, --common rusty legs
    [9812] = {7730, 7464, 2477, 2488}, --semi-rare rusty legs
    [9813] = {7730, 7464, 2477, 2488, 2470}, --rare rusty legs
    [9814] = {9814, 2527, 2528, 2515}, --common rusty shield
    [9815] = {9815, 2527, 2528, 2515, 2516, 2519}, --semi-rare rusty shield
    [9816] = {9816, 2527, 2528, 2515, 2516, 2519, 2520, 2514}, --rare rusty shield
    [9817] = {3982, 5462, 7457}, --common rusty boots
    [9818] = {3982, 5462, 7457, 2195}, --semi-rare rusty boots
    [9819] = {3982, 5462, 7457, 2195, 2645}, --rare rusty boots
    [9820] = {2462, 2479, 2491}, --common rusty helmet
    [9821] = {2462, 2479, 2491, 2497}, --semi rare rusty helmet
    [9822] = {2462, 2479, 2491, 2497, 2475, 2498} --rare rusty helmet
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if rustyItems[itemEx.itemid] ~= nil then
        if math.random(100) <= breakChance then <--- ROW 23!!
            doRemoveItem(itemEx.uid)
            doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You broke it.")
        else
            local q = #rustyItems[itemEx.itemid]
            local z = rustyItems[itemEx.itemid]
            local newId
            for i = 1, q do
                local x = math.random(100)
                if (x < difficulty) then
                    newId = z[i]
                    break
                elseif (i >= q) then 
                    newId = z[q]
                end    
            end
            
            doTransformItem(itemEx.uid,newId)
            doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You removed the rust, revealing a "..getItemNameById(newId))
        end
        doRemoveItem(item.uid,1)
        return TRUE
    end
    return FALSE
end
 
I'm getting this error message with TFS 0.3.1

Code:
[28/04/2009 15:47:01] Lua Script Error: [Action Interface] 
[28/04/2009 15:47:01] data/actions/scripts/Custom/ruster.lua:onUse

[28/04/2009 15:47:01] data/actions/scripts/Custom/ruster.lua:23: attempt to compare number with nil
[28/04/2009 15:47:01] stack traceback:
[28/04/2009 15:47:01] 	data/actions/scripts/Custom/ruster.lua:23: in function <data/actions/scripts/Custom/ruster.lua:21>

This is the script:
PHP:
local difficulty = 50

local rustyItems = {
    [9808] = {2656, 3968, 2486, 2476}, --common rusty armor
    [9809] = {2656, 3968, 2486, 2476, 8891}, --semi-rare rusty armor
    [9810] = {2656, 3968, 2486, 2476, 8891, 2487, 2466, 2472}, --rare rusty armor
    [9811] = {7730, 7464, 2477}, --common rusty legs
    [9812] = {7730, 7464, 2477, 2488}, --semi-rare rusty legs
    [9813] = {7730, 7464, 2477, 2488, 2470}, --rare rusty legs
    [9814] = {9814, 2527, 2528, 2515}, --common rusty shield
    [9815] = {9815, 2527, 2528, 2515, 2516, 2519}, --semi-rare rusty shield
    [9816] = {9816, 2527, 2528, 2515, 2516, 2519, 2520, 2514}, --rare rusty shield
    [9817] = {3982, 5462, 7457}, --common rusty boots
    [9818] = {3982, 5462, 7457, 2195}, --semi-rare rusty boots
    [9819] = {3982, 5462, 7457, 2195, 2645}, --rare rusty boots
    [9820] = {2462, 2479, 2491}, --common rusty helmet
    [9821] = {2462, 2479, 2491, 2497}, --semi rare rusty helmet
    [9822] = {2462, 2479, 2491, 2497, 2475, 2498} --rare rusty helmet
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if rustyItems[itemEx.itemid] ~= nil then
        if math.random(100) <= breakChance then <--- ROW 23!!
            doRemoveItem(itemEx.uid)
            doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You broke it.")
        else
            local q = #rustyItems[itemEx.itemid]
            local z = rustyItems[itemEx.itemid]
            local newId
            for i = 1, q do
                local x = math.random(100)
                if (x < difficulty) then
                    newId = z[i]
                    break
                elseif (i >= q) then 
                    newId = z[q]
                end    
            end
            
            doTransformItem(itemEx.uid,newId)
            doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You removed the rust, revealing a "..getItemNameById(newId))
        end
        doRemoveItem(item.uid,1)
        return TRUE
    end
    return FALSE
end

you are missing the variable breakChance

Code:
local breakChance = 40
on top
 
Thank you! Rep++ too you :D, i like that there is actually people looking into other peoples problems and solving them! keep it up!
 
doesnt works for me. ive done everything u said but when im ingame and try to use one of the rust removers (or 100 together) it just says "you can not use this object". i tried the rust remover item on every rusty item but nothing worked. the console says nothing, so i thought everything is working well ... ^.-

im using crying damson tfs 0.3.1.x ...

what should i do?
 
doesnt works for me. ive done everything u said but when im ingame and try to use one of the rust removers (or 100 together) it just says "you can not use this object". i tried the rust remover item on every rusty item but nothing worked. the console says nothing, so i thought everything is working well ... ^.-

im using crying damson tfs 0.3.1.x ...

what should i do?

I would make sure the path to script you supplied in actions.xml is correct, also make sure you don't get any error about it on startup, as well as see if you don't have '9930' item id action already.
 
okay i solved it by myself, the error occured because u made a mistake (i think so ...). I mean you posted the:

Code:
<action itemid="9930" event="script" value="tools/ruster.lua"/>

That's wrong, correct it to:
Code:
<action itemid="9930" script="tools/ruster.lua"/>

and it will work without any error ;D
i tested it and it (still) works ^^
 
Hes using an updated version then yours.. thats why
 
Last edited:
okay i solved it by myself, the error occured because u made a mistake (i think so ...). I mean you posted the:

Code:
<action itemid="9930" event="script" value="tools/ruster.lua"/>

That's wrong, correct it to:
Code:
<action itemid="9930" script="tools/ruster.lua"/>

and it will work without any error ;D
i tested it and it (still) works ^^

Only for old outdated servers, but nice try to be cool anyway :thumbup:
 
@ up
thanks ;D

@chris77
my names Criss, too but its a shame that u made this name to a noob title.
Ive done to solve it by myslef and gave reply and u come along and give stupid smartless comments -.-
i think u r the noob here...
 
Hehe right, the thread was inactive for too long for me to spot it ;]
 
Back
Top