• 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!

Help with revscirpt

walltimer

Active Member
Joined
Aug 5, 2020
Messages
170
Reaction score
26
1. make it revscript to buy aol typing !aol
function onSay(cid, words, param)
if doPlayerRemoveMoney(cid, 10000) then
doPlayerAddItem(cid,2173,1)
doSendMagicEffect(getPlayerPosition(cid),12)
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You've bought an amulet of loss!")
else
doPlayerSendCancel(cid,"You don't have enough money.")
doSendMagicEffect(getPlayerPosition(cid),2)
end
return true
end
2. make it revscript exp ring
local config = {

rate = 2.0, -- 2.0 = 2x faster than normal.
un_equip = 6300, -- Item ID of the UN-Equipped ring.
equip = 6301 -- Item ID of the Equipped ring.

}

function onDeEquip(cid, item, slot)
doPlayerSetExperienceRate(cid, 1.0)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your extra experience rate has ended.")
doTransformItem(item.uid, config.un_equip)
return true
end

function onEquip(cid, item, slot)
if getConfigValue("experienceStages") == "yes" then
doPlayerSetExperienceRate(cid, getExperienceStage(getPlayerLevel(cid))*2)
else
doPlayerSetExperienceRate(cid, getConfigValue("rateExperience")*2)
end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your extra experience rate has been activated! It is now: " .. config.rate .. "x doubled your former experience rate.")
doTransformItem(item.uid, config.equip)
doDecayItem(item.uid)
return true
end
3. anyworking upgrade item script? (easy as posible,bonuses dmg/def etc)
 
Solution
data/scripts/aol.lua
Lua:
local config = {
    price = 10000,
    itemId = ITEM_AMULETOFLOSS
}

local buyAol = TalkAction("!aol")

function buyAol.onSay(player, words, param, type)
    if not player:removeMoney(config.price) then
        player:sendCancelMessage(string.format("You need %d gold coins to buy %s.", config.price, ItemType(config.itemId):getName()))
        return false
    end

    local aol = player:addItem(config.itemId, 1)
    if aol then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, string.format("You have successfully purchased a %s.", aol:getName()))
        player:getPosition():sendMagicEffect(CONST_ME_GIFT_WRAPS)
    end
    return false
end

buyAol:register()

If you are using the official TFS...
I do not know how to create scripts, but I think that to run revscripts is just that, I hope that certain xd

Lua:
local aol = TalkAction("!aol")
function aol.onSay(cid, words, param)
if doPlayerRemoveMoney(cid, 10000) then
doPlayerAddItem(cid,2173,1)
doSendMagicEffect(getPlayerPosition(cid),12)
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You've bought an amulet of loss!")
else
doPlayerSendCancel(cid,"You don't have enough money.")
doSendMagicEffect(getPlayerPosition(cid),2)
end
return true
end
aol:register()
Lua:
local config = {

rate = 2.0, -- 2.0 = 2x faster than normal.
un_equip = 6300, -- Item ID of the UN-Equipped ring.
equip = 6301 -- Item ID of the Equipped ring.

}

local expring = Action()
function expring.onDeEquip(cid, item, slot)
doPlayerSetExperienceRate(cid, 1.0)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your extra experience rate has ended.")
doTransformItem(item.uid, config.un_equip)
return true
end

function expring.onEquip(cid, item, slot)
if getConfigValue("experienceStages") == "yes" then
doPlayerSetExperienceRate(cid, getExperienceStage(getPlayerLevel(cid))*2)
else
doPlayerSetExperienceRate(cid, getConfigValue("rateExperience")*2)
end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your extra experience rate has been activated! It is now: " .. config.rate .. "x doubled your former experience rate.")
doTransformItem(item.uid, config.equip)
doDecayItem(item.uid)
return true
end

expring:id(put the ring id here)
expring:register()

EDIT
I think I made a mistake in the exp ring script, if it doesn't work, try this:

Lua:
local config = {

rate = 2.0, -- 2.0 = 2x faster than normal.
un_equip = 6300, -- Item ID of the UN-Equipped ring.
equip = 6301 -- Item ID of the Equipped ring.

}

local expring = Action()
function expring.onDeEquip(cid, item, slot)
doPlayerSetExperienceRate(cid, 1.0)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your extra experience rate has ended.")
doTransformItem(item.uid, config.un_equip)
return true
end

local expring2 = Action()
function expring2.onEquip(cid, item, slot)
if getConfigValue("experienceStages") == "yes" then
doPlayerSetExperienceRate(cid, getExperienceStage(getPlayerLevel(cid))*2)
else
doPlayerSetExperienceRate(cid, getConfigValue("rateExperience")*2)
end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your extra experience rate has been activated! It is now: " .. config.rate .. "x doubled your former experience rate.")
doTransformItem(item.uid, config.equip)
doDecayItem(item.uid)
return true
end

expring:id(put the ring id here)
expring2:id(put the ring id here)
expring:register()
expring2:register()
 
Last edited:
ty, the exp ring error :
xxxxxxxx/data/scripts/expring.lua
data/lib/compat/compat.lua:107: bad argument #1 to 'rawset' (table expected, got userdata)
stack traceback:
[C]: at 0x560311436200
[C]: in function 'rawset'
data/lib/compat/compat.lua:107: in function '__newindex'
xxxxxxx/data/scripts/expring.lua:10: in main chunk
expring.lua [error]
 
Does the exp ring have 2 id's? 1 for when equipped and another for when not? If so, i would try to register the 2 there, in each respective place...
I have no idea what this error is, but maybe it can help xd.
Another thing I know, is that revscripts are only compatible with tfs 1.3, if the expring script is 1.2 or less, it might not work for functions that have another name in tfs 1.3, then I really wouldn't know how to change this.
 
Does the exp ring have 2 id's? 1 for when equipped and another for when not? If so, i would try to register the 2 there, in each respective place...
I have no idea what this error is, but maybe it can help xd.
Another thing I know, is that revscripts are only compatible with tfs 1.3, if the expring script is 1.2 or less, it might not work for functions that have another name in tfs 1.3, then I really wouldn't know how to change this.
u meybe right, tfs 1.2 error ;/
 
data/scripts/aol.lua
Lua:
local config = {
    price = 10000,
    itemId = ITEM_AMULETOFLOSS
}

local buyAol = TalkAction("!aol")

function buyAol.onSay(player, words, param, type)
    if not player:removeMoney(config.price) then
        player:sendCancelMessage(string.format("You need %d gold coins to buy %s.", config.price, ItemType(config.itemId):getName()))
        return false
    end

    local aol = player:addItem(config.itemId, 1)
    if aol then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, string.format("You have successfully purchased a %s.", aol:getName()))
        player:getPosition():sendMagicEffect(CONST_ME_GIFT_WRAPS)
    end
    return false
end

buyAol:register()

If you are using the official TFS latest version, then you can do something like the following for the ring
Regarding the ring, I recommend that you handle the transformation with the default system in movements.xml

and you can use this script to grant additional experience when I have ring equipped
data/scripts/extraExpRing.lua
Lua:
local config = {
    ringId = 6301,
    expMultiplier = 1.5 -- +50%
}

local expRing = EventCallback

function expRing.onGainExperience(player, source, exp, rawExp)
    if not source then
        return exp
    end

    local ring = player:getSlotItem(CONST_SLOT_RING)
    if ring and ring:getId() == config.ringId then
        exp = exp * config.expMultiplier
    end

    return exp
end

expRing:register(-1)

local ringDetect = EventCallback

function ringDetect.onItemMoved(player, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if toPosition.x == CONTAINER_POSITION and toPosition.y == CONST_SLOT_RING then
        if item:getId() == config.ringId then
            player:sendTextMessage(MESSAGE_INFO_DESCR, string.format("Ring equipped you receive %d%% more exp.", (config.expMultiplier -1) * 100))
            player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN, player)
        end
    end
end

ringDetect:register(-1)

It is worth mentioning that you can merge the two files into one, to keep things more orderly, but to avoid confusion I have separated the two scripts
 
Solution
data/scripts/aol.lua
Lua:
local config = {
    price = 10000,
    itemId = ITEM_AMULETOFLOSS
}

local buyAol = TalkAction("!aol")

function buyAol.onSay(player, words, param, type)
    if not player:removeMoney(config.price) then
        player:sendCancelMessage(string.format("You need %d gold coins to buy %s.", config.price, ItemType(config.itemId):getName()))
        return false
    end

    local aol = player:addItem(config.itemId, 1)
    if aol then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, string.format("You have successfully purchased a %s.", aol:getName()))
        player:getPosition():sendMagicEffect(CONST_ME_GIFT_WRAPS)
    end
    return false
end

buyAol:register()

If you are using the official TFS latest version, then you can do something like the following for the ring
Regarding the ring, I recommend that you handle the transformation with the default system in movements.xml

and you can use this script to grant additional experience when I have ring equipped
data/scripts/extraExpRing.lua
Lua:
local config = {
    ringId = 6301,
    expMultiplier = 1.5 -- +50%
}

local expRing = EventCallback

function expRing.onGainExperience(player, source, exp, rawExp)
    if not source then
        return exp
    end

    local ring = player:getSlotItem(CONST_SLOT_RING)
    if ring and ring:getId() == config.ringId then
        exp = exp * config.expMultiplier
    end

    return exp
end

expRing:register(-1)

local ringDetect = EventCallback

function ringDetect.onItemMoved(player, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if toPosition.x == CONTAINER_POSITION and toPosition.y == CONST_SLOT_RING then
        if item:getId() == config.ringId then
            player:sendTextMessage(MESSAGE_INFO_DESCR, string.format("Ring equipped you receive %d%% more exp.", (config.expMultiplier -1) * 100))
            player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN, player)
        end
    end
end

ringDetect:register(-1)

It is worth mentioning that you can merge the two files into one, to keep things more orderly, but to avoid confusion I have separated the two scripts
im otservbr, and get this error right now :
/data/scripts/extraexpring.lua:8: attempt to index local 'expRing' (a nil value)
stack traceback:
[C]: in function '__newindex'
data/scripts/extraexpring.lua:8: in main chunk
extraexpring.lua [error]
 
Ok, in your case you can go to the file data/events/scripts/player.lua and find the event Player:onGainExperience then find inside this event for the following:
self:setBaseXpGain(displayRate * 100)
and then paste this code after:
Lua:
 local ring = player:getSlotItem(CONST_SLOT_RING)
    if ring and ring:getId() == 6301 then
        exp = exp * 1.5
    end
The code that I pasted, should be left before the return, like the red line in the following image:

1618262512730.png


respect to the other piece of code, you should look for the event Player:onItemMoved and add the following code:
1618262681495.png

Lua:
if toPosition.x == CONTAINER_POSITION and toPosition.y == CONST_SLOT_RING then
        if item:getId() == 6301 then
            self:sendTextMessage(MESSAGE_INFO_DESCR, "Ring equipped you receive 50% more exp.")
            self:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN, self)
        end
    end
 
Thanks for ur help man, but still gettin
data/scripts/extraexpring.lua:8: attempt to index local 'expRing' (a nil value)
stack traceback:
[C]: in function '__newindex'
:(
Post automatically merged:

I found ur another topic in otland, and u helped whit the same problem one man, done it an its works xDD thx
 
Last edited:
Back
Top