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

Scripts not working for lua need fix

Saints Anathema

Old School Doleran
Joined
Feb 24, 2009
Messages
653
Reaction score
8
Location
BC,Canada
Code:
function onUse(cid, item, frompos, item2, topos)
local config = {
SkillStorage = 1001,
MineStorage = 1000,
Level = 50,
ActionID = 2000,
GetSkill = getPlayerStorageValue(cid, config.SkillStorage),
AdvanceSkillChance = math.random(1, 2),
MoneyChance = math.random(1, 50),
PlatinumCount = math.random(1, 50), -- 1 To 50 Platinum can be awarded.
CrystalCount = math.random(1, 5), -- 1 To 5 Crystal can be awarded.
MonsterChance = math.random(1, 15),
StrongBreakChance = math.random(1, 25),
NormalBreakChance = math.random(1, 10),
monsters = {"Dwarf", "Hydra", "Demon"}
}
   if getPlayerLevel(cid) >= config.Level and item.actionid == config.ActionID then
     if config.AdvanceSkillChance == 1 then 
         setPlayerStorageValue(cid, config.SkillStorage, config.GetSkill + 1)
           doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BIGCLOUDS)
            doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You now have ".. getPlayerStorageValue(cid, config.SkillStorage)" mining Skill.")
        elseif config.MoneyChance == 15 or config.MoneyChance == 30 then
          doPlayerAddItem(cid, 2152, config.PlatinumCount)
              doSendMagicEffect(getCreaturePosition(cid), CONST_ME_CAKE)
            elseif config.MoneyChance == 5 or config.MoneyChance == 18 then
               doPlayerAddItem(cid, 2160, config.CrystalCount)
                  doSendMagicEffect(getCreaturePosition(cid), CONST_ME_YALAHARIGHOST)
                elseif config.MonsterChance == 3 or config.MonsterChance == 15 then
                   doSummonCreature(config.monsters[math.random(1, #config.monsters)], getCreaturePosition(cid))
                     doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BIGCLOUDS)
                    elseif config.StrongBreakChance == 5 or config.StrongBreakChance == 15 and getPlayerStorageValue(cid, config.SkillStorage) >= 50 then
                       doDecayItem(itemEx.uid)
                         doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
                       elseif config.NormalBreakChance <= 2 or config.NormalBreakChance >= 7 and getPlayerStorageValue(cid, config.SkillStorage) <= 50 then
                         doDecayItem(itemEx.uid)
                           doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
                  else 
                     doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You do not have high enouph Level.")  
                    end
                end 
                  return TRUE       
                end

Code:
Lua Script Error: [Action Interface]
data/actions/scripts/tools/mining.lua:onUse

data/actions/scripts/tools/mining.lua:7: attempt to index global 'config' (a nil
 value)
stack traceback:
        data/actions/scripts/tools/mining.lua:7: in function <data/actions/scrip
ts/tools/mining.lua:1>

REP+ to any help or posts
Original Credits go to Sync

my server is tfs 0.2.4
 
Lua:
function onUse(cid, item, frompos, item2, topos)
local config = {
SkillStorage = 1001,
MineStorage = 1000,
Level = 50,
ActionID = 2000,
GetSkill = getPlayerStorageValue(cid, SkillStorage),
AdvanceSkillChance = math.random(1, 2),
MoneyChance = math.random(1, 50),
PlatinumCount = math.random(1, 50), -- 1 To 50 Platinum can be awarded.
CrystalCount = math.random(1, 5), -- 1 To 5 Crystal can be awarded.
MonsterChance = math.random(1, 15),
StrongBreakChance = math.random(1, 25),
NormalBreakChance = math.random(1, 10),
monsters = {"Dwarf", "Hydra", "Demon"}
}
   if getPlayerLevel(cid) >= config.Level and item.actionid == config.ActionID then
     if config.AdvanceSkillChance == 1 then 
         setPlayerStorageValue(cid, config.SkillStorage, config.GetSkill + 1)
           doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BIGCLOUDS)
            doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You now have ".. getPlayerStorageValue(cid, config.SkillStorage)" mining Skill.")
        elseif config.MoneyChance == 15 or config.MoneyChance == 30 then
          doPlayerAddItem(cid, 2152, config.PlatinumCount)
              doSendMagicEffect(getCreaturePosition(cid), CONST_ME_CAKE)
            elseif config.MoneyChance == 5 or config.MoneyChance == 18 then
               doPlayerAddItem(cid, 2160, config.CrystalCount)
                  doSendMagicEffect(getCreaturePosition(cid), CONST_ME_YALAHARIGHOST)
                elseif config.MonsterChance == 3 or config.MonsterChance == 15 then
                   doSummonCreature(config.monsters[math.random(1, #config.monsters)], getCreaturePosition(cid))
                     doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BIGCLOUDS)
                    elseif config.StrongBreakChance == 5 or config.StrongBreakChance == 15 and getPlayerStorageValue(cid, config.SkillStorage) >= 50 then
                       doDecayItem(itemEx.uid)
                         doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
                       elseif config.NormalBreakChance <= 2 or config.NormalBreakChance >= 7 and getPlayerStorageValue(cid, config.SkillStorage) <= 50 then
                         doDecayItem(itemEx.uid)
                           doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
                  else 
                     doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You do not have high enouph Level.")  
                    end
                end 
                  return TRUE       
                end
 
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local config = {
		SkillStorage = 1001,
		MineStorage = 1000,
		Level = 50,
		AdvanceSkillChance = math.random(2),
		MoneyChance = math.random(50),
		PlatinumCount = math.random(50), -- 1 To 50 Platinum can be awarded.
		CrystalCount = math.random(5), -- 1 To 5 Crystal can be awarded.
		MonsterChance = math.random(15),
		StrongBreakChance = math.random(25),
		NormalBreakChance = math.random(10),
		monsters = {"Dwarf", "Hydra", "Demon"}
	}
	if getPlayerLevel(cid) >= config.Level then
		if config.AdvanceSkillChance == 1 then
			setPlayerStorageValue(cid, config.SkillStorage, math.max(0, getPlayerStorageValue(cid, config.SkillStorage)) + 1)
			doSendMagicEffect(getThingPos(cid), CONST_ME_BIGCLOUDS)
			doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You now have ".. getPlayerStorageValue(cid, config.SkillStorage)" mining Skill.")
		elseif config.MoneyChance == 15 or config.MoneyChance == 30 then
			doPlayerAddItem(cid, 2152, config.PlatinumCount)
			doSendMagicEffect(getThingPos(cid), CONST_ME_CAKE)
		elseif config.MoneyChance == 5 or config.MoneyChance == 18 then
			doPlayerAddItem(cid, 2160, config.CrystalCount)
			doSendMagicEffect(getThingPos(cid), CONST_ME_YALAHARIGHOST)
		elseif config.MonsterChance == 3 or config.MonsterChance == 15 then
			doSummonCreature(config.monsters[math.random(#config.monsters)], getThingPos(cid))
			doSendMagicEffect(getThingPos(cid), CONST_ME_BIGCLOUDS)
		elseif config.StrongBreakChance == 5 or config.StrongBreakChance == 15 and getPlayerStorageValue(cid, config.SkillStorage) >= 50 then
			doDecayItem(itemEx.uid)
			doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
		elseif config.NormalBreakChance <= 2 or config.NormalBreakChance >= 7 and getPlayerStorageValue(cid, config.SkillStorage) <= 50 then
			doDecayItem(itemEx.uid)
			doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
		end
	else
		doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You do not have high enouph Level.")
	end
	return TRUE
end
 
@ Cykotitans script, it works but for some reason the pickaxe wont ever break, and my previous script was only supposed to be able to make them mine on action id 2000 which were special stones on my server, if possible id prefer to keep that but if not doesnt matter.
 
your script was uh.. checking the actionid of the pick.
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if itemEx.actionid ~= 2000 then
		doPlayerSendCancel(cid, 'You can\'t mine this.')
	elseif getPlayerLevel(cid) >= 50 then
		doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT)
		local money = math.random(50)
		if math.random(2) == 1 then -- 50%
			local s = math.max(0, getPlayerStorageValue(cid, 1001)) + 1
			setPlayerStorageValue(cid, 1001, s)
			doSendMagicEffect(getThingPos(cid), CONST_ME_BIGCLOUDS)
			doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, 'Your mining skill is now '.. s ..'.')
		elseif money == 15 or money == 30 then -- 4%
			doPlayerAddItem(cid, 2152, math.random(50))
			doSendMagicEffect(getThingPos(cid), CONST_ME_CAKE)
		elseif money == 5 or money == 18 then -- 4%
			doPlayerAddItem(cid, 2160, math.random(5))
			doSendMagicEffect(getThingPos(cid), CONST_ME_YALAHARIGHOST)
		elseif math.random(8) == 1 then -- 12.5%
			local monsters = {'Dwarf', 'Hydra', 'Demon'}
			doSummonCreature(monsters[math.random(#monsters)], getThingPos(cid))
			doSendMagicEffect(getThingPos(cid), CONST_ME_BIGCLOUDS)
		elseif math.random(getPlayerStorageValue(cid, 1001) < 50 and 2 or 12) == 1 then -- 50% or 8.33%
			doRemoveItem(item.uid)
			doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
		end
	else
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You don\'t have high enough level.')
	end
	return TRUE
end
 
Last edited:
Ok now everything works properly, they can only mine on certain action id's and even though the mining skill goes up a bit fast that works to atleast, the only issue im having with the script it the fact it still doesnt break the pick axe, so theoretically its a unlimited way to make money.

how to make it break?

Thanks in advance for any help, and thanks very much to cykotitans help!


EDIT ~~~

Script works completely 100%, ive been trying to fool around with the numbers and chances a bit more, i kinda want them to like get a stack of 10-30 CC's everytime they mine, and then like 3-5 gold ingots, every like 1/10 chance and then a monster 1/5 chances

i merely just changed around the platinum coins for CC's, and the CC's for 9971 on my server, still trying to get the chances right
 
Last edited:
Back
Top