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

Two small errors, One in spells one in advanced fishing

  • Thread starter Deleted member 49793
  • Start date
D

Deleted member 49793

Guest
Spell error:
#
Code:
[Error - Spell Interface]
#
data/spells/scripts/support/soul tap.lua:onCastSpell
#
Description:
#
data/spells/scripts/support/soul tap.lua:16: attempt to concatenate global 'mp' (a nil value)
#
stack traceback:
#
        data/spells/scripts/support/soul tap.lua:16: in function <data/spells/scripts/support/soul tap.lua:5>

Code:
--[scritpt]--
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, 49)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)
function onCastSpell(cid, var)
	if getPlayerSoul(cid) < 5 then
	   doPlayerSendCancel(cid,"You dont have enough souls to be sacrified.")
	   doSendMagicEffect(getThingPos(cid),2)
	   return false
	end
	health = math.floor((getCreatureMaxHealth(cid))*0.15)
	mana = math.floor((getCreatureMaxMana(cid))*0.05)
	doPlayerAddSoul(cid, (getPlayerSoul(cid) -2) - getPlayerSoul(cid) )
	doCreatureAddHealth(cid,health)
    doCreatureAddMana(cid,mana)
	doPlayerSendCancel(cid,"Restored : "..hp.." hp | "..mp.." mp")
	return doCombat(cid, combat, var)
end

Code:
#
#
[Error - Action Interface]
#
data/actions/scripts/fishing.lua:onUse
#
Description:
#
data/actions/scripts/fishing.lua:35: attempt to index local 'now' (a nil value)
#
stack traceback:
#
        data/actions/scripts/fishing.lua:35: in function <data/actions/scripts/fishing.lua:21>

Heres my fishing script

Code:
local config = {
	[1] = {item = {2670, 1}, chance = 400000, fishing = 0, quest = {enable = false, storage = nil}},		-- Shrimp 50%

	[2] = {item = {2667, 1}, chance = 200000, fishing = 10, quest = {enable = true, storage = nill}},		-- Fish 50%

	[3] = {item = {2668, 1}, chance = 100000, fishing = 60, quest = {enable = false, storage = nil}},	-- Salmon 10%


	[4] = {item = {7159, 1}, chance = 100000, fishing = 30, quest = {enable = false, storage = nil}},	-- # FISH GREEN PERCHES 10%


	[5] = {item = {7158, 1}, chance = 100000, fishing = 30, quest = {enable = false, storage = nil}},	-- Northern Pikes 10%


	[6] = {item = {2669, 1}, chance = 100000, fishing = 30, quest = {enable = false, storage = nil}},	-- # FISH RAINBOW RTOUTS 10%


	[44] = {item = {ITEM_WORM, 1}, chance = 92392, fishing = 0, quest = {enable = false, storage = nil}} 
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
local playerFishing = getPlayerSkill(cid, SKILL_FISHING)

local now = nil
for i = 1, #config do
	if (config[i].chance > math.random(1, 1000000)) then
		now = config[i]
		break
	end
end

if(itemEx.itemid >= 4608 and itemEx.itemid <= 4625 or itemEx.itemid == 493) then
	if(math.random(1, (100 + (playerFishing / 10))) <= playerFishing) then
		if getPlayerItemCount(cid, ITEM_WORM) > 0 then
			if(playerFishing >= now.fishing) then
				if(now.quest.enable) then
					if(getPlayerStorageValue(cid, now.quest.storage) < 0) then
						doPlayerAddItem(cid, now.item[1], now.item[2])
						doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You caught a "..getItemNameById(now.item[1]).."!")
					else
						doPlayerAddItem(cid, ITEM_FISH, 1)
						doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You caught a fish!")
					end
				else
					doPlayerAddItem(cid, now.item[1], now.item[2])
					doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You caught "..getItemNameById(now.item[1]).."!")
				end
			else
				doPlayerAddItem(cid, ITEM_FISH, 1)
				doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You caught a fish!")
			end
		end
			doPlayerAddSkillTry(cid, SKILL_FISHING, 1)
	end
		doSendMagicEffect(toPosition, CONST_ME_LOSEENERGY)
		doPlayerRemoveItem(cid, ITEM_WORM, 1)
		return TRUE
end 
	return FALSE
end
 
replace mp with mana....
doPlayerSendCancel(cid,"Restored : "..hp.." hp | "..mana.." mp")
i dont see where u have declared mp before...

2th:
if(playerFishing >= now.fishing) then

now is an array "now", so u must tell him the index!
"use isinarray function".... or write a loop...
he dosnt know wich fishing value u are trying to compare... with palyerfishing...
 
Last edited:
Code:
lua:16: attempt to concatenate global 'mp' (a nil value)

mp + hp aren't defined as locals.

local mp = ?
 
i know, but in this script is mp as global value dosnt needed... ( should be made in this function easly... mp=maxhp-currenthp ... getPlayermaxhealth... -getplayerhealth... to find out how much has been healed)... whats the deal...?
and where mp is declared, i cant see from giraffes post...
 
Back
Top