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

Lua Permanent attributes

nefinoo

Carnage.flv
Joined
Sep 11, 2010
Messages
420
Solutions
1
Reaction score
33
Location
Lo Mochis, Sinaloa
Lua:
local BONUSES = CreatureEvent("BONUSADDONS")
male = {128, 129, 130}
female = {136, 137, 138}

function BONUSES.onLogin(player)
    local Outfits = 0
    local sex = player:getSex()
    
        if sex == 0 then
            for i, looktype in pairs(female) do
                if player:hasOutfit(looktype, 3) then
                    Outfits = Outfits + 1
                end
            end
        else
            for i, looktype in pairs(male) do
                if player:hasOutfit(looktype, 3) then
                    Outfits = Outfits + 1
                end
            end
        end
        
    local Monturas = 0
    local i = 0
        for i = i+1, 187  do
            if player:hasMount(i) then
            Monturas = Monturas + 1
            end
        end
    player:say("i have "..Monturas.." mounts!!!.", TALKTYPE_SAY)
    player:say("I have "..Outfits.." outfits!!!.", TALKTYPE_SAY)
    
    return true
end
BONUSES:register()

I have this script and I want to know if you could help me in putting permanent attributes every 5 complete addons.
Attributes like% health / mana, critical chance / amount, life leech chance / amount and mana leech chance / amount, etc ...

I am using tfs 1.3.
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,524
Solutions
379
Reaction score
3,642
If the bonus's are static increases, use some math.

Lua:
local increase = 50 * math.floor(player:getStorageValue(key) / 5)
if increase > 0 then
    -- add buff
    print(increase)
end

If it's tiers of buffs that are added, use a table and some math.
Lua:
local buffs = {
    [5]  = {critical = 5},
    [10] = {critical = 15},
    [15] = {critical = 30},
    [20] = {critical = 30, health = 6},
    [25] = {critical = 30, health = 16},
    [30] = {critical = 30, health = 31},
    [35] = {critical = 30, health = 31, leech = 7},
    [40] = {critical = 30, health = 31, leech = 17},
    [45] = {critical = 30, health = 31, leech = 32}
}

local storageAmount = 5 * math.floor(player:getStorageValue(key) / 5)
storageAmount = storageAmount > 45 and 45 or storageAmount

local buff = buffs[storageAmount]
if buff then
    if buff.critical then
        -- give critical buff
        print(buff.critical)
    end
    if buff.health then
        -- give health buff
        print(buff.health)
    end
    if buff.leech then
        -- give leech buff
        print(buff.leech)
    end
end
 
OP
nefinoo

nefinoo

Carnage.flv
Joined
Sep 11, 2010
Messages
420
Solutions
1
Reaction score
33
Location
Lo Mochis, Sinaloa
So far, this is what I have, only that I have problems with maxhealth and maxmana, since the code is in login, I have a bug that every time I log out and login, my life goes up permanently and increases every time I log out and login.
could you help me @Xikini ?

Lua:
local BONUSES = CreatureEvent("BONUSADDONS")
male = {128,129,130,131,132,133,134,143,144,145,146,151,152,153,154,251,268,273,278,289,325,328,335,367,430,432,463,465,472,512,516,541,574,577,610,619,633,634,637,665,667,684,695,697,699,725,733,746,750,760,846,853,873,884,899,908,931,955,957,962,964,966,968,970,972,974,1021,1023,1042,1051,1056,1069,1094,1102,1127,1146,1161,1173,1186,1202,1204,1210,1245,1243,1251,1270,1279,1282,1288,1292,1322,1331,1338,1371,1382,1384,1415,1386,1415,1436,1444}
female = {136,137,138,139,140,141,142,147,148,149,150,156,157,158,252,269,270,279,288,324,329,336,366,431,433,464,466,471,513,514,542,575,578,618,620,632,635,636,664,666,683,694,696,698,724,732,745,749,845,852,874,885,900,909,929,956,958,963,965,967,969,971,973,975,1020,1024,1043,1050,1057,1070,1095,1103,1128,1147,1162,1174,1187,1203,1205,1207,1211,1246,1244,1252,1271,1280,1283,1289,1293,1323,1332,1339,1372,1383,1385,1387,1416,1437,1445}

local buffs = {
    [5]  = {critical = 2, lifeleech = 2, manaleech = 2, health = 1, mana = 1}
}

function BONUSES.onLogin(player)
    local Outfits = 0
    local sex = player:getSex()
    
        if sex == 0 then
            for i, looktype in pairs(female) do
                if player:hasOutfit(looktype, 3) then
                    Outfits = Outfits + 1
                end
            end
        else
            for i, looktype in pairs(male) do
                if player:hasOutfit(looktype, 3) then
                    Outfits = Outfits + 1
                end
            end
        end
        
    local Monturas = 0
    local i = 0
        for i = i+1, 187  do
            if player:hasMount(i) then
            Monturas = Monturas + 1
            end
        end
        
    Total = Outfits + Monturas

    local storageAmount = 5 * math.floor(Total / 5)
    storageAmount = storageAmount > 285 and 285 or storageAmount
    cantidad = math.floor(Total / 5)
    tabla = storageAmount/cantidad
    local i = 0
    local x = player:getStorageValue(11111)
    local buff = buffs[tabla]
        if buff then
            if buff.critical then
                crit = buff.critical * cantidad
                player:addSpecialSkill(SPECIALSKILL_CRITICALHITAMOUNT, crit)
            end
            if buff.lifeleech then
                life = buff.lifeleech * cantidad
                player:addSpecialSkill(SPECIALSKILL_LIFELEECHAMOUNT, life)
            end
            if buff.manaleech then
                manas = buff.manaleech * cantidad
                player:addSpecialSkill(SPECIALSKILL_MANALEECHAMOUNT, manas)
            end               
            repeat
                if i == x then
                    if buff.health then
                        hp = buff.health * cantidad
                        player:setMaxHealth(player:getMaxHealth() + hp)
                        x = x + 5
                        print(x)
                        player:setStorageValue(11111, x)
                    end
                    if buff.mana then
                        mp = buff.mana * cantidad
                        player:setMaxMana(player:getMaxMana() + mp)
                        x = x + 5
                        player:setStorageValue(11111, x)
                    end
                end
            i = i + 5
            until i > cantidad
        end   
    return true
end
BONUSES:register()
 
Top