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

Lua 2 scripts fix.

DukeeH

Active Member
Joined
Dec 6, 2010
Messages
550
Solutions
3
Reaction score
39
Hello guys, I'd like your help to fix two scripts...
A doll that adds skills/magic with !skill name (should add x skills)
Problem: it's adding too much skill (some ppl got 200+) and less than it should (8) for others.

Code:
function onSay(cid, words, param)
local Skillsy = { ["fist"]={SKILL_FIST}, ["club"]={SKILL_CLUB}, ["sword"]={SKILL_SWORD}, ["axe"]={SKILL_AXE}, ["distance"]={SKILL_DISTANCE}, ["shield"]={SKILL_SHIELD}, ["fishing"]={SKILL_FISHING}, ["magic"]={SKILL__MAGLEVEL} }
local msg = {"Escolha um skill (!skill nome), Opções de skill: fist, club, sword, axe, distance, shield, fishing, magic!", "Seus skills foram adicionados!", "Precisa de uma skill doll, visite nosso shop!", "Você só pode usar 3 skill dolls por character!"}
local param = string.lower(param)
local storage = 490289 -- storageID to use.


if(param ~= "" and Skillsy[param]) then
        if(getPlayerItemCount(cid, 165) > 0) then
                if getPlayerStorageValue(cid, storage) < 2 then
                    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, msg[2])
                    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_GIFT_WRAPS)
                    doPlayerAddSkill(cid, Skillsy[param][1], 8)
                    doPlayerRemoveItem(cid, 165, 1)
                    setPlayerStorageValue(cid, storage, (getPlayerStorageValue(cid, storage)+1))
                else
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, msg[4])
                end
        else
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, msg[3])
        end
    else
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, msg[1])
    end
    return true
end


Function: (cyko helped me a few years ago).
050-function.lua

Code:
function doPlayerAddMagLevel(cid, amount)
    for i = 1, amount do
        doPlayerAddSpentMana(cid, math.ceil((getPlayerRequiredMana(cid, getPlayerMagLevel(cid, true) + 1) - getPlayerSpentMana(cid)) / getConfigInfo('rateMagic')))
    end
    return true
end

function doPlayerAddSkill(cid, skill, amount, round)
    if(skill == SKILL__LEVEL) then
        return doPlayerAddLevel(cid, amount, round)
    elseif(skill == SKILL__MAGLEVEL) then
        return doPlayerAddMagLevel(cid, amount)
    end

    return doPlayerAddSkillTry(cid, skill, math.ceil((getPlayerRequiredSkillTries(cid, skill, getPlayerSkillLevel(cid, skill) + 1) - getPlayerSkillTries(cid, skill)) / getConfigInfo('rateSkill')))
end


Second script:
A ring that doubles your exp when equiped that has duration.
Problem: It's not going down (duration) or expiring.

items.xml
Code:
    <item id="164" article="a" name="experience ring">
        <attribute key="weight" value="80" />
        <attribute key="slotType" value="ring" />
        <attribute key="duration" value="3600" />
        <attribute key="showduration" value="1" />
        <attribute key="description" value="Doubles your experience when equiped." />
    </item>
    <item id="166" article="a" name="experience ring">
        <attribute key="weight" value="80" />
        <attribute key="slotType" value="ring" />
        <attribute key="stopduration" value="1" />
        <attribute key="showduration" value="1" />
        <attribute key="description" value="Doubles your experience when equiped." />
    </item>

movements.xml
Code:
    <movevent type="Equip" itemid="164" slot="ring" event="function" value="onEquipItem"/>
    <movevent type="Equip" itemid="166" slot="ring" event="script" value="expring.lua"/>
    <movevent type="DeEquip" itemid="164" slot="ring" event="script" value="expring.lua"/>

expring.lua
Code:
local config = {

rate = 2.0, -- 2.0 = 2x faster than normal.
un_equip = 166, -- Item ID of the UN-Equipped ring.
equip = 164 -- 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


Thanks.
 
Last edited:
Remove the tags in the script please, also this should be in request, since it isn't your script and you are asking to alter the script not fix it.
 
Remove the tags in the script please, also this should be in request, since it isn't your script and you are asking to alter the script not fix it.
Sorry Codex, I'm asking for a fix, both scripts are supposed to do what i'm asking, but are bugged in some way.
Removed the tags, but why? isn't cleaner to see it with the tags?
 
Last edited:
Sorry Codex, I'm asking for a fix, both scripts are supposed to do what i'm asking, but are bugged in some way.
Removed the tags, but why? isn't cleaner to see it with the tags?
You had color tags in the script, you can put the code tags back
 
Code:
    <item id="164" article="a" name="experience ring">
        <attribute key="weight" value="80" />
        <attribute key="slotType" value="ring" />
        <attribute key="decayTo" value="0" />
        <attribute key="transformDeEquipTo" value="166" />
        <attribute key="duration" value="3600" />
        <attribute key="showduration" value="1" />
        <attribute key="description" value="Doubles your experience when equiped." />
    </item>
    <item id="166" article="a" name="experience ring">
        <attribute key="weight" value="80" />
        <attribute key="slotType" value="ring" />
        <attribute key="transformEquipTo" value="164" />
        <attribute key="stopduration" value="1" />
        <attribute key="showduration" value="1" />
        <attribute key="description" value="Doubles your experience when equiped." />
    </item>
 
Code:
    <item id="164" article="a" name="experience ring">
        <attribute key="weight" value="80" />
        <attribute key="slotType" value="ring" />
        <attribute key="decayTo" value="0" />
        <attribute key="transformDeEquipTo" value="166" />
        <attribute key="duration" value="3600" />
        <attribute key="showduration" value="1" />
        <attribute key="description" value="Doubles your experience when equiped." />
    </item>
    <item id="166" article="a" name="experience ring">
        <attribute key="weight" value="80" />
        <attribute key="slotType" value="ring" />
        <attribute key="transformEquipTo" value="164" />
        <attribute key="stopduration" value="1" />
        <attribute key="showduration" value="1" />
        <attribute key="description" value="Doubles your experience when equiped." />
    </item>
Thanks for your time, will try.
 
superman-1e81lfm.jpg
 
If you want to give them 8 levels each time they use it change your 50-function with this

Code:
function doPlayerAddSkill(cid, skill, amount, round)
    if(skill == SKILL__LEVEL) then
        return doPlayerAddLevel(cid, amount, round)
    elseif(skill == SKILL__MAGLEVEL) then
        return doPlayerAddMagLevel(cid, amount)
    end
         --8 would be 8 levels each time--
    for 1, 8 do
        doPlayerAddSkillTry(cid, skill, getPlayerRequiredSkillTries(cid, skill) + 1)
    end
end
 
Back
Top