someone can help me ...
i'm just getting started with this language .
and don't know much .
i need help to fix this script and optimize it, thx for now.
----------------------------------------------------------------
local configg = {
waterIds = {493, 4608, 4609, 4610, 4611, 4612, 4613, 4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 4820, 4821, 4822, 4823, 4824, 4825}
}
local pokemons = {} -- i want initialize this one nully,
local grupo1 = { 'Magikarp' } -- what kind of data is this ? array ? matrix ? table ?
local grupo2 = { grupo1, {'Goldeen'}, {'Krabby'}, {'Poliwag'}, {'Horsea'} }
local grupo3 = { grupo2, {'Tentacool'} }
local grupo4 = { grupo3, {'Seaking'}, {'Poliwhril'} }
local grupo5 = { grupo4, {'Seadra'}, {'Kingler'} }
local grupo6 = { grupo5, {'Gyarados'}, {'Tentacruel'} }
local qtdpokes = 12 -- numero de monstros que você colocou /\
local dificuldade = 10 -- < quanto maior, mais dificil de pescar um monstro
local config = {
rateSkill = getConfigValue("rateSkill"),
allowFromPz = false
}
function onUse(cid, item, frompos, item2, topos)
local skill = getPlayerSkill(cid, SKILL_FISHING)
if ((skill >= 10) and (skill < 20)) then
pokemons = grupo1
end
if (skill >= 20) then
pokemons = grupo2
end
if (skill >= 40) then
pokemons = grupo3
end
if (skill >= 60) then
pokemons = grupo4
end
if (skill >= 80) then
pokemons = grupo5
end
if (skill >= 100) then
pokemons = grupo6
end
if(not isInArray(configg.waterIds, item2.itemid)) then
return false
end
local chance = math.random(1,qtdpokes+dificuldade) --
if chance >= 1 and chance <= dificuldade then
create = pokemons[chance][1] -- this is indexing nully, cant do it
doSummonCreature(create, getCreaturePosition(cid))
doSendMagicEffect(topos, 11)
else
doSendMagicEffect(topos, CONST_ME_LOSEENERGY)
end
if((config.allowFromPz or not getTileInfo(getCreaturePosition(cid)).protection) and item2.itemid ~= 2580 and
math.random(1, (100 + (skill / 10))) < skill) then
doPlayerAddSkillTry(cid, SKILL_FISHING, config.rateSkill)
doSendMagicEffect(topos, CONST_ME_LOSEENERGY)
else
doSendMagicEffect(topos, CONST_ME_LOSEENERGY)
end
return true
end
i'm just getting started with this language .
and don't know much .
i need help to fix this script and optimize it, thx for now.
----------------------------------------------------------------
local configg = {
waterIds = {493, 4608, 4609, 4610, 4611, 4612, 4613, 4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 4820, 4821, 4822, 4823, 4824, 4825}
}
local pokemons = {} -- i want initialize this one nully,
local grupo1 = { 'Magikarp' } -- what kind of data is this ? array ? matrix ? table ?
local grupo2 = { grupo1, {'Goldeen'}, {'Krabby'}, {'Poliwag'}, {'Horsea'} }
local grupo3 = { grupo2, {'Tentacool'} }
local grupo4 = { grupo3, {'Seaking'}, {'Poliwhril'} }
local grupo5 = { grupo4, {'Seadra'}, {'Kingler'} }
local grupo6 = { grupo5, {'Gyarados'}, {'Tentacruel'} }
local qtdpokes = 12 -- numero de monstros que você colocou /\
local dificuldade = 10 -- < quanto maior, mais dificil de pescar um monstro
local config = {
rateSkill = getConfigValue("rateSkill"),
allowFromPz = false
}
function onUse(cid, item, frompos, item2, topos)
local skill = getPlayerSkill(cid, SKILL_FISHING)
if ((skill >= 10) and (skill < 20)) then
pokemons = grupo1
end
if (skill >= 20) then
pokemons = grupo2
end
if (skill >= 40) then
pokemons = grupo3
end
if (skill >= 60) then
pokemons = grupo4
end
if (skill >= 80) then
pokemons = grupo5
end
if (skill >= 100) then
pokemons = grupo6
end
if(not isInArray(configg.waterIds, item2.itemid)) then
return false
end
local chance = math.random(1,qtdpokes+dificuldade) --
if chance >= 1 and chance <= dificuldade then
create = pokemons[chance][1] -- this is indexing nully, cant do it
doSummonCreature(create, getCreaturePosition(cid))
doSendMagicEffect(topos, 11)
else
doSendMagicEffect(topos, CONST_ME_LOSEENERGY)
end
if((config.allowFromPz or not getTileInfo(getCreaturePosition(cid)).protection) and item2.itemid ~= 2580 and
math.random(1, (100 + (skill / 10))) < skill) then
doPlayerAddSkillTry(cid, SKILL_FISHING, config.rateSkill)
doSendMagicEffect(topos, CONST_ME_LOSEENERGY)
else
doSendMagicEffect(topos, CONST_ME_LOSEENERGY)
end
return true
end