• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

Block item on event

Hertus

Premium User
Premium User
Joined
Jul 28, 2018
Messages
26
Reaction score
1
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;
    }

Sarah Wesker

ค∂vαηcε รүηтαx ❤
Support Team
Joined
Mar 16, 2017
Messages
1,276
Solutions
139
Reaction score
1,591
Location
London
GitHub
MillhioreBT
Twitch
millhiore_bt
YouTube
millhiorebt
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
OP
OP
H

Hertus

Premium User
Premium User
Joined
Jul 28, 2018
Messages
26
Reaction score
1
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:

Sarah Wesker

ค∂vαηcε รүηтαx ❤
Support Team
Joined
Mar 16, 2017
Messages
1,276
Solutions
139
Reaction score
1,591
Location
London
GitHub
MillhioreBT
Twitch
millhiore_bt
YouTube
millhiorebt
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.
 
Top