• 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 [TFS 1.0] Enable/Disable emoted spells on your character

Ninja

Global Moderator
Staff member
Global Moderator
Joined
Apr 6, 2010
Messages
5,947
Solutions
34
Reaction score
1,584
Location
Sweden
enums.h
replace
Code:
enum StorageValues_t {
    STORAGEVALUE_PROMOTION = 30018
};
with
Code:
enum StorageValues_t {
    STORAGEVALUE_PROMOTION = 30018,
    STORAGEVALUE_EMOTE = 30019
};

game.cpp

replace

Code:
bool Game::playerSaySpell(Player* player, SpeakClasses type, const std::string& text)
{
    std::string words = text;

    TalkActionResult_t result = g_talkActions->playerSaySpell(player, type, words);
    if (result == TALKACTION_BREAK) {
        return true;
    }

    result = g_spells->playerSaySpell(player, words);
    if (result == TALKACTION_BREAK) {
        if (!g_config.getBoolean(ConfigManager::EMOTE_SPELLS)) {
            return internalCreatureSay(player, SPEAK_SAY, words, false);
        } else {
            return internalCreatureSay(player, SPEAK_MONSTER_SAY, words, false);
        }

    } else if (result == TALKACTION_FAILED) {
        return true;
    }

    return false;
}
with
Code:
bool Game::playerSaySpell(Player* player, SpeakClasses type, const std::string& text)
{
    std::string words = text;

    TalkActionResult_t result = g_talkActions->playerSaySpell(player, type, words);
    if (result == TALKACTION_BREAK) {
        return true;
    }

    result = g_spells->playerSaySpell(player, words);
    if (result == TALKACTION_BREAK) {
        int32_t value;
        player->getStorageValue(STORAGEVALUE_EMOTE, value);
        if (!g_config.getBoolean(ConfigManager::EMOTE_SPELLS) && value != 1) {
            return internalCreatureSay(player, SPEAK_SAY, words, false);
        } else {
            return internalCreatureSay(player, SPEAK_MONSTER_SAY, words, false);
        }

    } else if (result == TALKACTION_FAILED) {
        return true;
    }

    return false;
}
Talkaction example
Code:
function onSay(cid, words, param)
    local player = Player(cid)
    if param == "emote" and player:getStorageValue(30019) < 1 then
        player:setStorageValue(30019, 1)
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have enabled emoted spells.")
    elseif param == "normal" and player:getStorageValue(30019) == 1 then
        player:setStorageValue(30019, 0)
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have disabled emoted spells.")
    end
    return false
end
 
Last edited:
Cool Ninja Really Helpful but you should add exhaustion to the script :)

A 0.3.6/0.4 script with exhaustion
Code:
function onSay(cid, words, param)
    local player = Player(cid)
    local time = 5
    if exhaustion.check(cid, 30017) then
    doPlayerSendCancel(cid, "Exhaustion Please Wait "..exhaustion.get(cid,30017).."")
return true
end
    if param == "emote" and doPlayergetStorageValue(cid, 30019) < 1 then
        doPlayerSetStorageValue(cid,30019, 1)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have enabled emoted spells.")
        exhaustion.set(cid, 30017,time)
    elseif param == "normal" and doPlayergetStorageValue(cid, 30019) == 1 then
        doPlayerSetStorageValue(cid, 30019, 0)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have disabled emoted spells.")
    end
    return false
end
 
Last edited:
go to your login.lua and under local player = Player(cid) add this:
Code:
player:setStorageValue(30019, 1)
 
@Ninja I don't know why, but when I use this with the latest source I get an error
Code:
1>..\src\game.cpp(3511): error C2660: 'Spells::playerSaySpell' : function does not take 3 arguments
I've used this before with source compiled on the 22nd of December and it worked fine. But with today's source it fails.
 
I have compiled this feature with latest version of forgottenserver 1.0 (from github). It seems that this error is connected with your source code. Have you installed/copied it correctly? Additionally, local changes in source code can cause errors.
 
@dominique120

Remove what I've marked with red
result = g_spells->playerSaySpell(player, type, words);
 
Got a problem in enums.h ,i don't have this
Code:
enum StorageValues_t {
    STORAGEVALUE_PROMOTION = 30018
};

@Ninja
 
Last edited:
This just changes it from players saying the spells and the spell words showing up beside them orange or whatever, and makes them show up only in their channel or what?
 
This just changes it from players saying the spells and the spell words showing up beside them orange or whatever, and makes them show up only in their channel or what?
Yes, it displays spells in orange text and this only applies to players who got storage key 30019 and value 1 (normally emote spells affect all players).
 
Oh ok I get you... Right on, thanks, could come in handy :D
 
Hey (noob alert!),

Where do i find "enums.h" and "game.cpp" ?

I appreciate the help! Thanks!
 
Those are in the sources. That is a source file and a header file.
 
You lost me at Sources :(

I still don't know where to find the Source files :/

I know... I know... I'm retarded.

But could you break it down - dummy version -- for me? You're the best :*
 
You lost me at Sources :(

I still don't know where to find the Source files :/

I know... I know... I'm retarded.

But could you break it down - dummy version -- for me? You're the best :*

Get the source here, read a bit, explore a bit, play a bit then things will make sense.

Come back in a few days and you'll see that stuff makes more sense. Ask in the support board if you have questions.

Don't be afraid to question, explore and be bold.
 
Thanks for the link and for the words of advice!


I still can't get it to work. I editing those files just as you said.

I put the "Src" Folder in the same folder as my C:/OtServer, is that right?


-Edit-
Okay so I learned a little bit. I need to compile the new sources! And I should re-compile everytime I edit them right?
 
Last edited:
Back
Top