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

Block item on event

Hertus

New Member
Joined
Jul 28, 2018
Messages
42
Reaction score
2
How to block the use of items during the event? I don't want to add this code in every file. I am currently using this:

Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY)
combat:setParameter(COMBAT_PARAM_CREATEITEM, ITEM_MAGICWALL)


local storageEventJoin = 1000
function onCastSpell(creature, variant, isHotkey)
    if creature:getStorageValue(storageEventJoin) > 0 then
        doCreatureSay(creature, "You cannot use this item in an event.", TALKTYPE_ORANGE_1)
        return false
    end
    
    return combat:execute(creature, variant)
end
 
Solution
HERE
C++:
    uint32_t storageID = 0;
    int32_t storageValue;
    if (player->getStorageValue(storageID, storageValue) && storageValue > 0) {
        g_game.internalCreatureSay(player, TALKTYPE_MONSTER_SAY, "You cannot use this item in an event.", false);
        g_game.addMagicEffect(player->getPosition(), CONST_ME_POFF);
        return false;
    }
HERE
C++:
    uint32_t storageID = 0;
    int32_t storageValue;
    if (player->getStorageValue(storageID, storageValue) && storageValue > 0) {
        g_game.internalCreatureSay(player, TALKTYPE_MONSTER_SAY, "You cannot use this item in an event.", false);
        g_game.addMagicEffect(player->getPosition(), CONST_ME_POFF);
        return false;
    }
 
Solution
Thank you! It works! :)

I noticed something like this in the cpp code:
Code:
if (player->hasFlag(PlayerFlag_CannotUseSpells)) {
       zreturn false;
 }

Can i somehow use it in lua?
I would like to manage this in .lua and not .cpp :)
Code:
player:setFlag(PlayerFlag_CannotUseSpells)
 
Last edited:
Thank you! It works! :)

I noticed something like this in the cpp code:
Code:
if (player->hasFlag(PlayerFlag_CannotUseSpells)) {
       zreturn false;
 }

Can i somehow use it in lua?
I would like to manage this in .lua and not .cpp :)
Code:
player:setFlag(PlayerFlag_CannotUseSpells)
You cannot use these flags, the flags belong to the groups, if you modify one, you will be modifying all the players.

There is nothing wrong with modifying the sources and much less this code so simple and small, when you need to delete it you do it and that's it.
You can still control it from lua, it's the same, just add or remove the storage right?

You can also create a new group and add whatever flags you want to them, then use switch to party player and you're good to go. when they leave the event you return them to the default group.
 
Back
Top