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

Onkill otx2

matheusjp2

New Member
Joined
Oct 5, 2015
Messages
15
Reaction score
3
A small problem is occurring, when there is a group of 10 people killing the same monster sometimes it does not set the storage and ends up leaving the team behind

script.
Lua:
local saga = {
['raditz saga'] = {setStorageValue = 2,
rewards = {
    {"exp", 10000}
}},
['monkey'] = {setStorageValue = 4,
rewards = {
    {"item", 2160, 100},
    {"exp", 20000}
}},
['gregory'] = {setStorageValue = 5,
rewards = {
    {"exp", 20000}
}},
['nappa'] = {setStorageValue = 7,
rewards = {
    {"exp", 20000}
}},
['vegeta'] = {setStorageValue = 8,
rewards = {
    {"exp", 20000}
}},

['oozaru vegeta'] = {setStorageValue = 9,
rewards = {
    {"exp", 25000}
}},

}

local function reward(cid, t)
    for _,n in pairs(t) do
        if(n[1] == "item") then
            doPlayerAddItem(cid, n[2], n[3], true)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,  "Reward: ".. n[3] .." ".. getItemNameById(n[2]) .."(s).")
        end
        if(n[1] == "exp") then
            doPlayerAddExperience(cid, n[2])
            doSendAnimatedText(getCreaturePosition(cid), n[2], 15)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,  "Experience: ".. n[2] ..".")
        end
    end
    return true
end

function onKill(cid, target, lastHit)

    for x, y in pairs(saga) do
        if(x:lower() == getCreatureName(target):lower()) then
            --if(getPlayerStorageValue(cid, 8000) == y.getStorageValue) then
                doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Saga: ".. x .. " successful done.")
                setPlayerStorageValue(cid, 8000, y.setStorageValue)
                --doCreatureSay(cid, "Saga ".. x .." successful done.", TALKTYPE_ORANGE_1)   
                reward(cid, y.rewards)
            --end
        end
    end
    return true
end
 
It looks like you commented "--if(getPlayerStorageValue(cid, 8000) == y.getStorageValue) then". Just uncomment and test to verify that the storage was fetched correctly.

Lua:
local saga = {
    ['raditz saga'] = {
        setStorageValue = 2,
        rewards = {
            {"exp", 10000}
        }
    },
    ['monkey'] = {
        setStorageValue = 4,
        rewards = {
            {"item", 2160, 100},
            {"exp", 20000}
        }
    },
    ['gregory'] = {
        setStorageValue = 5,
        rewards = {
            {"exp", 20000}
        }
    },
    ['nappa'] = {
        setStorageValue = 7,
        rewards = {
            {"exp", 20000}
        }
    },
    ['vegeta'] = {
        setStorageValue = 8,
        rewards = {
            {"exp", 20000}
        }
    },
    ['oozaru vegeta'] = {
        setStorageValue = 9,
        rewards = {
            {"exp", 25000}
        }
    }
}

local function reward(cid, t)
    for _, n in pairs(t) do
        if n[1] == "item" then
            doPlayerAddItem(cid, n[2], n[3], true)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Reward: " .. n[3] .. " " .. getItemNameById(n[2]) .. "(s).")
        elseif n[1] == "exp" then
            doPlayerAddExperience(cid, n[2])
            doSendAnimatedText(getCreaturePosition(cid), n[2], 15)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Experience: " .. n[2] .. ".")
        end
    end
    return true
end

function onKill(cid, target, lastHit)
    for x, y in pairs(saga) do
        if x:lower() == getCreatureName(target):lower() then
            if getPlayerStorageValue(cid, 8000) == y.setStorageValue then
                doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Saga: " .. x .. " successfully done.")
                setPlayerStorageValue(cid, 8000, y.setStorageValue)
                reward(cid, y.rewards)
            end
        end
    end
    return true
end
 
Lua:
local saga = {
    ['raditz saga'] = {
        setStorageValue = 2,
        rewards = {
            {"exp", 10000}
        }
    },
    ['monkey'] = {
        setStorageValue = 4,
        rewards = {
            {"item", 2160, 100},
            {"exp", 20000}
        }
    },
    ['gregory'] = {
        setStorageValue = 5,
        rewards = {
            {"exp", 20000}
        }
    },
    ['nappa'] = {
        setStorageValue = 7,
        rewards = {
            {"exp", 20000}
        }
    },
    ['vegeta'] = {
        setStorageValue = 8,
        rewards = {
            {"exp", 20000}
        }
    },
    ['oozaru vegeta'] = {
        setStorageValue = 9,
        rewards = {
            {"exp", 25000}
        }
    }
}

local function reward(cid, t)
    for _, n in pairs(t) do
        if n[1] == "item" then
            doPlayerAddItem(cid, n[2], n[3], true)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Reward: " .. n[3] .. " " .. getItemNameById(n[2]) .. "(s).")
        elseif n[1] == "exp" then
            doPlayerAddExperience(cid, n[2])
            doSendAnimatedText(getCreaturePosition(cid), n[2], 15)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Experience: " .. n[2] .. ".")
        end
    end
    return true
end

function onKill(cid, target, lastHit)
    for x, y in pairs(saga) do
        if x:lower() == getCreatureName(target):lower() then
            if getPlayerStorageValue(cid, 8000) == y.setStorageValue then
                doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Saga: " .. x .. " successfully done.")
                setPlayerStorageValue(cid, 8000, y.setStorageValue)
                reward(cid, y.rewards)
            end
        end
    end
    return true
end
this occurs when there are a lot of people attacking
 
see if it worked or not, if you have errors in the console just show them here

Lua:
local saga = {
    ['raditz saga'] = {
        storageValue = 2,
        rewards = {
            {"exp", 10000}
        }
    },
    ['monkey'] = {
        storageValue = 4,
        rewards = {
            {"item", 2160, 100},
            {"exp", 20000}
        }
    },
    ['gregory'] = {
        storageValue = 5,
        rewards = {
            {"exp", 20000}
        }
    },
    ['nappa'] = {
        storageValue = 7,
        rewards = {
            {"exp", 20000}
        }
    },
    ['vegeta'] = {
        storageValue = 8,
        rewards = {
            {"exp", 20000}
        }
    },
    ['oozaru vegeta'] = {
        storageValue = 9,
        rewards = {
            {"exp", 25000}
        }
    }
}

local function reward(cid, t)
    for _, n in pairs(t) do
        if n[1] == "item" then
            doPlayerAddItem(cid, n[2], n[3], true)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Reward: " .. n[3] .. " " .. getItemNameById(n[2]) .. "(s).")
        elseif n[1] == "exp" then
            doPlayerAddExperience(cid, n[2])
            doSendAnimatedText(getCreaturePosition(cid), n[2], 15)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Experience: " .. n[2] .. ".")
        end
    end
    return true
end

local sagaState = {}

function onKill(cid, target, lastHit)
    for x, y in pairs(saga) do
        if x:lower() == getCreatureName(target):lower() then
            if not sagaState[x] or sagaState[x] == y.storageValue - 1 then
                sagaState[x] = y.storageValue
                doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Saga: " .. x .. " successfully done.")
                reward(cid, y.rewards)
            end
        end
    end
    return true
end
 
see if it worked or not, if you have errors in the console just show them here

Lua:
local saga = {
    ['raditz saga'] = {
        storageValue = 2,
        rewards = {
            {"exp", 10000}
        }
    },
    ['monkey'] = {
        storageValue = 4,
        rewards = {
            {"item", 2160, 100},
            {"exp", 20000}
        }
    },
    ['gregory'] = {
        storageValue = 5,
        rewards = {
            {"exp", 20000}
        }
    },
    ['nappa'] = {
        storageValue = 7,
        rewards = {
            {"exp", 20000}
        }
    },
    ['vegeta'] = {
        storageValue = 8,
        rewards = {
            {"exp", 20000}
        }
    },
    ['oozaru vegeta'] = {
        storageValue = 9,
        rewards = {
            {"exp", 25000}
        }
    }
}

local function reward(cid, t)
    for _, n in pairs(t) do
        if n[1] == "item" then
            doPlayerAddItem(cid, n[2], n[3], true)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Reward: " .. n[3] .. " " .. getItemNameById(n[2]) .. "(s).")
        elseif n[1] == "exp" then
            doPlayerAddExperience(cid, n[2])
            doSendAnimatedText(getCreaturePosition(cid), n[2], 15)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Experience: " .. n[2] .. ".")
        end
    end
    return true
end

local sagaState = {}

function onKill(cid, target, lastHit)
    for x, y in pairs(saga) do
        if x:lower() == getCreatureName(target):lower() then
            if not sagaState[x] or sagaState[x] == y.storageValue - 1 then
                sagaState[x] = y.storageValue
                doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Saga: " .. x .. " successfully done.")
                reward(cid, y.rewards)
            end
        end
    end
    return true
end
both do not give to storage
Post automatically merged:

Lua:
local saga = {
    ['raditz saga'] = {
        setStorageValue = 2,
        rewards = {
            {"exp", 10000}
        }
    },
    ['monkey'] = {
        setStorageValue = 4,
        rewards = {
            {"item", 2160, 100},
            {"exp", 20000}
        }
    },
    ['gregory'] = {
        setStorageValue = 5,
        rewards = {
            {"exp", 20000}
        }
    },
    ['nappa'] = {
        setStorageValue = 7,
        rewards = {
            {"exp", 20000}
        }
    },
    ['vegeta'] = {
        setStorageValue = 8,
        rewards = {
            {"exp", 20000}
        }
    },
    ['oozaru vegeta'] = {
        setStorageValue = 9,
        rewards = {
            {"exp", 25000}
        }
    }
}

local function reward(cid, t)
    for _, n in pairs(t) do
        if n[1] == "item" then
            doPlayerAddItem(cid, n[2], n[3], true)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Reward: " .. n[3] .. " " .. getItemNameById(n[2]) .. "(s).")
        elseif n[1] == "exp" then
            doPlayerAddExperience(cid, n[2])
            doSendAnimatedText(getCreaturePosition(cid), n[2], 15)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Experience: " .. n[2] .. ".")
        end
    end
    return true
end

function onKill(cid, target, lastHit)
    for x, y in pairs(saga) do
        if x:lower() == getCreatureName(target):lower() then
            if getPlayerStorageValue(cid, 8000) == y.setStorageValue then
                doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Saga: " .. x .. " successfully done.")
                setPlayerStorageValue(cid, 8000, y.setStorageValue)
                reward(cid, y.rewards)
            end
        end
    end
    return true
end
now does not receive any messages, nor does it change anyone's storage
 
Last edited:
Lua:
local saga = {
    ['raditz saga'] = {
        storageValue = 2,
        rewards = {
            {"exp", 10000}
        }
    },
    ['monkey'] = {
        storageValue = 4,
        rewards = {
            {"item", 2160, 100},
            {"exp", 20000}
        }
    },
    ['gregory'] = {
        storageValue = 5,
        rewards = {
            {"exp", 20000}
        }
    },
    ['nappa'] = {
        storageValue = 7,
        rewards = {
            {"exp", 20000}
        }
    },
    ['vegeta'] = {
        storageValue = 8,
        rewards = {
            {"exp", 20000}
        }
    },
    ['oozaru vegeta'] = {
        storageValue = 9,
        rewards = {
            {"exp", 25000}
        }
    }
}

local function reward(cid, rewards)
    for _, reward in ipairs(rewards) do
        local rewardType = reward[1]
        if rewardType == "item" then
            local itemId = reward[2]
            local itemCount = reward[3]
            doPlayerAddItem(cid, itemId, itemCount, true)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Reward: " .. itemCount .. " " .. getItemNameById(itemId) .. "(s).")
        elseif rewardType == "exp" then
            local expAmount = reward[2]
            doPlayerAddExperience(cid, expAmount)
            doSendAnimatedText(getCreaturePosition(cid), expAmount, 15)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Experience: " .. expAmount .. ".")
        end
    end
    return true
end

local sagaState = {}

function onKill(cid, target, lastHit)
    local targetName = getCreatureName(target):lower()
    for sagaName, sagaData in pairs(saga) do
        if targetName == sagaName:lower() then
            if not sagaState[sagaName] or sagaState[sagaName] == sagaData.storageValue - 1 then
                sagaState[sagaName] = sagaData.storageValue
                doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Saga: " .. sagaName .. " successfully done.")
                reward(cid, sagaData.rewards)
            end
        end
    end
    return true
end


test there
 
I made a change and it seems to have worked.
Post automatically merged:

Lua:
local saga = {
['raditz saga'] = {setStorageValue = 2, getStorageValue = 1,
rewards = {
    {"exp", 10000}
}},
['monkey'] = {setStorageValue = 4, getStorageValue = 3,
rewards = {
    {"item", 2160, 100},
    {"exp", 20000}
}},
['gregory'] = {setStorageValue = 5, getStorageValue = 4,
rewards = {
    {"exp", 20000}
}},
['nappa'] = {setStorageValue = 7, getStorageValue = 6,
rewards = {
    {"exp", 20000}
}},
['vegeta'] = {setStorageValue = 8, getStorageValue = 7,
rewards = {
    {"exp", 20000}
}},

['oozaru vegeta'] = {setStorageValue = 9, getStorageValue = 8,
rewards = {
    {"exp", 25000}
}},

}

local function reward(cid, t)
    for _,n in pairs(t) do
        if(n[1] == "item") then
            doPlayerAddItem(cid, n[2], n[3], true)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,  "Reward: ".. n[3] .." ".. getItemNameById(n[2]) .."(s).")
        end
        if(n[1] == "exp") then
            doPlayerAddExperience(cid, n[2])
            doSendAnimatedText(getCreaturePosition(cid), n[2], 15)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,  "Experience: ".. n[2] ..".")
        end
    end
    return true
end

function onKill(cid, target, lastHit)

    for x, y in pairs(saga) do
        if(x:lower() == getCreatureName(target):lower()) then
            if(getPlayerStorageValue(cid, 8000) == y.getStorageValue) then
                doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Saga: ".. x .. " successful done.")
                setPlayerStorageValue(cid, 8000, y.setStorageValue)
                doCreatureSay(cid, "Saga ".. x .." successful done.", TALKTYPE_ORANGE_1)   
                reward(cid, y.rewards)
            end
        end
    end
    return true
end
 
Back
Top