• 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 What does this line mean?

Westbay

New Member
Joined
Mar 6, 2018
Messages
27
Reaction score
3
What does this line mean? "setConditionParam(condition, CONDITION_PARAM_SUBID, 99)" May I remove it if I just want the potion to increase my magic level by 10 for 60 minutes?

Lua:
local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_TICKS, 60 * 60 * 1000) -- 10 minutes
setConditionParam(condition, CONDITION_PARAM_STAT_MAGICLEVEL, 10)
setConditionParam(condition, CONDITION_PARAM_SUBID, 99)
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(not isSorcerer(cid) and not isDruid(cid)) then
        doCreatureSay(cid, "Only sorcerers and druids may drink this fluid.", TALKTYPE_ORANGE_1, cid)
        return true
    end
    if(doAddCondition(cid, condition)) then
        doSendMagicEffect(fromPosition, CONST_ME_MAGIC_RED)
        doRemoveItem(item.uid, 1)
        doCreatureSay(cid, "Your magic level increased by 10 for 60 minutes.", TALKTYPE_ORANGE_1, cid)
    end
    return true
end
 
What does this line mean? "setConditionParam(condition, CONDITION_PARAM_SUBID, 99)" May I remove it if I just want the potion to increase my magic level by 10 for 60 minutes?

Lua:
local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_TICKS, 60 * 60 * 1000) -- 10 minutes
setConditionParam(condition, CONDITION_PARAM_STAT_MAGICLEVEL, 10)
setConditionParam(condition, CONDITION_PARAM_SUBID, 99)
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(not isSorcerer(cid) and not isDruid(cid)) then
        doCreatureSay(cid, "Only sorcerers and druids may drink this fluid.", TALKTYPE_ORANGE_1, cid)
        return true
    end
    if(doAddCondition(cid, condition)) then
        doSendMagicEffect(fromPosition, CONST_ME_MAGIC_RED)
        doRemoveItem(item.uid, 1)
        doCreatureSay(cid, "Your magic level increased by 10 for 60 minutes.", TALKTYPE_ORANGE_1, cid)
    end
    return true
end

No way to test but I think its there so the condition cannot be overridden with the same attributes. So lets say we have another spell which increases your mlvl. This way you can combine them

I think thats how it works (you can test) :p

And also allows you to manage it by checking specific conditions on player and removing them using different scripts
 
@mackerel is right, subid is a unique identifier for the condition so that you can find it later and alter it instead of having to interfere with the default subid and overwrite other conditions with new ones
 
Alright thanks a lot! :)

When I use this script it gives me 10 magic levels but it also decreases my shielding with 10 and I can not heal or do any spells. Where am I wrong?

Lua:
local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_TICKS, 60 * 60 * 1000) -- 10 minutes
setConditionParam(condition, CONDITION_PARAM_STAT_MAGICLEVEL, 10)
setConditionParam(condition, CONDITION_PARAM_SUBID, 99)
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(not isSorcerer(cid) and not isDruid(cid)) then
        doCreatureSay(cid, "Only sorcerers and druids may drink this fluid.", TALKTYPE_ORANGE_1, cid)
        return true
    end
    if(doAddCondition(cid, condition)) then
        doSendMagicEffect(fromPosition, CONST_ME_MAGIC_RED)
        doRemoveItem(item.uid, 1)
        doCreatureSay(cid, "Your magic level increased by 10 for 60 minutes.", TALKTYPE_ORANGE_1, cid)
    end
    return true
end
ORIGINAL SCRIPT
Lua:
local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_TICKS, 10 * 60 * 1000) -- 10 minutes
setConditionParam(condition, CONDITION_PARAM_STAT_MAGICLEVEL, 3)
setConditionParam(condition, CONDITION_PARAM_SKILL_SHIELD, -10)
setConditionParam(condition, CONDITION_PARAM_SUBID, 99)
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(not isSorcerer(cid) and not isDruid(cid)) then
        doCreatureSay(cid, "Only sorcerers and druids may drink this fluid.", TALKTYPE_ORANGE_1, cid)
        return true
    end
    if(doAddCondition(cid, condition)) then
        doSendMagicEffect(fromPosition, CONST_ME_MAGIC_RED)
        doRemoveItem(item.uid, 1)
        doCreatureSay(cid, "You feel smarter.", TALKTYPE_ORANGE_1, cid)
    end
    return true
end
 
not sure why you wouldn't be able to use spells, doesn't sound like it's an issue with this script
but as for your shield you have setConditionParam(condition, CONDITION_PARAM_SKILL_SHIELD, -10) in your script
 
This one looks alright OP :confused:

you should change the SUBID from 99 to something else and see if that works

if Not I would test the script on another item
 
Back
Top Bottom