Feature [TFS 1.0] Enable/Disable emoted spells on your character

Ninja

Global Moderator
Staff member
Global Moderator
Joined
Apr 6, 2010
Messages
5,935
Best answers
30
Reaction score
1,415
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:

tetra20

DD
Joined
Jan 17, 2009
Messages
1,304
Best answers
3
Reaction score
286
Location
Egypt
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:

dominique120

Science & Reason
Premium User
Joined
Jun 16, 2013
Messages
3,891
Best answers
2
Reaction score
991
Location
Númenor
Is there a way to enable this permanently for everyone?
 

Printer

if Printer then print("LUA") end
Premium User
Joined
Dec 27, 2009
Messages
5,733
Best answers
21
Reaction score
2,015
Location
Sweden?
go to your login.lua and under local player = Player(cid) add this:
Code:
player:setStorageValue(30019, 1)
 

dominique120

Science & Reason
Premium User
Joined
Jun 16, 2013
Messages
3,891
Best answers
2
Reaction score
991
Location
Númenor
@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.
 

kamilwxx

This account is inactive.
Joined
Dec 7, 2013
Messages
86
Best answers
0
Reaction score
15
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.
 
OP
Ninja

Ninja

Global Moderator
Staff member
Global Moderator
Joined
Apr 6, 2010
Messages
5,935
Best answers
30
Reaction score
1,415
Location
Sweden
@dominique120

Remove what I've marked with red
result = g_spells->playerSaySpell(player, type, words);
 

Sweetlove

Excellent OT User
Joined
Jun 22, 2009
Messages
270
Best answers
0
Reaction score
11
Location
Sverige
Got a problem in enums.h ,i don't have this
Code:
enum StorageValues_t {
    STORAGEVALUE_PROMOTION = 30018
};
@Ninja
 
Last edited:

Codinablack

Dreamer
Joined
Dec 26, 2013
Messages
1,217
Best answers
4
Reaction score
373
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?
 
OP
Ninja

Ninja

Global Moderator
Staff member
Global Moderator
Joined
Apr 6, 2010
Messages
5,935
Best answers
30
Reaction score
1,415
Location
Sweden
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).
 

Codinablack

Dreamer
Joined
Dec 26, 2013
Messages
1,217
Best answers
4
Reaction score
373
Oh ok I get you... Right on, thanks, could come in handy :D
 

imkingran

Learning everyday.
Premium User
Joined
Jan 15, 2014
Messages
1,258
Best answers
18
Reaction score
379
Hey (noob alert!),

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

I appreciate the help! Thanks!
 

Codinablack

Dreamer
Joined
Dec 26, 2013
Messages
1,217
Best answers
4
Reaction score
373
Those are in the sources. That is a source file and a header file.
 

imkingran

Learning everyday.
Premium User
Joined
Jan 15, 2014
Messages
1,258
Best answers
18
Reaction score
379
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 :*
 

dominique120

Science & Reason
Premium User
Joined
Jun 16, 2013
Messages
3,891
Best answers
2
Reaction score
991
Location
Númenor
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.
 

imkingran

Learning everyday.
Premium User
Joined
Jan 15, 2014
Messages
1,258
Best answers
18
Reaction score
379
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:
Top