• 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 How can i remove potion 'on use' in this script

1268995

Member
Joined
Sep 9, 2010
Messages
422
Reaction score
13
Hello guys, i have this potion script:

Code:
local config = {
        removeOnUse = "yes",
        usableOnTarget = "yes", -- can be used on target? (fe. healing friend)
        splashable = "no",

        realAnimation = "no", -- make text effect visible only for players in range 1x1
        healthMultiplier = 1.0,
        manaMultiplier = 1.0
}

config.removeOnUse = getBooleanFromString(config.removeOnUse)
config.usableOnTarget = getBooleanFromString(config.usableOnTarget)
config.splashable = getBooleanFromString(config.splashable)
config.realAnimation = getBooleanFromString(config.realAnimation)
local POTIONS =
{
        [127] = {empty = 0, splash = 2, health = {1800, 2200}, level = 1, vocations = {1, 2, 5, 6}, vocStr = "sorcerers and druids"}, -- mage pot
        [128] = {empty = 0, splash = 2, health = {2600, 3100}, level = 1, vocations = {4, 8}, vocStr = "knights"}, -- kina pot
        [129] = {empty = 0, splash = 3, health = {2100, 2400}, mana = {500, 760}, vocStr = "paladins"} -- pala pot
}

local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))
function onUse(cid, item, fromPosition, itemEx, toPosition)
        local potion = POTIONS[item.itemid]
        if(not potion) then
                return false
        end
        if(not isPlayer(itemEx.uid) or (not config.usableOnTarget and cid ~= itemEx.uid)) then
                if(not config.splashable) then
                        return false
                end
                if(toPosition.x == CONTAINER_POSITION) then
                        toPosition = getThingPos(item.uid)
                end
                doDecayItem(doCreateItem(2016, potion.splash, toPosition))
                doTransformItem(item.uid, potion.empty)
                return TRUE
        end
        if(hasCondition(cid, CONDITION_EXHAUST)) then
                doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
                return TRUE
        end
        if(((potion.level and getPlayerLevel(cid) < potion.level) or (potion.vocations and not isInArray(potion.vocations, getPlayerVocation(cid)))) and
                not getPlayerCustomFlagValue(cid, PLAYERCUSTOMFLAG_GAMEMASTERPRIVILEGES))
        then
                doCreatureSay(itemEx.uid, "Só " .. potion.vocStr .. (potion.level and (" de level " .. potion.level) or "") .. " ou mais podem beber essa poção!", TALKTYPE_ORANGE_1)
                return TRUE
        end
        local health = potion.health
        if(health and not doCreatureAddHealth(itemEx.uid, math.ceil(math.random(health[1], health[2]) * config.healthMultiplier))) then
                return false
        end
        local mana = potion.mana
        if(mana and not doPlayerAddMana(itemEx.uid, math.ceil(math.random(mana[1], mana[2]) * config.manaMultiplier))) then
                return false
        end
        doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_MAGIC_BLUE)
        if(not realAnimation) then
                doCreatureSay(itemEx.uid, "SkySoft..", TALKTYPE_ORANGE_1)
        else
                for i, tid in ipairs(getSpectators(getCreaturePosition(cid), 1, 1)) do
                        if(isPlayer(tid)) then
                                doCreatureSay(itemEx.uid, "SkySoft..", TALKTYPE_ORANGE_1, false, tid)
                        end
                end
        end
        doAddCondition(cid, exhaust)
        if(not potion.empty or config.removeOnUse) then
        doRemoveItem(item.uid, 1)
        return TRUE
        end
        doRemoveItem(item.uid, 0)
        doPlayerAddItem(cid, potion.empty, 0)
        doPlayerRemoveItem(cid, potion.empty, getPlayerItemCount(cid, potion.empty))
        doPlayerAddItem(cid, potion.empty, getPlayerItemCount(cid, potion.empty))
        return TRUE
end

This script only works if i right click on potion then click on me.

The thing is: i am using a item that does not have the possibility of right click.

I need that this script make i use the potion when i only give a single right click on the mousem without right click + click on me. Do u guys get what i am trying to say? sorry for very very very crap noob english.
 
Well, if im not wrong u have to ise a different ID, as the potions are all "use on" type. Its defined on the Tibia.dat. You should use other item or just edit tibia.dat.
 
#up lol
The thing is: i am using a item that does not have the possibility of right click.

I can write example script wait for my edit.
Say please TFS version for god sake, humans.

Code:
local mana = {500, 760}
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))

function onUse(cid, item, fromPosition, itemEx, toPosition)

        if(hasCondition(cid, CONDITION_EXHAUST)) then
                doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
                return true
        end

        if(not doPlayerAddMana(cid, math.ceil(math.random(mana[1], mana[2])))) then
            return false
        end
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE)
        doCreatureSay(itemEx.uid, "SkySoft..", TALKTYPE_ORANGE_1)
        doAddCondition(cid, exhaust)
        doRemoveItem(item.uid, 1)
        return true
end
 
Last edited:
That script was made for items that can be used with crosshair (useable / use on stat in .dat).
If you want some other item that doesn't have the crosshair attribute, you can simply make a script like this and connect it to that item and it will work. Bear in mind that the script below can be edited and configured to work for several other items instead of just one (like the potion script itself), this is just a simple sample to get you going.

function onUse(cid, item, fromPosition, itemEx, toPosition)
doCreatureAddHealth(cid, 200)
doRemoveItem(item.uid, 1)
return true
end

In general, in action scripts, itemEx is used when you want to identify the object/creature the crosshair was used on.
 
Well, if im not wrong u have to ise a different ID, as the potions are all "use on" type. Its defined on the Tibia.dat. You should use other item or just edit tibia.dat.

Well, exist actions scripts that work witouht the need right click on item + right click on player.
So i think this potion script are edited to work like right click on item + right click on player

I need to remove this part of code that say: script will only give mana if right click on item + right click on player
 
That script was made for items that can be used with crosshair (useable / use on stat in .dat).
If you want some other item that doesn't have the crosshair attribute, you can simply make a script like this and connect it to that item and it will work. Bear in mind that the script below can be edited and configured to work for several other items instead of just one (like the potion script itself), this is just a simple sample to get you going.

function onUse(cid, item, fromPosition, itemEx, toPosition)
doCreatureAddHealth(cid, 200)
doRemoveItem(item.uid, 1)
return true
end

In general, in action scripts, itemEx is used when you want to identify the object/creature the crosshair was used on.

Thanks.

But i look for on this script the part that are giving player mana and health and i do not found it.
Where is the doplayeraddhealth/mana on this code part: ?

Code:
        doAddCondition(cid, exhaust)
        if(not potion.empty or config.removeOnUse) then
        doRemoveItem(item.uid, 1)
        return TRUE
        end
        doRemoveItem(item.uid, 0)
        doPlayerAddItem(cid, potion.empty, 0)
        doPlayerRemoveItem(cid, potion.empty, getPlayerItemCount(cid, potion.empty))
        doPlayerAddItem(cid, potion.empty, getPlayerItemCount(cid, potion.empty))
 
U can laugh what u want. I wasnt wrong with my answer. If he want to make a script that makes healing stuff without crosshair, he have to use a item without crosshairs. Yes, he did mention that, but also said he wanted to remove the "crosshair part" which is done in .dat
 
#up lol


I can write example script wait for my edit.
Say please TFS version for god sake, humans.

Code:
local mana = {500, 760}
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))

function onUse(cid, item, fromPosition, itemEx, toPosition)

        if(hasCondition(cid, CONDITION_EXHAUST)) then
                doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
                return true
        end

        if(not doPlayerAddMana(cid, math.ceil(math.random(mana[1], mana[2])))) then
            return false
        end
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE)
        doCreatureSay(itemEx.uid, "SkySoft..", TALKTYPE_ORANGE_1)
        doAddCondition(cid, exhaust)
        doRemoveItem(item.uid, 1)
        return true
end
8.6, 0.3.6
 
#up lol


I can write example script wait for my edit.
Say please TFS version for god sake, humans.

Code:
local mana = {500, 760}
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))

function onUse(cid, item, fromPosition, itemEx, toPosition)

        if(hasCondition(cid, CONDITION_EXHAUST)) then
                doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
                return true
        end

        if(not doPlayerAddMana(cid, math.ceil(math.random(mana[1], mana[2])))) then
            return false
        end
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE)
        doCreatureSay(itemEx.uid, "SkySoft..", TALKTYPE_ORANGE_1)
        doAddCondition(cid, exhaust)
        doRemoveItem(item.uid, 1)
        return true
end

Yee, the script works. I am wining mana when i use the item, But appear on console:

Code:
[28/07/2015 19:01:52] [Error - Action Interface]
[28/07/2015 19:01:52] data/actions/scripts/liquids/potionsdonate.lua:onUse
[28/07/2015 19:01:52] Description:
[28/07/2015 19:01:52] (luaDoCreatureSay) Creature not found
 
Code:
local mana = {500, 760}
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))

function onUse(cid, item, fromPosition, itemEx, toPosition)

    if(hasCondition(cid, CONDITION_EXHAUST)) then
        doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
        return true
    end

    if(not doPlayerAddMana(cid, math.ceil(math.random(mana[1], mana[2])))) then
        return false
    end
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE)
    doCreatureSay(cid, "SkySoft..", TALKTYPE_ORANGE_1)
    doAddCondition(cid, exhaust)
    doRemoveItem(item.uid, 1)
    return true
end
misstype ;p
 
Code:
local mana = {500, 760}
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))

function onUse(cid, item, fromPosition, itemEx, toPosition)

    if(hasCondition(cid, CONDITION_EXHAUST)) then
        doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
        return true
    end

    if(not doPlayerAddMana(cid, math.ceil(math.random(mana[1], mana[2])))) then
        return false
    end
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE)
    doCreatureSay(cid, "SkySoft..", TALKTYPE_ORANGE_1)
    doAddCondition(cid, exhaust)
    doRemoveItem(item.uid, 1)
    return true
end
misstype ;p

Worked! Thank ya!

I add this checker:

Code:
    if((not(isKnight(itemEx.uid)) or getPlayerLevel(itemEx.uid) < 80) and getPlayerCustomFlagValue(itemEx.uid, PlayerCustomFlag_GamemasterPrivileges) == FALSE) then
        doCreatureSay(itemEx.uid, "Only knights of level 80 or above may drink this fluid.", TALKTYPE_ORANGE_1)
        return true
    end

and got this error:

Code:
[28/07/2015 19:09:18] [Error - Action Interface]
[28/07/2015 19:09:18] data/actions/scripts/liquids/potionsdonate.lua:onUse
[28/07/2015 19:09:18] Description:
[28/07/2015 19:09:18] (luaDoCreatureSay) Creature not found

Full script:

Code:
local mana = {1800, 2200}

local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))

function onUse(cid, item, fromPosition, itemEx, toPosition)

    if(hasCondition(cid, CONDITION_EXHAUST)) then
        doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
        return true
    end
   
    if((not(isKnight(itemEx.uid)) or getPlayerLevel(itemEx.uid) < 80) and getPlayerCustomFlagValue(itemEx.uid, PlayerCustomFlag_GamemasterPrivileges) == FALSE) then
        doCreatureSay(itemEx.uid, "Only knights of level 80 or above may drink this fluid.", TALKTYPE_ORANGE_1)
        return true
    end
   
    if(not doPlayerAddMana(cid, math.ceil(math.random(mana[1], mana[2])))) then
        return false
    end
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE)
    doCreatureSay(cid, "SkySoft..", TALKTYPE_ORANGE_1)
    doAddCondition(cid, exhaust)
    doRemoveItem(item.uid, 1)
    return true
end
 
not used to this tfs but maybe
doCreatureSay(itemEx.uid, "Only knights of level 80 or above may drink this fluid.", TALKTYPE_ORANGE_1) expects a creature id as 1 param, and you are giving item?
 
not used to this tfs but maybe
doCreatureSay(itemEx.uid, "Only knights of level 80 or above may drink this fluid.", TALKTYPE_ORANGE_1) expects a creature id as 1 param, and you are giving item?
I really dont know, i understood some code structures but dont know too much about tfs coded...

EDIT: no, i removed the
Code:
doCreatureSay(itemEx.uid, "Only knights of level 80 or above may drink this fluid.", TALKTYPE_ORANGE_1)

And the same error appear.
 
Code:
local mana = {500, 760}
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))

function onUse(cid, item, fromPosition, itemEx, toPosition)

    if(not isKnight(cid) or getPlayerLevel(cid) < 80) then
        doCreatureSay(cid, "Only knights of level 80 or above may drink this fluid.", TALKTYPE_ORANGE_1)
        return true
    end

    if(hasCondition(cid, CONDITION_EXHAUST)) then
        doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
        return true
    end

    if(not doPlayerAddMana(cid, math.ceil(math.random(mana[1], mana[2])))) then
        return false
    end
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE)
    doCreatureSay(cid, "SkySoft..", TALKTYPE_ORANGE_1)
    doAddCondition(cid, exhaust)
    doRemoveItem(item.uid, 1)
    return true
end

If you dont have function isKnight(cid) then use this script:
Code:
local mana = {500, 760}
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))

function onUse(cid, item, fromPosition, itemEx, toPosition)

local v = getPlayerVocation(cid)

    if(v ~= 4 or v ~= 8 or getPlayerLevel(cid) < 80) then
        doCreatureSay(cid, "Only knights of level 80 or above may drink this fluid.", TALKTYPE_ORANGE_1)
        return true
    end

    if(hasCondition(cid, CONDITION_EXHAUST)) then
        doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
        return true
    end

    if(not doPlayerAddMana(cid, math.ceil(math.random(mana[1], mana[2])))) then
        return false
    end
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE)
    doCreatureSay(cid, "SkySoft..", TALKTYPE_ORANGE_1)
    doAddCondition(cid, exhaust)
    doRemoveItem(item.uid, 1)
    return true
end

isKnight(cid)
Code:
function isKnight(cid)
    local player = Player(cid)
    if player == nil then
        return false
    end
    return isInArray({4, 8}, getPlayerVocation(cid))
end

This is end script with function isKnight(cid)
Code:
function isKnight(cid)
    local player = Player(cid)
    if player == nil then
        return false
    end
    return isInArray({4, 8}, getPlayerVocation(cid))
end

local mana = {500, 760}
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))

function onUse(cid, item, fromPosition, itemEx, toPosition)

    if(not isKnight(cid) or getPlayerLevel(cid) < 80) then
        doCreatureSay(cid, "Only knights of level 80 or above may drink this fluid.", TALKTYPE_ORANGE_1)
        return true
    end

    if(hasCondition(cid, CONDITION_EXHAUST)) then
        doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
        return true
    end

    if(not doPlayerAddMana(cid, math.ceil(math.random(mana[1], mana[2])))) then
        return false
    end
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE)
    doCreatureSay(cid, "SkySoft..", TALKTYPE_ORANGE_1)
    doAddCondition(cid, exhaust)
    doRemoveItem(item.uid, 1)
    return true
end
 
Last edited:
Code:
local mana = {500, 760}
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))

function onUse(cid, item, fromPosition, itemEx, toPosition)

    if(not isKnight(cid) or getPlayerLevel(cid) < 80) then
        doCreatureSay(cid, "Only knights of level 80 or above may drink this fluid.", TALKTYPE_ORANGE_1)
        return true
    end

    if(hasCondition(cid, CONDITION_EXHAUST)) then
        doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
        return true
    end

    if(not doPlayerAddMana(cid, math.ceil(math.random(mana[1], mana[2])))) then
        return false
    end
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE)
    doCreatureSay(cid, "SkySoft..", TALKTYPE_ORANGE_1)
    doAddCondition(cid, exhaust)
    doRemoveItem(item.uid, 1)
    return true
end

If you dont have function isKnight(cid) then use this script:
Code:
local mana = {500, 760}
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))

function onUse(cid, item, fromPosition, itemEx, toPosition)

local v = getPlayerVocation(cid)

    if(v ~= 4 or v ~= 8 or getPlayerLevel(cid) < 80) then
        doCreatureSay(cid, "Only knights of level 80 or above may drink this fluid.", TALKTYPE_ORANGE_1)
        return true
    end

    if(hasCondition(cid, CONDITION_EXHAUST)) then
        doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
        return true
    end

    if(not doPlayerAddMana(cid, math.ceil(math.random(mana[1], mana[2])))) then
        return false
    end
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE)
    doCreatureSay(cid, "SkySoft..", TALKTYPE_ORANGE_1)
    doAddCondition(cid, exhaust)
    doRemoveItem(item.uid, 1)
    return true
end

isKnight(cid)
Code:
function isKnight(cid)
    local player = Player(cid)
    if player == nil then
        return false
    end
    return isInArray({4, 8}, getPlayerVocation(cid))
end

The first code u posted worked! Thank you man!

I am only getting a error while trying to use the potion on my God.

In this part:

Code:
if(not isKnight(cid) or getPlayerLevel(cid) < 1) then

i tryed:

Code:
if(not isKnight(cid) or getPlayerLevel(cid) < 1) or getPlayerGroupId(cid) < 5 then

and also:

Code:
if(not isKnight(cid) or getPlayerLevel(cid) < 1 or getPlayerGroupId(cid) < 5) then

None worked, god cant use the potion (a not knight god)
 
You can change god vocation in database to 4.
or wait i can do something to work with gods too.

Try this :p
Code:
local mana = {500, 760}
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))

function onUse(cid, item, fromPosition, itemEx, toPosition)

    if getPlayerCustomFlagValue(cid, PlayerCustomFlag_GamemasterPrivileges) ~= 1 then
        if(not isKnight(cid) or getPlayerLevel(cid) < 80) then
            doCreatureSay(cid, "Only knights of level 80 or above may drink this fluid.", TALKTYPE_ORANGE_1)
            return true
        end
    end

    if(hasCondition(cid, CONDITION_EXHAUST)) then
        doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
        return true
    end

    if(not doPlayerAddMana(cid, math.ceil(math.random(mana[1], mana[2])))) then
        return false
    end
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE)
    doCreatureSay(cid, "SkySoft..", TALKTYPE_ORANGE_1)
    doAddCondition(cid, exhaust)
    doRemoveItem(item.uid, 1)
    return true
end
You understand the code? I blocked:
Code:
      if(not isKnight(cid) or getPlayerLevel(cid) < 80) then
            doCreatureSay(cid, "Only knights of level 80 or above may drink this fluid.", TALKTYPE_ORANGE_1)
            return true
        end
with:
Code:
if getPlayerCustomFlagValue(cid, PlayerCustomFlag_GamemasterPrivileges) ~= 1 then
end
This means if player don't have flag gamemaster it will pass to check isKnight(cid) or getPlayerLevel(cid) < 80 and if player has gamemaster flag it will not execute this check and go to next step of script.
 
Last edited:
You can change god vocation in database to 4.
or wait i can do something to work with gods too.
You can change god vocation in database to 4.
or wait i can do something to work with gods too.

Try this :p
Code:
local mana = {500, 760}
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))

function onUse(cid, item, fromPosition, itemEx, toPosition)

    if getPlayerCustomFlagValue(cid, PlayerCustomFlag_GamemasterPrivileges) ~= 1 then
        if(not isKnight(cid) or getPlayerLevel(cid) < 80) then
            doCreatureSay(cid, "Only knights of level 80 or above may drink this fluid.", TALKTYPE_ORANGE_1)
            return true
        end
    end

    if(hasCondition(cid, CONDITION_EXHAUST)) then
        doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
        return true
    end

    if(not doPlayerAddMana(cid, math.ceil(math.random(mana[1], mana[2])))) then
        return false
    end
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE)
    doCreatureSay(cid, "SkySoft..", TALKTYPE_ORANGE_1)
    doAddCondition(cid, exhaust)
    doRemoveItem(item.uid, 1)
    return true
end
You understand the code? I blocked:
Code:
      if(not isKnight(cid) or getPlayerLevel(cid) < 80) then
            doCreatureSay(cid, "Only knights of level 80 or above may drink this fluid.", TALKTYPE_ORANGE_1)
            return true
        end
with:
Code:
if getPlayerCustomFlagValue(cid, PlayerCustomFlag_GamemasterPrivileges) ~= 1 then
end
This means if player don't have flag gamemaster it will pass to check isKnight(cid) or getPlayerLevel(cid) < 80 and if player has gamemaster flag it will not execute this check and go to next step of script.

IDK why, u script seems perfect, but dont work, god still cant use potions.
 
It's because of this
PlayerCustomFlag_GamemasterPrivileges

lemme check what is going on with it.
Try this please:
Code:
local mana = {500, 760}
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))

function onUse(cid, item, fromPosition, itemEx, toPosition)

    if getPlayerCustomFlagValue(cid, PLAYERCUSTOMFLAG_GAMEMASTERPRIVILEGES) == false then
        if(not isKnight(cid) or getPlayerLevel(cid) < 80) then
            doCreatureSay(cid, "Only knights of level 80 or above may drink this fluid.", TALKTYPE_ORANGE_1)
            return true
        end
    end

    if(hasCondition(cid, CONDITION_EXHAUST)) then
        doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
        return true
    end

    if(not doPlayerAddMana(cid, math.ceil(math.random(mana[1], mana[2])))) then
        return false
    end
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE)
    doCreatureSay(cid, "SkySoft..", TALKTYPE_ORANGE_1)
    doAddCondition(cid, exhaust)
    doRemoveItem(item.uid, 1)
    return true
end
 
It's because of this
PlayerCustomFlag_GamemasterPrivileges

lemme check what is going on with it.
Try this please:
Code:
local mana = {500, 760}
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))

function onUse(cid, item, fromPosition, itemEx, toPosition)

    if getPlayerCustomFlagValue(cid, PLAYERCUSTOMFLAG_GAMEMASTERPRIVILEGES) == false then
        if(not isKnight(cid) or getPlayerLevel(cid) < 80) then
            doCreatureSay(cid, "Only knights of level 80 or above may drink this fluid.", TALKTYPE_ORANGE_1)
            return true
        end
    end

    if(hasCondition(cid, CONDITION_EXHAUST)) then
        doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
        return true
    end

    if(not doPlayerAddMana(cid, math.ceil(math.random(mana[1], mana[2])))) then
        return false
    end
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE)
    doCreatureSay(cid, "SkySoft..", TALKTYPE_ORANGE_1)
    doAddCondition(cid, exhaust)
    doRemoveItem(item.uid, 1)
    return true
end

YEYYYYYY i love yaaaaaaaaaaaa, all workk gooooood <33333333333333

PLAYERCUSTOMFLAG_GAMEMASTERPRIVILEGES -->>> what this means? group id > 4 ?
 
It's flag that your character has gamemaster privileges.
See this page, maybe you will understand what flags are.
http://ranisalt.github.io/flags-calculator/

You can edit your flags in data/XML/groups.xml
Code:
<group id="4" name="Gamemaster" flags="3808558964575" customFlags="257215" access="3" violationReasons="19" nameViolationFlags="10" statementViolationFlags="69" depotLimit="3000" maxVips="300" outfit="75"/>

I'm not really sure what exactly means PLAYERCUSTOMFLAG_GAMEMASTERPRIVILEGES but i think it't that your customflags gives you gamemaster functions
 
Last edited:

Similar threads

Back
Top