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

Solved Old TFS 0.3 talkaction !party update for TFS 1.2

Michael Orsino

Premium User
Premium User
Support Team
Joined
Nov 15, 2007
Messages
854
Solutions
10
Reaction score
389
Location
Santiago, Chile (Australian)
SEE POST #6 FOR THE SOLUTION

Hello,

I'd like to include this old war script in my current war project. TFS 1.2 compat.lua lets the majority of this script function as intended.

In the below code, I have commented out the statement that does not work. The intention of this line is to check if the player using the talkaction is the leader of the party he is in.
There is no error, it just jumps to the else statement.

Any assistance appreciated

Thanks,
Michael

Code:
local config =
{
    sexChangeable = false,
    copyOutfitAndAddonsEverytime = false
}

function onSay(cid, words, param, channel)
    party = getPlayerParty(cid)
    if (config.sexChangeable == true) then
        sex = getPlayerSex(cid)
    end
    if (party) then
        --if (party == player:getId()) then
            outfit = getCreatureOutfit(cid)
            members = getPartyMembers(party)
            if (#members >= 1) then  
                tmp = outfit
                for i=1,#members do  
                    if (config.sexChangeable == true) then
                        if (sex ~= getPlayerSex(members[i])) then
                            doPlayerSetSex(members[i], sex)
                        end
                    end
                    if(config.copyOutfitAndAddonsEverytime == false and canPlayerWearOutfit(members[i], tmp.lookType, tmp.lookAddons) ~= true) then
                        local tmpOutfit = getCreatureOutfit(members[i])
                        tmp.lookType = tmpOutfit.lookType
                        tmp.lookAddons = tmpOutfit.lookAddons
                    end
                    doCreatureChangeOutfit(members[i], tmp)
                    doSendMagicEffect(getCreaturePosition(members[i]), 66)
                end
            end
        --else
            --doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You must be the leader of a party!")
        --end
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You must be in a party!")
    end
    return true
end
 
Last edited:
Code:
local config = {
    sexChangeable = false,
    copyOutfitAndAddonsEverytime = false
}

function onSay(player, words, param, channel)
    party = player:getParty()
    if (config.sexChangeable == true) then
        sex = player:getSex() -- yes plxor
    end
    if party then
        if party:getLeader() == player:getId() then
            outfit = player:getOutfit()
            members = party:getMembers()
            if (#members >= 1) then
                tmp = outfit
                for i = 1, #members do
                    if (config.sexChangeable == true) then
                        if sex ~= members[i]:getSex() then
                            members[i]:setSex(sex)
                        end
                    end
                    if config.copyOutfitAndAddonsEverytime == false and members[i]:hasOutfit(tmp.lookType, tmp.lookAddons) ~= true then
                        local tmpOutfit = members[i]:getOutfit()
                        tmp.lookType = tmpOutfit.lookType
                        tmp.lookAddons = tmpOutfit.lookAddons
                    end
                    members[i]:setOutfit(tmp)
                    Position(members[i]:getPosition()):sendMagicEffect(66)
                end
            end
        else
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You must be the leader of a party!")
        end
    else
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You must be in a party!")
    end
    return true
end
 
Last edited:
That is very similar to what I tried too, unfortunately it doesn't currently work

Code:
Feb 23 11:18:19 198-27-98-111 tfs[28836]: Lua Script Error: [TalkAction Interface]
Feb 23 11:18:19 198-27-98-111 tfs[28836]: data/talkactions/scripts/go.lua:onSay
Feb 23 11:18:19 198-27-98-111 tfs[28836]: data/talkactions/scripts/go.lua:11: bad argument #1 to 'next' (table expected, got userdata)
Feb 23 11:18:19 198-27-98-111 tfs[28836]: stack traceback:
Feb 23 11:18:19 198-27-98-111 tfs[28836]: [C]: at 0x00991d9e
Feb 23 11:18:19 198-27-98-111 tfs[28836]: [C]: in function 'next'
Feb 23 11:18:19 198-27-98-111 tfs[28836]: data/talkactions/scripts/go.lua:11: in function <data/talkactions/scripts/go.lua:6>
 
Try this:
Code:
local config = {
    sexChangeable = false,
    copyOutfitAndAddonsEverytime = false
}

function onSay(player, words, param)
    local party = player:getParty()
    if not party then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You must be in a party!")
        return false
    end

    local leader = party:getLeader()
    if leader ~= player then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You must be the leader of a party!")
        return false
    end

    local leaderOutfit = leader:getOutfit()
    local leaderSex = leader:getSex()
    for _, member in ipairs(party:getMembers()) do
        if config.sexChangeable and leaderSex ~= member:getSex() then
            member:setSex(leaderSex)
        end

        local newOutfit = leaderOutfit
        if not config.copyOutfitAndAddonsEverytime then
            local tmpOutfit = member:getOutfit()
            if not member:hasOutfit(leaderOutfit.lookType) then
                newOutfit.lookType = tmpOutfit.lookType
            end

            if not member:hasOutfit(leaderOutfit.lookType, leaderOutfit.lookAddons) then
                newOutfit.lookAddons = tmpOutfit.lookAddons
            end
        end

        member:setOutfit(newOutfit)
        member:getPosition():sendMagicEffect(CONST_ME_YALAHARIGHOST)
    end

    return false
end
 
Back
Top