• 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 Get amount of addons owned

nefinoo

Carnage.flv
Joined
Sep 11, 2010
Messages
551
Solutions
1
Reaction score
59
Location
Lo Mochis, Sinaloa
I am guiding myself through this thread, and since im not good at lua, im trying to understand it. What I did was add the code in lib to create the function, then create a revscript action
Lua:
local Outfitss = Action()

function Outfitss.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, player:getOwnedOutfits())             
    return true
end

Outfitss:id(5091)
Outfitss:register()

and apparently the script works, but it doesn't show me anything.

nothing.png
 
The Player::getOwnedOutfits function returns a Lua table, which by the looks of it does not have an implicit string conversion. You can try iterating the table instead (not tested):

Lua:
local Outfitss = Action()

function Outfitss.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    text = ""
    outfits = player:getOwnedOutfits()
    
    for outfitId, addons in pairs(outfits) do
        text = text .. "(" .. outfitId .. ": " .. addons .. "), "
    end

    if text ~= "" then
        -- Remove last ', '
        text = text:sub(1, -3)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, text)
    else
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "No outfits.")
    end

    return true
end

Outfitss:id(5091)
Outfitss:register()
 
The Player::getOwnedOutfits function returns a Lua table, which by the looks of it does not have an implicit string conversion. You can try iterating the table instead (not tested):

Lua:
local Outfitss = Action()

function Outfitss.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    text = ""
    outfits = player:getOwnedOutfits()
   
    for outfitId, addons in pairs(outfits) do
        text = text .. "(" .. outfitId .. ": " .. addons .. "), "
    end

    if text ~= "" then
        -- Remove last ', '
        text = text:sub(1, -3)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, text)
    else
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "No outfits.")
    end

    return true
end

Outfitss:id(5091)
Outfitss:register()
I did not understand much your script man, but it gave me a good idea, just putting all the looktypes distributed by gender

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()

Now my question is, how can I add permanent attributes for every 5 mounts and addons.
 
Back
Top