• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Simplify this script

bomba

Member
Joined
Feb 26, 2008
Messages
635
Reaction score
7
Location
Brazil
I would like to simplify this script I'm doing. I started doing the script, but if I continue like this I will take a long time.

Please help me!
Code:
local drop3060 = 96609765002
local rand3060 = math.random(1, 100)

local drop6090 = 96609765003
local rand6090 = math.random(1, 100)

local drop90120 = 96609765004
local rand90120 = math.random(1, 100)

local msg = "Found a weapon!"

function onKill(cid, target, lastHit)
    if isMonster(target) == true then
        if getPlayerLevel(cid) > 29 and getPlayerLevel(cid) <= 60 then
            if getPlayerStorageValue(cid, drop3060) == 1 then
                if getCreatureName(target) == "Chakoya Tribewarden" or getCreatureName(target) == "Cyclops" or getCreatureName(target) == "Cyclops Drone" or getCreatureName(target) == "Frost Giant" or getCreatureName(target) == "Frost Giantess" or getCreatureName(target) == "Goblin" or getCreatureName(target) == "Goblin Assassin" or getCreatureName(target) == "Goblin Leader" or getCreatureName(target) == "Goblin Scavenger" or getCreatureName(target) == "Lizard Templar" or getCreatureName(target) == "Pirate Skeleton" or getCreatureName(target) == "Smuggler" or getCreatureName(target) == "Smuggler Baron Silvertoe" then
                    if rand3060 > 0 and rand3060 <= 5 then
    -------------------------------- Rand3060 is equal 5% of 100%
                      doPlayerAddItem(cid, 2406, 1)
                      doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, msg)
                    end
                elseif getCreatureName(target) == "Crypt Shambler" or getCreatureName(target) == "Braindeath" then
                    if rand3060 > 0 and rand3060 <= 5 then
    -------------------------------- Rand3060 is equal 5% of 100%
                      doPlayerAddItem(cid, 2450, 1)
                      doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, msg)
                    end
                end
            end
        elseif getPlayerLevel(cid) > 60 and getPlayerLevel(cid) <= 90 then
            if getPlayerStorageValue(cid, drop6090) == 1 then
                if getCreatureName(target) == "Quara Predator" or getCreatureName(target) == "Thul" or getCreatureName(target) == "Werewolf" or getCreatureName(target) == "Madareth" then
                    if rand6090 > 0 and rand6090 <= 4 then
    -------------------------------- Rand6090 is equal 4% of 100%
                      doPlayerAddItem(cid, 7855, 1)
                      doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, msg)
                    end
                elseif getCreatureName(target) == "Demon" then
                    if rand6090 > 0 and rand6090 <= 4 then
    -------------------------------- Rand6090 is equal 4% of 100%
                      doPlayerAddItem(cid, 2407, 1)
                      doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, msg)
                    end
                end
            end
        elseif getPlayerLevel(cid) > 90 and getPlayerLevel(cid) <= 120 then
            if getPlayerStorageValue(cid, drop90120) == 1 then
                if getCreatureName(target) == "Dipthrah" or getCreatureName(target) == "Horestis" then
                    if rand90120 > 0 and rand90120 <= 3 then
    -------------------------------- Rand90120 is equal 3% of 100%
                      doPlayerAddItem(cid, 2446, 1)
                      doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, msg)
                    end
                elseif getCreatureName(target) == "Quara Predator" or getCreatureName(target) == "Spectre" or getCreatureName(target) == "Thul" or getCreatureName(target) == "Werewolf" or getCreatureName(target) == "Madareth" then
                    if rand90120 > 0 and rand90120 <= 3 then
    -------------------------------- Rand90120 is equal 3% of 100%
                      doPlayerAddItem(cid, 7383, 1)
                      doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, msg)
                    end
                end
            end
        end
    end
  return true
end
 
Code:
local t = {
    [{29, 60}] = {90000, {"Chakoya Tribewarden", "Cyclops", "Cyclops Drone", "Frost Giant", "Frost Giantess", "Goblin", "Goblin Assassin", "Goblin Leader", "Goblin Scavenger", "Lizard Templar", "Pirate Skeleton", "Smuggler", "Smuggler Baron Silvertoe"}, 5, {2406, 1}, {"Crypt Shambler", "Braindeath"}, {2450, 1}},
    [{61, 90}] = {90001, {"Quara Predator", "Thul", "Werewolf", "Madareth", "Dragon"}, 4, {7855, 1}, {"Demon"}, {2407, 1}},
    [{91, 120}] = {90002, {"Dipthrah", "Horestis"}, 3, {2446, 1}, {"Quara Predator", "Spectre", "Thul", "Werewolf", "Madareth"}, {7381, 1}}
}

local rand = math.random(1, 100)
local msg = "Found a weapon!"
function onKill(cid, target, lastHit)
    if isMonster(target) == true then
        for k, v in pairs(t) do
            if getPlayerLevel(cid) >= k[1] and getPlayerLevel(cid) <= k[2] then
                if getPlayerStorageValue(cid, v[1]) == 1 then
                    if isInArray(v[2], getCreatureName(target)) then
                        if rand > 0 and rand <= v[3] then
                            doPlayerAddItem(cid, v[4][1], v[4][2])
                            doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, msg)
                        end
                    elseif isInArray(v[5], getCreatureName(target)) then
                        if rand > 0 and rand <= v[3] then
                            doPlayerAddItem(cid, v[6][1], v[6][2])
                            doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, msg)
                        end
                    end
                end
            end
        end
    end
    return true
end
 
Last edited:
Back
Top