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

Feature Disable Effects Command

S

Shadow_

Guest
Hey everybody,
Most of you noticed what happened yesterday so it was just a miss understanding between me and the staff of otland so i decided to release this because it is frequently asked by players while it is so simple to do.
This script is made for AsgardOT and wasn't going to make it unless @mRefaat requested it.
What does it do?
when you cast this command !effects effects get disabled if it is already disabled it get enabled.
Talkactions.xml
Code:
    <talkaction words="!effects" separator=" " script="effects.lua"/>
effects.lua
Lua:
local cooldown = 15

function onSay(player, words, param)
    if player:getStorageValue(storage) <= os.time() then
        player:setStorageValue(storage, os.time() + cooldown)
        if player:getStorageValue(48091) <= 0 then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have de-activated effects.")
            player:setStorageValue(48091, 1)
        else
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have activated effects.")
            player:setStorageValue(48091, -1)    
        end
    else
        player:sendCancelMessage("Can only be executed once every " .. cooldown .. " seconds. Remaining cooldown: " .. player:getStorageValue(storage) - os.time())
    end
    return false
end

protocolgame.cpp
Find those and change them with those
C++:
void ProtocolGame::sendDistanceShoot(const Position& from, const Position& to, uint8_t type)
{
    NetworkMessage msg;
    msg.addByte(0x85);
    msg.addPosition(from);
    msg.addPosition(to);
    msg.addByte(type);
    writeToOutputBuffer(msg);
}

void ProtocolGame::sendMagicEffect(const Position& pos, uint8_t type)
{
    if (!canSee(pos)) {
        return;
    }
    NetworkMessage msg;
    msg.addByte(0x83);
    msg.addPosition(pos);
    msg.addByte(type);
    writeToOutputBuffer(msg);
}
C++:
int32_t effectstor = 48091;
int32_t effectval = -1;
void ProtocolGame::sendDistanceShoot(const Position& from, const Position& to, uint8_t type)
{
    if (player->getStorageValue(effectstor, effectval))
    {
    NetworkMessage msg;
    msg.addByte(0x85);
    msg.addPosition(from);
    msg.addPosition(to);
    msg.addByte(type);
    writeToOutputBuffer(msg);
    }
}

void ProtocolGame::sendMagicEffect(const Position& pos, uint8_t type)
{
    if (!canSee(pos)) {
        return;
    }
    if (player->getStorageValue(effectstor, effectval))
    {
    NetworkMessage msg;
    msg.addByte(0x83);
    msg.addPosition(pos);
    msg.addByte(type);
    writeToOutputBuffer(msg);
    }
}

enjoy.
 
Last edited by a moderator:
For tfs 0.4/0.3.7


talkaction
<talkaction words="!effect" event="script" value="effect.lua"/>

effect.lua
Lua:
function onSay(cid, words, param)
if getPlayerStorageValue(cid, 115201) == 1 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have de-activated effect.")
setPlayerStorageValue(cid, 115201, 0)
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have activated effect.")
setPlayerStorageValue(cid, 115201, 1)
end
return true
end
protocolgame.cpp
C++:
void ProtocolGame::sendDistanceShoot(const Position& from, const Position& to, uint8_t type)
{
    if(type > SHOOT_EFFECT_LAST || (!canSee(from) && !canSee(to)))
        return;

    NetworkMessage_ptr msg = getOutputBuffer();
    if(!msg)
        return;

    TRACK_MESSAGE(msg);
    AddDistanceShoot(msg, from, to, type);
}

void ProtocolGame::sendMagicEffect(const Position& pos, uint8_t type)
{
    if(type > MAGIC_EFFECT_LAST || !canSee(pos))
        return;

    NetworkMessage_ptr msg = getOutputBuffer();
    if(!msg)
        return;

    TRACK_MESSAGE(msg);
    AddMagicEffect(msg, pos, type);
}

change them with
C++:
void ProtocolGame::sendDistanceShoot(const Position& from, const Position& to, uint8_t type)
{
    if(type > SHOOT_EFFECT_LAST || (!canSee(from) && !canSee(to)))
        return;

    std::string value;
    player->getStorage("115201", value);
    int32_t tmp = (int32_t)atoi(value.c_str());
    if(tmp > 0) {

    NetworkMessage_ptr msg = getOutputBuffer();
    if(!msg)
        return;

    TRACK_MESSAGE(msg);
    AddDistanceShoot(msg, from, to, type);
  }
}

void ProtocolGame::sendMagicEffect(const Position& pos, uint8_t type)
{
    if(type > MAGIC_EFFECT_LAST || !canSee(pos))
        return;

    std::string value;
    player->getStorage("115201", value);
    int32_t tmp = (int32_t)atoi(value.c_str());
    if(tmp > 0) {

    NetworkMessage_ptr msg = getOutputBuffer();
    if(!msg)
        return;

    TRACK_MESSAGE(msg);
    AddMagicEffect(msg, pos, type);
   }
}


enjoy ;)
 
Back
Top