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

New fishing sytem

bomba

Member
Joined
Feb 26, 2008
Messages
635
Reaction score
7
Location
Brazil
I wanna a new fishing system like this:
Look at this sketch:
Code:
local listOthers = {2226, 2240, 5417, 10583, 5951}
config = {
[3877] = {bait = {8297}, obtain = {{2667, 70, math.random(1, 4)}, {listOthers[math.random(#listOthers)], 29, math.random(1, 5)}, {5895, 1, 1}}} -- Example: {Item, Chance, Quantidade}
[2580] = {bait = {5951, 3976, 9005}, obtain = {{2667, 70, 1}, {5554, 30, 1}}} -- Example: {Item, Chance, Quantidade}
[10223] = {bait = false, obtain = {10224, 100, 1}} -- Example: {Item, Chance, Quantidade}
}

player:addSkillTries(SKILL_FISHING, 1)

local waterIds = {493, 4608, 4609, 4610, 4611, 4612, 4613, 4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 7236, 10499, 15401, 15402}
if not isInArray(waterIds, itemEx.itemid) then
    return false
end

if bait == false then
    return true
elseif (bait == 8297 or bait == 5951 or bait == 3976 or bait == 9005) then
    return true
else
    player:sendCancelMessage("You need to put a bait.")
end

local stor = 97170035
if player:getStorageValue(stor) == 1440 then
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Now you are a professional fisherman.")
end

local obtain = player:addItem(config.obtain)
if (obtain == 2667 or obtain == 10224) then
    player:setStorageValue(stor, player:getStorageValue(stor)+1)
end
 
Last edited:
Edit:
My first attempt:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)
    local listOthers = {2226, 2240, 5417, 10583, 5951}
    config = {
    [3877] = {isca = 8297, obter = {a = 2667, b = listOthers[math.random(#listOthers)], c = 5895}},
    [2580] = {isca = {5951, 3976, 9005}, obter = {a = 2667, b = 5554}},
    [10223] = {obter = 10224},
}

local waterIds = {493, 4608, 4609, 4610, 4611, 4612, 4613, 4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 7236, 10499, 15401, 15402}
if not isInArray(waterIds, itemEx.itemid) then
    return false
end

local varaDePesca = config[item.itemid]
local aleat = math.random(1, 100)
if varaDePesca == 3877 then
    if getPlayerItemCount(cid, varaDePesca[isca]) >= 1 then
        doPlayerRemoveItem(cid, varaDePesca[isca], 1)
        doPlayerAddSkillTries(SKILL_FISHING, 1)
        if aleat <= 70 then
            doPlayerAddItem(cid, varaDePesca[obter[a]], math.random(1, 4))
            setPlayerStorageValue(cid, stor, (getPlayerStorageValue(cid, stor)+1))
            if getPlayerStorageValue(cid, stor) == 1440 then
                doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Transformou-se em um pescador profissional.")
            end
        elseif (aleat >= 71 and aleat <= 73) then
            doPlayerAddItem(cid, varaDePesca[obter[b]], 1)
        elseif aleat >= 74 then
            doPlayerAddItem(cid, varaDePesca[obter[c]], math.random(1, 5))
        end
    else
        doPlayerSendCancel(cid, "Precisa ter a isca correta.")
    end
elseif varaDePesca == 2580 then
    if getPlayerItemCount(cid, varaDePesca[isca]) >= 1 then
        doPlayerRemoveItem(cid, varaDePesca[isca], 1)
        doPlayerAddSkillTries(SKILL_FISHING, 1)
        if aleat <= 70 then
            doPlayerAddItem(cid, varaDePesca[obter[a]], 1)
            setPlayerStorageValue(cid, stor, (getPlayerStorageValue(cid, stor)+1))
            if getPlayerStorageValue(cid, stor) == 1440 then
                doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Transformou-se em um pescador profissional.")
            end
        elseif aleat >= 71 then
            doPlayerAddItem(cid, varaDePesca[obter[b]], 1)
        end
    else
        doPlayerSendCancel(cid, "Precisa ter a isca correta.")
    end
elseif varaDePesca == 10223 then
    if getPlayerStorageValue(cid, stor) >= 1440 then
    doPlayerAddSkillTries(SKILL_FISHING, 1)
    doPlayerAddItem(cid, varaDePesca[obter], 1)
    setPlayerStorageValue(cid, stor, (getPlayerStorageValue(cid, stor)+1))
    else
        doPlayerSendCancel(cid, "Precisa ser um pescador profissional.")
    end
end
return true
end

Not appear errors in console, but nothing happens.

-- Double Post Merged, at Tue Aug 4, 2015 17:05 PM --

Up!
 
Last edited by a moderator:
Updated:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)
    local listOthers = {2226, 2240, 5417, 10583, 5951}
    config = {
    [3877] = {isca = 8297, obter = {a = 2667, b = listOthers[math.random(#listOthers)], c = 5895}},
    [2580] = {isca = {5951, 3976, 9005}, obter = {a = 2667, b = 5554}},
    [10223] = {obter = 10224},
}

local waterIds = {493, 4608, 4609, 4610, 4611, 4612, 4613, 4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 7236, 10499, 15401, 15402}
if not isInArray(waterIds, itemEx.itemid) then
    return false
end

local varaDePesca = config[item.itemid]
local aleat = math.random(1, 100)
if varaDePesca == 3877 then
    if getPlayerItemCount(cid, varaDePesca["isca"]) >= 1 then
        doPlayerRemoveItem(cid, varaDePesca["isca"], 1)
        doPlayerAddSkillTries(SKILL_FISHING, 1)
        if aleat <= 70 then
            doPlayerAddItem(cid, varaDePesca["obter"]["a"], math.random(1, 4))
            setPlayerStorageValue(cid, stor, (getPlayerStorageValue(cid, stor)+1))
            if getPlayerStorageValue(cid, stor) == 1440 then
                doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Transformou-se em um pescador profissional.")
            end
        elseif (aleat >= 71 and aleat <= 73) then
            doPlayerAddItem(cid, varaDePesca["obter"]["b"], 1)
        elseif aleat >= 74 then
            doPlayerAddItem(cid, varaDePesca["obter"]["c"], math.random(1, 5))
        end
    else
        doPlayerSendCancel(cid, "Precisa ter a isca correta.")
    end
elseif varaDePesca == 2580 then
    if getPlayerItemCount(cid, varaDePesca["isca"]) >= 1 then
        doPlayerRemoveItem(cid, varaDePesca["isca"], 1)
        doPlayerAddSkillTries(SKILL_FISHING, 1)
        if aleat <= 70 then
            doPlayerAddItem(cid, varaDePesca["obter"]["a"], 1)
            setPlayerStorageValue(cid, stor, (getPlayerStorageValue(cid, stor)+1))
            if getPlayerStorageValue(cid, stor) == 1440 then
                doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Transformou-se em um pescador profissional.")
            end
        elseif aleat >= 71 then
            doPlayerAddItem(cid, varaDePesca["obter"]["b"], 1)
        end
    else
        doPlayerSendCancel(cid, "Precisa ter a isca correta.")
    end
elseif varaDePesca == 10223 then
    if getPlayerStorageValue(cid, stor) >= 1440 then
    doPlayerAddSkillTries(SKILL_FISHING, 1)
    doPlayerAddItem(cid, varaDePesca["obter"], 1)
    setPlayerStorageValue(cid, stor, (getPlayerStorageValue(cid, stor)+1))
    else
        doPlayerSendCancel(cid, "Precisa ser um pescador profissional.")
    end
end
return true
end

But don't work
 
If it's not working then:
1. Tell us which TFS version you are using.
2. Show us what error message is appearing in your console if any.
3. If there is not an error message then tell us what is suppose to happen and what's happening instead.

It will save time for people trying to help instead of us going line by line trying to find the error.
 
line 35 is written incorrectly
Code:
if getPlayerItemCount(cid, varaDePesca["isca"]) >= 1 then
This will return false because your comparing a table to a number

Also itemid 3877 what is this? I checked a 8.6 server and there is no record of an item with that id.

I see no where in the script 1440 being set, what is the significance of this number for comparison?
 
Updated:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)
    local listOthers = {2226, 2240, 5417, 10583, 5951}
    config = {
    [3877] = {isca = 8297, obter = {a = 2667, b = listOthers[math.random(#listOthers)], c = 5895}},
    [2580] = {isca = {5951, 3976, 9005}, obter = {a = 2667, b = 5554}},
    [10223] = {obter = 10224},
}

local waterIds = {493, 4608, 4609, 4610, 4611, 4612, 4613, 4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 7236, 10499, 15401, 15402}
if not isInArray(waterIds, itemEx.itemid) then
    return false
end

local aleat = math.random(1, 100)
if item.itemid == 3877 then
    if getPlayerItemCount(cid, config[3877]["isca"]) >= 1 then
        doPlayerRemoveItem(cid, config[3877]["isca"], 1)
        doPlayerAddSkillTry(SKILL_FISHING, 1)
        doSendMagicEffect(toPosition, CONST_ME_WATERSPLASH)
        if aleat <= 70 then
            doPlayerAddItem(cid, config[3877]["obter"]["a"], math.random(1, 4))
            setPlayerStorageValue(cid, stor, (getPlayerStorageValue(cid, stor)+1))
            if getPlayerStorageValue(cid, stor) == 1440 then
                doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Transformou-se em um pescador profissional.")
            end
        elseif (aleat >= 71 and aleat <= 73) then
            doPlayerAddItem(cid, config[3877]["obter"]["b"], 1)
        elseif aleat >= 74 then
            doPlayerAddItem(cid, config[3877]["obter"]["c"], math.random(1, 5))
        end
    else
        doPlayerSendCancel(cid, "Precisa de isca.")
    end
elseif item.itemid == 2580 then
    if getPlayerItemCount(cid, config[2580]["isca"]) >= 1 then
        doPlayerRemoveItem(cid, config[2580]["isca"], 1)
        doPlayerAddSkillTry(SKILL_FISHING, 1)
        doSendMagicEffect(toPosition, CONST_ME_WATERSPLASH)
        if aleat <= 70 then
            doPlayerAddItem(cid, config[2580]["obter"]["a"], 1)
            setPlayerStorageValue(cid, stor, (getPlayerStorageValue(cid, stor)+1))
            if getPlayerStorageValue(cid, stor) == 1440 then
                doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Transformou-se em um pescador profissional.")
            end
        elseif aleat >= 71 then
            doPlayerAddItem(cid, config[2580]["obter"]["b"], 1)
        end
    else
        doPlayerSendCancel(cid, "Precisa de isca.")
    end
elseif item.itemid == 10223 then
    if getPlayerStorageValue(cid, stor) >= 1440 then
    doPlayerAddSkillTry(SKILL_FISHING, 1)
    doPlayerAddItem(cid, config[10223]["obter"], 1)
    doSendMagicEffect(toPosition, CONST_ME_WATERSPLASH)
    setPlayerStorageValue(cid, stor, (getPlayerStorageValue(cid, stor)+1))
    else
        doPlayerSendCancel(cid, "Precisa ser um pescador profissional.")
    end
end
return true
end

Error:
error.png
 
In a simple table like this.
Code:
local config = {8297, 2667}
Code:
-- To get the first value (8297)
config[1]

-- For the second value (2667)
config[2]


~~~~
If you give a name to the value, use a . followed by the name to get the value.
Code:
local config = {isca = 8297, obter = 2667}
Code:
-- 8297
config.isca

-- 2667
config.obter


~~~~
If you use keys, you can get the value like this.
Code:
local config = {["isca"] = 8297, ["obter"] = 2667}
Code:
-- 8297
config["isca"]

-- 2667
config["obter"]



~~~~
In the table in the script you posted, the values from the keys are tables with names for the values in that table.
So you have to combinate it.
Code:
config[3877].isca
This will be 8297.

The way you have it atm: config[3877]["isca"], the table should look like this.
Code:
local config = {
     [3877] = {["isca"] = 8297}
     -- etc
}
 
Last edited:
Back
Top