• 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 Change outfit each time

Kiriito

New Member
Joined
Dec 5, 2014
Messages
23
Reaction score
2
Location
Argentina
Would like request a function or script that change player outfit each time he walk.
Example:

Player have outfit X, the script check if he stand or walk, if player walk, automatic change her outfit to Y.
Would need it to check many outfits at same time, like:

Player looktype: 120
Player looktype:121

If any player with looktype 120 walk then change her outfit to X, if he stand for 1sec then automatic send back to 120.
If any player with looktype 121 walk then change her outfit to Y, if he stand for 1sec then automatic send back to 121.

Would like to have it running automatic when player login, thats possible?

Cheers:)
 
Code:
local outfits = {
    {onMoveOutfit = 120, onStandStillOutfit = 121}
}

local function changeOutfitOnMove(cid, position)
    local player = Player(cid)
    if not player then
        return false
    end
   
    local playerPosition, outfit = player:getPosition()
    for i = 1, #outfits do
        outfit = outfits[i]
        if player:getOutfit().lookType == outfit.onStandStillOutfit then
            break
        end
       
        if playerPosition.x ~= position.x or playerPosition.y ~= position.y or playerPosition.z ~= position.z then
            player:setOutfit(outfit.onMoveOutfit)
        else
            player:setOutfit(outfit.onStandStillOutfit)
        end
    end
   
    addEvent(changeOutfitOnMove, 100, player:getId(), playerPosition)
end

changeOutfitOnMove(player:getId(), Position(0, 0, 0))
 
Yes, automatic when player login, and then when player walk. :)

Code:
local outfits = {
    {onMoveOutfit = 120, onStandStillOutfit = 121},
    {onMoveOutfit = 122, onStandStillOutfit = 123}
}

To add more outfits i do this way?
 
Here you go, made some changes:
Code:
local outfits = {
    {onWalkOutfit = 128, onStandOutfit = 129},
    {onWalkOutfit = 130, onStandOutfit = 131}
}

local function changeOutfitOnMove(cid, position)
    local player = Player(cid)
    if not player then
        return false
        end

    local playerPosition, hasOutfit = player:getPosition(), player:getOutfit().lookType
    local outfit
    for i = 1, #outfits do
        outfit = outfits[i]
        if hasOutfit == outfit.onWalkOutfit or hasOutfit == outfit.onStandOutfit then
            if playerPosition.x ~= position.x or playerPosition.y ~= position.y or playerPosition.z ~= position.z then
                player:setOutfit({lookType = outfit.onWalkOutfit})
            else
                if hasOutfit == outfit.onStandOutfit then
                    break
                end

                player:setOutfit({lookType = outfit.onStandOutfit})
            end
        end
    end

    addEvent(changeOutfitOnMove, 100, player:getId(), playerPosition)
end
 
I added in login.lua and i'm have outfit 128 then when i walk it dont change to 129

-- ordered as in creaturescripts.xml
local events = {
'TutorialCockroach',
'ElementalSpheresOverlords',
'BigfootBurdenVersperoth',
'BigfootBurdenWarzone',
'BigfootBurdenWeeper',
'BigfootBurdenWiggler',
'SvargrondArenaKill',
'NewFrontierShardOfCorruption',
'NewFrontierTirecz',
'ServiceOfYalaharDiseasedTrio',
'ServiceOfYalaharAzerus',
'ServiceOfYalaharQuaraLeaders',
'InquisitionBosses',
'InquisitionUngreez',
'KillingInTheNameOfKills',
'MastersVoiceServants',
'PharaoKillPortal',
'SecretServiceBlackKnight',
'ThievesGuildNomad',
'WotELizardMagistratus',
'WotELizardNoble',
'WotEKeeper',
'WotEBosses',
'WotEZalamon',
'PlayerDeath',
'AdvanceSave'
}

function onLogin(player)
local loginStr = 'Welcome to ' .. configManager.getString(configKeys.SERVER_NAME) .. '!'
if player:getLastLoginSaved() <= 0 then
loginStr = loginStr .. ' Please choose your outfit.'
player:sendTutorial(1)
else
if loginStr ~= '' then
player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)
end


loginStr = string.format('Your last visit was on %s.', os.date('%a %b %d %X %Y', player:getLastLoginSaved()))
end
player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)

for i = 1, #events do
player:registerEvent(events)
end


local outfits = {
{onWalkOutfit = 128, onStandOutfit = 129},
{onWalkOutfit = 130, onStandOutfit = 131}
}

local function changeOutfitOnMove(cid, position)
local player = Player(cid)
if not player then
return false
end

local playerPosition, hasOutfit = player:getPosition(), player:getOutfit().lookType
local outfit
for i = 1, #outfits do
outfit = outfits
if hasOutfit == outfit.onWalkOutfit or hasOutfit == outfit.onStandOutfit then
if playerPosition.x ~= position.x or playerPosition.y ~= position.y or playerPosition.z ~= position.z then
player:setOutfit({lookType = outfit.onWalkOutfit})
else
if hasOutfit == outfit.onStandOutfit then
break
end

player:setOutfit({lookType = outfit.onStandOutfit})
end
end
end

addEvent(changeOutfitOnMove, 100, player:getId(), playerPosition)
end

return true
end
 
First of all, move the function over function onLogin(player)

And just add this inside over return true
Code:
changeOutfitOnMove(player:getId(), Position(0, 0, 0))
 

Similar threads

Back
Top