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

TFS 1.0 attempt to call method 'say' <a nilv value>

Devlinn

Member
Joined
Mar 25, 2015
Messages
295
Reaction score
6
hello i try add effect to this manarune
PHP:
function getPlayerManaMax(cid)manaNow = getPlayerMana(cid)doPlayerAddMana(cid,1000000)manaMax = getPlayerMana(cid)doPlayerAddMana(cid,manaNow-manaMax)
return manaMax
endfunction onUse(cid, item, frompos, item2, topos)local config = {ended = true,effect_enable = true,effect = 13,text_enable = true,text_colour = 191,exh =
 {exh_enable = true,exh_time = 1.4,storage = 12345, -- liczba przechowujaca exhausted}
}local voctab =
{
{minn=5, maxx=750, lvmul=2, mlmul=35},
{minn=150, maxx=550, lvmul=12, mlmul=1},
{minn=50, maxx=550, lvmul=5, mlmul=45},
{minn=150, maxx=1550, lvmul=3, mlmul=15}
}topos.stackpos = 253
player = getThingfromPos(topos)playerpos = getPlayerPosition(player.uid)cidpos = getPlayerPosition(cid)used = false
canUse = true
maglv = getPlayerMagLevel(cid)voc = getPlayerVocation(cid)lv=getPlayerLevel(cid)vocc=voctab[voc]addminn=vocc.minn +(vocc.lvmul*lv)+(vocc.mlmul*maglv)addmaxx=vocc.maxx +(vocc.lvmul*lv)+(vocc.mlmul*maglv)add=math.random(addminn,addmaxx)
if player.uid > 0 thenif getPlayerMana(player.uid) == getPlayerManaMax(player.uid) then
doPlayerSendCancel(cid, "Mana "..getPlayerName(player.uid).." is full!")
return 1
endelse
if getPlayerMana(cid) == getPlayerManaMax(cid) then
doPlayerSendCancel(cid, "Your mana is full.")
return 1
end
endif(os.time() < getPlayerStorageValue(cid, config.exh.storage)) then
 doPlayerSendCancel(cid,"You are exhausted.")canUse = false
endif (canUse) thenif player.itemid > 0 thenif (config.effect_enable) then
 doSendMagicEffect(playerpos, config.effect)endif (config.text_enable) then
 player:say("add", TALKTYPE_MONSTER_SAY)end
 doPlayerAddMana(player.uid,add)used = trueelse
 if config.effect_enable then
 doSendMagicEffect(cidpos, config.effect)endif (config.text_enable) then
 player:say("add", TALKTYPE_MONSTER_SAY)end
 doPlayerAddMana(cid,add)used = true
 end
endif (used) and (canUse) thenif (config.exh.exh_enable) then
 setPlayerStorageValue(cid, config.exh.storage, os.time() + config.exh.exh_time)endif (config.ended) thenif item.type > 1 then
 doChangeTypeItem(item.uid,item.type-1)
 elsedoRemoveItem(item.uid,1)end
 end
endreturn 1
end
but i got error
Screen_Shot_10_11_15_at_10_59_AM.png
 
Could you format the code so its readable?
It looks very messy, if you want help from others at least care some what of presentation.
 
add the below code to inside onUse
Code:
local player = Player(cid)
doesnt work
function getPlayerManaMax(cid)
manaNow = getPlayerMana(cid)
doPlayerAddMana(cid,1000000)
manaMax = getPlayerMana(cid)
doPlayerAddMana(cid,manaNow-manaMax)
return manaMax
end
function onUse(cid, item, frompos, item2, topos)
local player = Player(cid)
local config = {
ended = true,
effect_enable = true,
effect = 13,
text_enable = true,
text_colour = 191,
exh =
{
exh_enable = true,
exh_time = 1.4,
storage = 12345, -- liczba przechowujaca exhausted
}
}
local voctab =
{
{minn=5, maxx=750, lvmul=2, mlmul=35},
{minn=150, maxx=550, lvmul=12, mlmul=1},
{minn=50, maxx=550, lvmul=5, mlmul=45},
{minn=150, maxx=1550, lvmul=3, mlmul=15}
}
topos.stackpos = 253
player = getThingfromPos(topos)
playerpos = getPlayerPosition(player.uid)
cidpos = getPlayerPosition(cid)
used = false
canUse = true
maglv = getPlayerMagLevel(cid)
voc = getPlayerVocation(cid)
lv=getPlayerLevel(cid)
vocc=voctab[voc]
addminn=vocc.minn +(vocc.lvmul*lv)+(vocc.mlmul*maglv)
addmaxx=vocc.maxx +(vocc.lvmul*lv)+(vocc.mlmul*maglv)
add=math.random(addminn,addmaxx)
if player.uid > 0 then
if getPlayerMana(player.uid) == getPlayerManaMax(player.uid) then
doPlayerSendCancel(cid, "Mana "..getPlayerName(player.uid).." is full!")
return 1
end
else
if getPlayerMana(cid) == getPlayerManaMax(cid) then
doPlayerSendCancel(cid, "Your mana is full.")
return 1
end
end
if(os.time() < getPlayerStorageValue(cid, config.exh.storage)) then
doPlayerSendCancel(cid,"You are exhausted.")
canUse = false
end
if (canUse) then
if player.itemid > 0 then
if (config.effect_enable) then
doSendMagicEffect(playerpos, config.effect)
end
if (config.text_enable) then
player:say("add", TALKTYPE_MONSTER_SAY)
end
doPlayerAddMana(player.uid,add)
used = true
else
if config.effect_enable then
doSendMagicEffect(cidpos, config.effect)
end
if (config.text_enable) then
player:say("add", TALKTYPE_MONSTER_SAY)
end
doPlayerAddMana(cid,add)
used = true
end
end
if (used) and (canUse) then
if (config.exh.exh_enable) then
setPlayerStorageValue(cid, config.exh.storage, os.time() + config.exh.exh_time)
end
if (config.ended) then
if item.type > 1 then
doChangeTypeItem(item.uid,item.type-1)
else
doRemoveItem(item.uid,1)
end
end
end
return 1
end
 
Code:
    local exhaust = true   
    local time_ = 5
    function onUse(cid, item, frompos, item2, topos)
        local player = Player(cid)
       
        if getPlayerMana(cid) == getPlayerManaMax(cid) then
            doPlayerSendCancel(cid, "Your Mana is full!")
            return false
        end
       
        if( exhaust ) then
            player:say("ahhh!", TALKTYPE_MONSTER_SAY)
            doPlayerAddMana(cid, getPlayerMaxMana(cid))
            exhaust = false
            if item.type > 1 then
                doChangeTypeItem(item.uid, item.type - 1)
            else
                doRemoveItem(item.uid, 1)
            end
            addEvent(function() exhaust = true end, time_ * 1000)
        else
            doPlayerSendCancel(cid, "You are exhausted.")
            return false
        end
        return true
    end
 
Code:
    local exhaust = true  
    local time_ = 5
    function onUse(cid, item, frompos, item2, topos)
        local player = Player(cid)
      
        if getPlayerMana(cid) == getPlayerManaMax(cid) then
            doPlayerSendCancel(cid, "Your Mana is full!")
            return false
        end
      
        if( exhaust ) then
            player:say("ahhh!", TALKTYPE_MONSTER_SAY)
            doPlayerAddMana(cid, getPlayerMaxMana(cid))
            exhaust = false
            if item.type > 1 then
                doChangeTypeItem(item.uid, item.type - 1)
            else
                doRemoveItem(item.uid, 1)
            end
            addEvent(function() exhaust = true end, time_ * 1000)
        else
            doPlayerSendCancel(cid, "You are exhausted.")
            return false
        end
        return true
    end
hmm work but i see ahh i want see how many mana i got from rune
 
hmm work but i see ahh i want see how many mana i got from rune
You can achieve this by doing a simple calculation such as getPlayerMaxMana(cid) - getPlayerMana(cid) = how much mana the rune will add.
Code:
local mana = getPlayerMaxMana(cid) - getPlayerMana(cid)

Instead of the "ahhh!" message
Code:
player:say("ahhh!", TALKTYPE_MONSTER_SAY)

You can insert local mana into the player:say like this:
Code:
player:say(mana, TALKTYPE_MONSTER_SAY)
 
You can achieve this by doing a simple calculation such as getPlayerMaxMana(cid) - getPlayerMana(cid) = how much mana the rune will add.
Code:
local mana = getPlayerMaxMana(cid) - getPlayerMana(cid)

Instead of the "ahhh!" message
Code:
player:say("ahhh!", TALKTYPE_MONSTER_SAY)

You can insert local mana into the player:say like this:
Code:
player:say(mana, TALKTYPE_MONSTER_SAY)

edit it works thanks how to block when i have full mana cant see message 0
and add level * magic level experience i get more mana
now one use = full mana


like this
{minn=5, maxx=750, lvmul=2, mlmul=35},
{minn=150, maxx=550, lvmul=12, mlmul=1},
{minn=50, maxx=550, lvmul=5, mlmul=45},
{minn=150, maxx=1550, lvmul=3, mlmul=15}
vocation: paladin,sorcerer,knight
or something
 
Last edited:
Back
Top