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

[Request] Special Food Spell

MarkSmartRemark

Lua-Noob in Training :D
Joined
Jan 27, 2010
Messages
139
Reaction score
3
Hi,

Im looking for a code that does the following:

  1. Player casts spell and adds 20 of an item into his backpack. (spell)
  2. Example If he has 89 of these in backpack the spell will only add 11 to his backpack.(part of spell)
  3. If he already has 100 in backpack, spell will not work.



EDIT: Spell is working perfectly.

Code:
--.::.CONFIG.::.--
local item = 2677      --- Item ID number
local cast_amount = 20 --- How many will spell create
local max_item = 100    --- Maximum allowed in BP
--.::.CONFIG.::.--



function onCastSpell(cid, var)
local difference = (max_item - cast_amount)
    if  getPlayerItemCount(cid, item) <= difference then
        doPlayerAddItem(cid, item, cast_amount, true)
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
    elseif getPlayerItemCount(cid, item) > difference and getPlayerItemCount(cid, item) < max_item then
            doPlayerAddItem(cid, item,(max_item - getPlayerItemCount(cid, item)))
            doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
        elseif getPlayerItemCount(cid, item) >= max_item then
            doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
            doPlayerSendCancel(cid, "You've reached your limit of "..max_item.." "..getItemNameById(item)..".")
  end
  return true
end

will be reposted on spells section with credits to those who helped and myself, Thanks alot!!
 
Last edited:
Code:
local fot = if getPlayerLevel(cid) <= 20 then
local fot = FOODS[1]
elseif getPlayerLevel(cid) > 20 then
local fot = FOODS[2]
end
don't declare local again
so just
Code:
local fot = if getPlayerLevel(cid) <= 20 then
  fot = FOODS[1]
else
  fot = FOODS[2]
end
 
ok so heres what the spell is at now, its getting very close.

i changed the script to

Code:
local FOODS = {2677, 6543} -- Here put the ID of the food item/s--


function onCastSpell(cid, var)
local get = getPlayerPosition(cid)
  if getPlayerItemCount(cid, FOODS[1]) <= 80 then
      if getPlayerLevel(cid) <= 20 then
        doPlayerAddItem(cid, FOODS[1], 20, true)
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
      elseif getPlayerLevel(cid) > 20 then
        doPlayerAddItem(cid, FOODS[2], 20, true)
   
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
    elseif getPlayerItemCount(cid, FOODS) > 80 and getPlayerLevel(cid) <= 20 then
            doPlayerAddItem(cid,FOODS[1],(100 - getPlayerItemCount(cid, FOODS[1])))
        end
    elseif getPlayerItemCount(cid, FOODS) > 80 and getPlayerLevel(cid) > 20 then
        doPlayerAddItem(cid,FOODS[2],(100 - getPlayerItemCount(cid, FOODS[2])))
     
    else
      doSendAnimatedText(getPlayerPosition(cid), "El Hechizo no funciona, al parecer ya tienes demaciados", 1)
  end
return true
end

i changed what i did in the previous post like uid->cid and added [1] foods to first getPlayerItemCount .. if i dont do these things the spell wont work.

Now if im level <= 20 then it works perfectly.. checks for everything and adds the right amounts.

if im level >20 it just keeps adding no matter how much i have in backpack
 
Code:
local FOODS = {2677, 6543} -- Here put the ID of the food item/s--
local get = getPlayerPosition(cid)
local fot = if getPlayerLevel(cid) <= 20 then
                fot = FOODS[1]
            elseif getPlayerLevel(cid) > 20 then
                fot = FOODS[2]
            end
function onCastSpell(cid, var)
  if getPlayerItemCount(cid, fot) <= 80 then
      if getPlayerLevel(cid) <= 20 then
        doPlayerAddItem(uid, FOODS[1], 20, true)
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
      elseif getPlayerLevel(cid) > 20 then
        doPlayerAddItem(uid, FOODS[2], 20, true)
      end
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
    elseif getPlayerItemCount(cid, fot) > 80 then
        doPlayerAddItem(uid,fox,(100 - getPlayerItemCount(cid, FOODS[1])))
    else
      doSendAnimatedText(getPlayerPosition(cid), "El Hechizo no funciona, al parecer ya tienes demasciados", 1)
  end
  return true
end


This should do.
;)

IF don't, try this one

Code:
local FOODS = {2677, 6543} -- Here put the ID of the food item/s--
local get = getPlayerPosition(cid)
local fot = if getPlayerLevel(cid) <= 20 then
                fot = FOODS[1]
            elseif getPlayerLevel(cid) > 20 then
                fot = FOODS[2]
            end
function onCastSpell(cid, var)
  if getPlayerItemCount(cid, fot) <= 80 then
      if getPlayerLevel(cid) <= 20 then
        doPlayerAddItem(uid, FOODS[1], 20, true)
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
      elseif getPlayerLevel(cid) > 20 then
        doPlayerAddItem(uid, FOODS[2], 20, true)
      end
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
    elseif getPlayerItemCount(cid, fot) > 80 and getPlayerLevel(cid) <= 20 then
        doPlayerAddItem(uid,FOODS[1],(100 - getPlayerItemCount(cid, FOODS[1])))
    elseif getPlayerItemCount(cid, fot) > 80 and getPlayerLevel(cid) > 20 then
        doPlayerAddItem(uid,FOODS[2],(100 - getPlayerItemCount(cid, FOODS[2])))
    else
      doSendAnimatedText(getPlayerPosition(cid), "El Hechizo no funciona, al parecer ya tienes demaciados", 1)
  end
  return true
end

Again, tell me which one works, which one don't and why ;)
 
Code:
local FOODS = {2677, 6543} -- Here put the ID of the food item/s--
local get = getPlayerPosition(cid)
local fot = if getPlayerLevel(cid) <= 20 then
                fot = FOODS[1]
            elseif getPlayerLevel(cid) > 20 then
                fot = FOODS[2]
            end
function onCastSpell(cid, var)
  if getPlayerItemCount(cid, fot) <= 80 then
      if getPlayerLevel(cid) <= 20 then
        doPlayerAddItem(uid, FOODS[1], 20, true)
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
      elseif getPlayerLevel(cid) > 20 then
        doPlayerAddItem(uid, FOODS[2], 20, true)
      end
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
    elseif getPlayerItemCount(cid, fot) > 80 then
        doPlayerAddItem(uid,fox,(100 - getPlayerItemCount(cid, FOODS[1])))
    else
      doSendAnimatedText(getPlayerPosition(cid), "El Hechizo no funciona, al parecer ya tienes demasciados", 1)
  end
  return true
end


This should do.
;)

gives me this error
Code:
[20/02/2014 11:17:37] [Error - LuaScriptInterface::loadFile] data/spells/scripts/Mage/New/Conjure Refreshment.lua:3: unexpected symbol near 'if'
[20/02/2014 11:17:37] [Warning - Event::loadScript] Cannot load script (data/spells/scripts/Mage/New/Conjure Refreshment.lua)
[20/02/2014 11:17:37] data/spells/scripts/Mage/New/Conjure Refreshment.lua:3: unexpected symbol near 'if'
[20/02/2014 11:17:38] Reloaded spells.

I also changed to tetras version
Code:
local fot = if getPlayerLevel(cid) <= 20 then
  fot = FOODS[1]
else
  fot = FOODS[2]
end
and it gave me the same one

EDIT: Also remember that the "uid" in the script has to be cid or it wont recognize the player.. idk why but yea
 
Code:
local fot = {if getPlayerLevel(cid) <= 20 then
                fot = FOODS[1]
            elseif getPlayerLevel(cid) > 20 then
                fot = FOODS[2]
            end}

Change that part to this

Tell me what apparead
 
@Obsdark same error on the same line by "if"

EDIT: I just tested the second part and it gives me the same errors as the first.. even when i change it up a little too. I think this script got me the closest

Code:
local FOODS = {2677, 6543} -- Here put the ID of the food item/s--


function onCastSpell(cid, var)
local get = getPlayerPosition(cid)
  if getPlayerItemCount(cid, FOODS[1]) <= 80 then
      if getPlayerLevel(cid) <= 20 then
        doPlayerAddItem(cid, FOODS[1], 20, true)
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
      elseif getPlayerLevel(cid) > 20 then
        doPlayerAddItem(cid, FOODS[2], 20, true)

        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
    elseif getPlayerItemCount(cid, FOODS) > 80 and getPlayerLevel(cid) <= 20 then
            doPlayerAddItem(cid,FOODS[1],(100 - getPlayerItemCount(cid, FOODS[1])))
        end
    elseif getPlayerItemCount(cid, FOODS) > 80 and getPlayerLevel(cid) > 20 then
        doPlayerAddItem(cid,FOODS[2],(100 - getPlayerItemCount(cid, FOODS[2])))
  
    else
      doSendAnimatedText(getPlayerPosition(cid), "El Hechizo no funciona, al parecer ya tienes demaciados", 1)
  end
return true
end

it does everything correctly for < 20
for over 20 > it keeps adding after 80 of food

@obsd
 
Last edited:
Code:
fot = if getPlayerLevel(cid) <= 20 then
        fot = FOODS[1]
      elseif getPlayerLevel(cid) > 20 then
        fot = FOODS[2]
      end

How about this.
?

So basicly the one than is a little smaller have the same problem than the other than is a little bigger?
Good to know, if that's the case you should use the smaller, Smaller = Better for this cases
 
Last edited:
Code:
fot = if getPlayerLevel(cid) <= 20 then
        fot = FOODS[1]
      elseif getPlayerLevel(cid) > 20 then
        fot = FOODS[2]
      end

How about this.
?

i tried with and without parenthesis and same error xDD i think for that to work like that it needs to be some type of function..
maybe like

Code:
local function fot(cid)
if  getPlayerLevel(cid) <= 20 then
fot = FOODS[1]
elseif getPlayerLevel(cid) > 20 then
fot = FOODS[2]
end
end

then again im not good at scripting .. but i tried making a function out of it and the spell script loads without error but then it just keeps adding food
 
i suspected,

Code:
local function fot(cid)
    if getPlayerLevel(cid) <= 20 then  
        fot = FOODS[1]
    elseif getPlayerLevel(cid) > 20 then
        fot = FOODS[2]
    end
end

Good one there, i think this should work
 
Code:
local FOODS = {2677, 6543} -- Here put the ID of the food item/s--
function havefood()
local fot
if getPlayerLevel(cid) <= 20 then
  fot = FOODS[1]
else
  fot = FOODS[2]
end
return fot
end

function onCastSpell(cid, var)
  if getPlayerItemCount(cid, havefood()) <= 80 then
  if getPlayerLevel(cid) <= 20 then
  doPlayerAddItem(cid, FOODS[1], 20, true)
  doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
  elseif getPlayerLevel(cid) > 20 then
  doPlayerAddItem(cid, FOODS[2], 20, true)
  end
  doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
  elseif getPlayerItemCount(cid, havefood()) > 80 then
  doPlayerAddItem(cid.FOODS[1],(100 - getPlayerItemCount(cid, FOODS[1])))
  else
  doSendAnimatedText(getPlayerPosition(cid), "El Hechizo no funciona, al parecer ya tienes demasciados", 1)
  end
  return true
end
 
Code:
local FOODS = {2677, 6543} -- Here put the ID of the food item/s--
function havefood()
local fot
if getPlayerLevel(cid) <= 20 then
  fot = FOODS[1]
else
  fot = FOODS[2]
end
return fot
end

function onCastSpell(cid, var)
  if getPlayerItemCount(cid, havefood()) <= 80 then
  if getPlayerLevel(cid) <= 20 then
  doPlayerAddItem(cid, FOODS[1], 20, true)
  doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
  elseif getPlayerLevel(cid) > 20 then
  doPlayerAddItem(cid, FOODS[2], 20, true)
  end
  doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
  elseif getPlayerItemCount(cid, havefood()) > 80 then
  doPlayerAddItem(cid.FOODS[1],(100 - getPlayerItemCount(cid, FOODS[1])))
  else
  doSendAnimatedText(getPlayerPosition(cid), "El Hechizo no funciona, al parecer ya tienes demasciados", 1)
  end
  return true
end

gave me this error

Code:
[20/02/2014 11:58:51] [Error - Spell Interface]
[20/02/2014 11:58:51] data/spells/scripts/Mage/New/Conjure Refreshment.lua:onCastSpell
[20/02/2014 11:58:51] Description:
[20/02/2014 11:58:51] data/spells/scripts/Mage/New/Conjure Refreshment.lua:4: attempt to compare boolean with number
[20/02/2014 11:58:51] stack traceback:
[20/02/2014 11:58:51]    data/spells/scripts/Mage/New/Conjure Refreshment.lua:4: in function 'havefood'
[20/02/2014 11:58:51]    data/spells/scripts/Mage/New/Conjure Refreshment.lua:13: in function <data/spells/scripts/Mage/New/Conjure Refreshment.lua:12>
 
i suspected,

Code:
local function fot(cid)
    if getPlayerLevel(cid) <= 20 then 
        fot = FOODS[1]
    elseif getPlayerLevel(cid) > 20 then
        fot = FOODS[2]
    end
end

Good one there, i think this should work

tried this too, it gives me no error but doesnt check for the 80.. just keeps casting
 
Code:
local FOODS = {XXXX, YYYY} -- Here put the ID of the food item/s--
local get = getPlayerPosition(cid)
local function fot(cid)
    if getPlayerLevel(cid) <= 20 then   
        fot = FOODS[1]
    elseif getPlayerLevel(cid) > 20 then
        fot = FOODS[2]
    end
    return fot
end
function onCastSpell(cid, var)
  if getPlayerItemCount(cid, fot) <= 80 then
      if getPlayerLevel(cid) <= 20 then
        doPlayerAddItem(uid, FOODS[1], 20, true)
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
      elseif getPlayerLevel(cid) > 20 then
        doPlayerAddItem(uid, FOODS[2], 20, true)
      end
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
    elseif getPlayerItemCount(cid, fot) > 80 then
        doPlayerAddItem(uid,fot,(100 - getPlayerItemCount(cid, FOODS[1])))
    else
      doSendAnimatedText(getPlayerPosition(cid), "El Hechizo no funciona, al parecer ya tienes demasciados", 1)
  end
  return true
end

and this one? it works?

if not, try this one

Code:
local FOODS = {XXXX, YYYY} -- Here put the ID of the food item/s--
local get = getPlayerPosition(cid)
local function fot(cid)
    if getPlayerLevel(cid) <= 20 then    
        fot = FOODS[1]
    elseif getPlayerLevel(cid) > 20 then
        fot = FOODS[2]
    end
    return fot
end
function onCastSpell(cid, var)
  if getPlayerItemCount(cid, fot) <= 80 then
      if getPlayerLevel(cid) <= 20 then
        doPlayerAddItem(uid, FOODS[1], 20, true)
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
      elseif getPlayerLevel(cid) > 20 then
        doPlayerAddItem(uid, FOODS[2], 20, true)
      end
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
    elseif getPlayerItemCount(cid, fot) > 80 and getPlayerLevel(cid) <= 20 then
        doPlayerAddItem(uid,FOODS[1],(100 - getPlayerItemCount(cid, FOODS[1])))
    elseif getPlayerItemCount(cid, fot) > 80 and getPlayerLevel(cid) > 20 then
        doPlayerAddItem(uid,FOODS[2],(100 - getPlayerItemCount(cid, FOODS[2])))
    else
        doSendAnimatedText(getPlayerPosition(cid), "El Hechizo no funciona, al parecer ya tienes demaciados", 1)
  end
  return true
end
 
u know what we need? to make a little debuggin

i need you to write this one like a new spell, and tell me what's print, just like it is.
Code:
local function fot(cid)
    if getPlayerLevel(cid) <= 20 then
        fot = FOODS[1]
    elseif getPlayerLevel(cid) > 20 then
        fot = FOODS[2]
    end
    return fot
end
if getPlayerPosition(cid) == getPlayerPosition(cid) then
   debugPrint(fot)
end

Needless to say than you must test it in 2 different characters ;), one with lvl 20 or less and one with a level over 20

PS: use the ones i just post before too, maybie they'll work, i think i found the error about it and fix them but if not, i'm gonna need you do the other spell to get the info needed to fix the one u want.
 
Last edited:
@Obsdark

Hey! i found a cheap way around all of this! I will make one spell, that creates item

Code:
--.::.CONFIG.::.--
local item = 2677      --- Item ID number
local cast_amount = 20 --- How many will spell create
local max_item = 100    --- Maximum allowed in BP
--.::.CONFIG.::.--



function onCastSpell(cid, var) 
 local difference = (max_item - cast_amount) 
    if  getPlayerItemCount(cid, item) <= difference then
        doPlayerAddItem(cid, item, cast_amount, true)
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN) 
    elseif getPlayerItemCount(cid, item) > difference and getPlayerItemCount(cid, item) < max_item then
            doPlayerAddItem(cid, item,(max_item - getPlayerItemCount(cid, item)))
            doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN) 
        elseif getPlayerItemCount(cid, item) >= max_item then
            doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
            doPlayerSendCancel(cid, "You've reached your limit of "..max_item.." "..getItemNameById(item)..".")
  end
  return true
end

then ill make a food script and make it so the food gives you different effects depending on level.. which would be much easier in 2 scripts, instead of having 1 script do it all :p ! whatever the item is it will work for everyone just have a diff effect..

im sorry if you feel like ive wasted your time :( not to lie, i learned some things in all that testing haha but yea i think its more practical to have 2 diff scripts for this one.. I'll repost once i have everything done with credits to you and tetra..

EDIT: Updated version to one with easier config..
 
Last edited:
For be honest with you, that was the next step, but first i wanna see it functioning without vars ;)

After all, if i sum vars, then the thing is easier to install but can't be so much for debug..

Besides that one doesn't cast you another type of food in the same code, you'll need to make two spells for that, but, if works for you..



Good one that though, i was going to make it a Resource, Still can if you tell me what was the code return of the others.
 
the first 2 codes gave me no error but kept adding 20 each time >.<

and the second part gave me all this

Code:
[20/02/2014 23:42:52] [Error - Spell Interface]
[20/02/2014 23:42:52] data/spells/scripts/Mage/New/Conjure Refreshment Table.lua
[20/02/2014 23:42:52] Description:
[20/02/2014 23:42:52] (luaGetThingPosition) Thing not found

[20/02/2014 23:42:52] [Error - Spell Interface]
[20/02/2014 23:42:52] data/spells/scripts/Mage/New/Conjure Refreshment Table.lua
[20/02/2014 23:42:52] Description:
[20/02/2014 23:42:52] (luaGetThingPosition) Thing not found

[20/02/2014 23:42:52] [Error - Spell Interface]
[20/02/2014 23:42:52] data/spells/scripts/Mage/New/Conjure Refreshment Table.lua
[20/02/2014 23:42:52] Description:
[20/02/2014 23:42:52] ...pells/scripts/Mage/New/Conjure Refreshment Table.lua:10: attempt to call global 'debugPrint' (a nil value)
[20/02/2014 23:42:52] [Warning - Event::loadScript] Cannot load script (data/spells/scripts/Mage/New/Conjure Refreshment Table.lua)

[20/02/2014 23:42:53] Reloaded spells.
 
the first 2 codes gave me no error but kept adding 20 each time >.<

and the second part gave me all this

Code:
[20/02/2014 23:42:52] [Error - Spell Interface]
[20/02/2014 23:42:52] data/spells/scripts/Mage/New/Conjure Refreshment Table.lua
[20/02/2014 23:42:52] Description:
[20/02/2014 23:42:52] (luaGetThingPosition) Thing not found

[20/02/2014 23:42:52] [Error - Spell Interface]
[20/02/2014 23:42:52] data/spells/scripts/Mage/New/Conjure Refreshment Table.lua
[20/02/2014 23:42:52] Description:
[20/02/2014 23:42:52] (luaGetThingPosition) Thing not found

[20/02/2014 23:42:52] [Error - Spell Interface]
[20/02/2014 23:42:52] data/spells/scripts/Mage/New/Conjure Refreshment Table.lua
[20/02/2014 23:42:52] Description:
[20/02/2014 23:42:52] ...pells/scripts/Mage/New/Conjure Refreshment Table.lua:10: attempt to call global 'debugPrint' (a nil value)
[20/02/2014 23:42:52] [Warning - Event::loadScript] Cannot load script (data/spells/scripts/Mage/New/Conjure Refreshment Table.lua)

[20/02/2014 23:42:53] Reloaded spells.
It isn't debugPrint() it is print("any shit")
And post the script for me to fix the getThingPosition
 
It isn't debugPrint() it is print("any shit")
And post the script for me to fix the getThingPosition

ohh dont worry, that was just to test some things for obsdark, i already made the working script, im adding a few features to it and im gonna repost in spells for people to use..ill give credits to you guys.. spell is looking nice
 
Yes indeed ;)

Thanks a lot, now i check the code, i guess this would do every single thing you want.


Code:
local FOODS = {XXXX, YYYY} -- Here put the ID of the food item/s--
local Total_Max = 100 -- Here adjust the total --
local text = "You've reached your limit of "..max_item.." "..getItemNameById(item).."." -- Here adjust the message --
local function fot(cid)
    if getPlayerLevel(cid) <= 20 then  
        fot = FOODS[1]
    elseif getPlayerLevel(cid) > 20 then
        fot = FOODS[2]
    end
    return fot
end
function onCastSpell(cid, var)
  if getPlayerItemCount(cid, fot) ~= Total_Max then
      if getPlayerLevel(cid) <= 20 then
        doPlayerAddItem(uid,fot,(Total_Max - getPlayerItemCount(cid, fot)))
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
      elseif getPlayerLevel(cid) > 20 then
        doPlayerAddItem(uid,fot,(Total_Max - getPlayerItemCount(cid, fot)))
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
      end
    else
      doSendAnimatedText(getPlayerPosition(cid), "..text..", 1)
      doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
  end
  return true
end

if not, try this one


Code:
local FOODS = {XXXX, YYYY} -- Here put the ID of the food item/s--
local Total_Max = 100 -- Here adjust the total --
local text = "You've reached your limit of "..max_item.." "..getItemNameById(item).."." -- Here adjust the message --
local function fot(cid)
    if getPlayerLevel(cid) <= 20 then  
        fot = FOODS[1]
    elseif getPlayerLevel(cid) > 20 then
        fot = FOODS[2]
    end
    return fot
end
function onCastSpell(cid, var)
  if getPlayerItemCount(cid, fot) ~= Total_Max then
      if getPlayerLevel(cid) <= 20 then
        doPlayerAddItem(uid,fot,(Total_Max - getPlayerItemCount(cid, FOODS[1])))
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
      elseif getPlayerLevel(cid) > 20 then
        doPlayerAddItem(uid,fot,(Total_Max - getPlayerItemCount(cid, FOODS[2])))
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_GREEN)
      end
    else
      doSendAnimatedText(getPlayerPosition(cid), "..text..", 1)
      doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
  end
  return true
end

Pretty much sure than some of this two must work perfectly
Gave me the feedback,

after this,
Probably i'll post it on resources. ;)

Thanks a lot!
 
Last edited:
Back
Top