• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Mug of Mead script help.

  • Thread starter Thread starter tejdi
  • Start date Start date
T

tejdi

Guest
Hello, it's my script:
meadcup.lua:

Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if target.itemid ~= 2012 then
        return false
    end

    item:remove(1)
    player:addCondition(CONDITION_DRUNK)
    toPosition:sendMagicEffect(CONST_ME_POFF)
    return true
end

and actions.xml:
Code:
    <action itemid="2012" script="mateusz/meadcup.lua"/>

But it doesn't check that is cup with mead. It can be empty cup, how can edit that?
 
Been up for 36 hours.. something tells me to try something like this?

Code:
if target.itemid ~= (2012, 1) then -- idea being itemID, subID
return false
end

Haha, good luck. :x
 
TFS 1.1
Code:
GREEN   = MESSAGE_INFO_DESCR

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local itemID = item:getId()

    if item:getFluidType() == 0 then
        return player:sendTextMessage(GREEN, ItemType(itemID):getName().." is empty :(")
    end
   
    if target:isCreature() then
        if item:getFluidType() == 3 then -- 3 == beer
        item:remove(1)
        player:addCondition(CONDITION_DRUNK)
        toPosition:sendMagicEffect(CONST_ME_POFF)
    else player:sendTextMessage(GREEN, "I prevented spilling, whatever is inside the mug!! I'm too OP!")
    end
return true
end
 
TFS 1.1
Code:
GREEN   = MESSAGE_INFO_DESCR

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local itemID = item:getId()

    if item:getFluidType() == 0 then
        return player:sendTextMessage(GREEN, ItemType(itemID):getName().." is empty :(")
    end
  
    if target:isCreature() then
        if item:getFluidType() == 3 then -- 3 == beer
        item:remove(1)
        player:addCondition(CONDITION_DRUNK)
        toPosition:sendMagicEffect(CONST_ME_POFF)
    else player:sendTextMessage(GREEN, "I prevented spilling, whatever is inside the mug!! I'm too OP!")
    end
return true
end

Where can i check other types? Any list or smth?
I need mead not beer ?:x
 
Ok so mead it number 43. (I've discovered it by this script )
Code:
    player:sendTextMessage(GREEN, "It' is it: " ..item:getFluidType().. ".")

Maybe it will help someone.


-----------------
Full script will look like that:

Code:
GREEN   = MESSAGE_INFO_DESCR
local drunk = Condition(CONDITION_DRUNK)
drunk:setParameter(CONDITION_PARAM_TICKS, 60000)

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local itemID = item:getId()

    if item:getFluidType() == 0 then
        return player:sendTextMessage(GREEN, ItemType(itemID):getName().." is empty.")
    end
  
    if target:isCreature() then
        if item:getFluidType() == 43 then -- 3 == beer
        item:remove(1)
        --player:addCondition(CONDITION_DRUNK)
        player:addCondition(drunk)
        toPosition:sendMagicEffect(CONST_ME_POFF)
    else
    player:sendTextMessage(GREEN, "It' is it: " ..item:getFluidType().. ".")
    end
return true
end
end
 
Found this in const.h
Code:
enum FluidColors_t
{
   FLUID_EMPTY     = 0x00,
   FLUID_BLUE     = 0x01,
   FLUID_RED     = 0x02,
   FLUID_BROWN     = 0x03,
   FLUID_GREEN     = 0x04,
   FLUID_YELLOW   = 0x05,
   FLUID_WHITE     = 0x06,
   FLUID_PURPLE   = 0x07
};

enum FluidTypes_t
{
   FLUID_NONE       = FLUID_EMPTY,
   FLUID_WATER       = FLUID_BLUE,
   FLUID_BLOOD       = FLUID_RED,
   FLUID_BEER       = FLUID_BROWN,
   FLUID_SLIME       = FLUID_GREEN,
   FLUID_LEMONADE     = FLUID_YELLOW,
   FLUID_MILK       = FLUID_WHITE,
   FLUID_MANA       = FLUID_PURPLE,

   FLUID_LIFE       = FLUID_RED + 8,
   FLUID_OIL       = FLUID_BROWN + 8,
   FLUID_URINE       = FLUID_YELLOW + 8,
   FLUID_COCONUTMILK   = FLUID_WHITE + 8,
   FLUID_WINE       = FLUID_PURPLE + 8,

   FLUID_MUD       = FLUID_BROWN + 16,
   FLUID_FRUITJUICE   = FLUID_YELLOW + 16,

   FLUID_LAVA       = FLUID_RED + 24,
   FLUID_RUM       = FLUID_BROWN + 24,
   FLUID_SWAMP       = FLUID_GREEN + 24,

   FLUID_TEA       = FLUID_BROWN + 32,
   FLUID_MEAD       = FLUID_BROWN + 40
};
Code:
FLUID_MEAD = FLUID_BROWN + 40
So 3+40 = mead, which is what you found out as well. :3

-- edit
So to make it a bit faster you could use..
Code:
if item:getFluidType() == FLUID_MEAD then
 
Last edited by a moderator:
Back
Top