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

Solved [OTHire] Use on yourself / Use on target

LuisPro

World War <3
Joined
May 10, 2009
Messages
425
Solutions
1
Reaction score
53
Hello.
I wonder how to do stuff like this by server side:
1. if player write "uh" effect will be like on 8.6 with UH and "Use on yourself" <-- spells
2. if player write "mf" effect will be like on 8.6 with mana potion and "Use on yourself" <- actions
3. if player attacking player/monster and write "sd" effect will be like on 8.6 with SD and "Use on target" <-- spells

uh, mf, sd is just text what should be written in "Hotkeys". Visiblity this text aboive head (like exura) is optionaly.

It should be done by talkactions or in spells?
Someone have idea how it can be done?

Greetings.

About UH if i do like this:
Code:
    <instant name="UH" words="uh" needlearn="0" lvl="8" maglv="4" mana="0" selftarget="1" aggressive="0" script="healing/ultimate_healing_rune.lua">
        <vocation name="Sorcerer"/> <vocation name="Master Sorcerer"/>
        <vocation name="Druid"/>    <vocation name="Elder Druid"/>
        <vocation name="Paladin"/>  <vocation name="Royal Paladin"/>
        <vocation name="Knight"/>  <vocation name="Elite Knight"/>
    </instant>

Its works well but it not do -1 uh charge from BP. Any sugestions? :P
 
Last edited by a moderator:
Talkaction script on MF? If so, make the script return false

lel i dont know how but its works perfect :D TY :*

how was oryginal exhaust on manafluids on real tibia 7.6?

This is my code now:
Code:
function onSay(cid, words, param)
    local exhaust = 666
    if getPlayerItemCount(cid, 2006, 7) ~= 0 then
        if(not exhaustion.get(cid, exhaust)) then
        exhaustion.set(cid, exhaust, 0.5)
        doPlayerAddMana(cid, 100)
        doPlayerSay(cid, "Aaaah...", 16)
        --doPlayerRemoveItem(cid, 2006, 1, 7)
        end
    end
    return false
end
For first look everything working good. but when i start "spam" exhaust gets weird on second use, first use is normal, this second one is too fast, and every next one is good.

i take this part of exhaust code from npc Lubo:
Code:
    exhaustion.set(cid, exhaust, 3600)
    setPlayerStorageValue(cid, 27031, 1)
  elseif msgcontains(msg, "addon") and getPlayerStorageValue(cid, fcitizen) < 1 and getPlayerStorageValue(cid, 27031) == 1 then
  if(not exhaustion.get(cid, exhaust)) then
    npcHandler:say("Just in time! Your backpack is finished. Here you go, I hope you like it.", cid)
    setPlayerStorageValue(cid, fcitizen, 1)
3600 - so its look like 1 = 1sec. but when i set 1 in my code, and test it was work like 2s. ;s
so i set to 0.5 to get 1sec. effect. but that second drink problem ;s

Should i use different exhaust code in different style or something?
Or someone know why this mf drinking acting weird on second drink
(i can make video if u guys want to see that)
 
Last edited:
bumpek

i think its happend becouse its use os.time()+time. (my target exhaust is 1sec) so script take os.time()+ add 1 sec.
but sometimes he take os.time just when new second is beginning then second use is good delay, but i think sometimes it take os.time couple ms before new sec. and new second comes just after couple ms and then i got this too fast drink effect
its just my idea, i can be wrong
is there any other way to use exhaust without os.time?
or force somehow to wait full 1sec. not only this time left to new sec.

what u guys think? im right or wrong?

yeah, i was right.

The accuracy of this exhaust is +/- 999ms. Consider changing os.time to os.mtime. Not sure if mtime is implemented though as standard C lua dosn't seem to have it.
And if the integer value is to big to be stored perhaps just strip away a static 50 years or so from the timestamp.
os.time returns timestamp in seconds, mtime returns in milliseconds.

So if you cast a spell at 2.93 seconds, and the spell has 1 second exhaust, you will be able to cast it again in 0.07 seconds because the second timestamp will change between 2(.93) to 3(.00).
Using mtime to return it in milliseconds means if you cast a spell at 2.931 seconds with 1 second cooldown, you will have to wait until time has elapsed into 3.931 seconds.

so, simple change os.time to os.mtime here:

Code:
exhaustion =
{

    check = function (cid, storage)
        local exhaust = getPlayerStorageValue(cid, storage)
        if (os.mtime() >= exhaust) then
            return false
        else
            return true
        end
    end,

    get = function (cid, storage)
        local exhaust = getPlayerStorageValue(cid, storage)
        local left = exhaust - os.mtime()
        if (left >= 0) then
            return left
        else
            return false
        end
    end,

    set = function (cid, storage, time)
        setPlayerStorageValue(cid, storage, os.mtime()+time)
    end,

    make = function (cid, storage, time)
        local exhaust = exhaustion.get(cid, storage)
        if (exhaust > 0) then
            return false
        else
            exhaustion.set(cid, storage, time)
            return true
        end
    end
}

is not working, what can i do?
 
Last edited:
Ok, so i walk around this by addEvent and works well!

But my question is: if i add addEvent to every use of mana fluid for every player, it will not stress/lag? server or something?
 
Talkaction script on MF? If so, make the script return false
Everything works well, there is no "mf" above player head and local chat, but when player got open game chat, or any other chat, "mf" is spaming here. Any way to prevent this?
 
Everything works well, there is no "mf" above player head and local chat, but when player got open game chat, or any other chat, "mf" is spaming here. Any way to prevent this?

just simple #s mf
not best solution, but better than nothing xd

if i add addEvent to every use of mana fluid for every player, it will not stress/lag? server or something?
 
Back
Top