• 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 Outfits per vocation

70011983

Ners
Joined
Nov 21, 2011
Messages
354
Solutions
1
Reaction score
56
Location
Croatia
Hello,
how do I make so a certain vocation has a specific outfit? I mean like, paladin will have ONLY hunter outfit, knight will have ONLY warrior/barbarian etc..
Tried to do it myself but I didn't get any further yet, found several same threads but that wasn't really helpful.
 
If I remove the script that I earlier posted that didnt fully work this is what I get:
Code:
[10/06/2014 12:55:08] [Error - CreatureScript Interface]
[10/06/2014 12:55:08] data/creaturescripts/scripts/login.lua:onLogin
[10/06/2014 12:55:08] Description:
[10/06/2014 12:55:08] (luaDoPlayerAddOutfit) Player not found

If I put it back and +this, no error (it does appear), the player can pick any of the 4 outfit that have the "quest" thing on it.
try this I don't test it

Code:
 local KnightfemaleOutfits = { ["Knight"]={131}}
local knightmaleOutfits = { ["Knight"]={139} }
  local femaleOutfits = { ["warrior"]={134} }
   local maleOutfits = { ["warrior"]={142} }
    local param = string.lower(param)
function onLogin(cid)
registerCreatureEvent(cid, "vocation addon")
--- local current = getCreatureOutfit(cid)
return onOutfit(cid, {lookAddons = 1}, getCreatureOutfit(cid)) and true
end

function onOutfit(cid, old, current)
if getPlayerAccess(cid) >= 4 then
return print("Staff/support can't get any vocation addon") and true
end
if getPlayerStorageValue(player, 4504) == 1 then
  if(getPlayerSex(cid) == 0)then
  doPlayerAddOutfit(cid, KnightfemaleOutfits,1)
            else
              doPlayerAddOutfit(cid, knightmaleOutfits, 3)
            end
             if getPlayerStorageValue(player, 4503) == 1 then
  if(getPlayerSex(cid) == 0)then
  doPlayerAddOutfit(cid, KnightfemaleOutfits,1)
            else
              doPlayerAddOutfit(cid, knightmaleOutfits, 3)
            end
 
Add this to your login.lua file or post it if it dosen't work.

try this I don't test it

Code:
 local KnightfemaleOutfits = { ["Knight"]={131}}
local knightmaleOutfits = { ["Knight"]={139} }
  local femaleOutfits = { ["warrior"]={134} }
   local maleOutfits = { ["warrior"]={142} }
    local param = string.lower(param)
function onLogin(cid)
registerCreatureEvent(cid, "vocation addon")
--- local current = getCreatureOutfit(cid)
return onOutfit(cid, {lookAddons = 1}, getCreatureOutfit(cid)) and true
end

function onOutfit(cid, old, current)
if getPlayerAccess(cid) >= 4 then
return print("Staff/support can't get any vocation addon") and true
end
if getPlayerStorageValue(player, 4504) == 1 then
  if(getPlayerSex(cid) == 0)then
  doPlayerAddOutfit(cid, KnightfemaleOutfits,1)
            else
              doPlayerAddOutfit(cid, knightmaleOutfits, 3)
            end
             if getPlayerStorageValue(player, 4503) == 1 then
  if(getPlayerSex(cid) == 0)then
  doPlayerAddOutfit(cid, KnightfemaleOutfits,1)
            else
              doPlayerAddOutfit(cid, knightmaleOutfits, 3)
            end

Damn worst tabbing of the year? \o/
And why would you print the message insted of using doPlayerSendTextMessage or doPlayerSendCancel?
And the best thing, he wanted a certin outfit per vocation not per sex.
Go read this thread: http://otland.net/threads/how-to-tab-lua-scripts.203763/ before "helping" with any other scripts.
And also decide if you wanna use if() then or if then, its just a mess if you use both.
 
Doesn't work:
Code:
[18/06/2014 20:55:07] [Error - CreatureScript Interface] 
[18/06/2014 20:55:07] data/creaturescripts/scripts/login.lua:onLogin
[18/06/2014 20:55:07] Description: 
[18/06/2014 20:55:07] (luaDoPlayerAddOutfit) Player not found
login.lua:
Code:
local config = {
    loginMessage = getConfigValue('loginMessage'),
    useFragHandler = getBooleanFromString(getConfigValue('useFragHandler'))
}

function onLogin(cid)
    local loss = getConfigValue('deathLostPercent')
    if(loss ~= nil) then
        doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
    end

    local accountManager = getPlayerAccountManager(cid)
    if(accountManager == MANAGER_NONE) then
        local lastLogin, str = getPlayerLastLoginSaved(cid), config.loginMessage
        if(lastLogin > 0) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
            str = "Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
        else
            str = str .. " Please choose your outfit."
            doPlayerSendOutfitWindow(cid)
        end

        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
    elseif(accountManager == MANAGER_NAMELOCK) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, it appears that your character has been namelocked, what would you like as your new name?")
    elseif(accountManager == MANAGER_ACCOUNT) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to manage your account and if you want to start over then type 'cancel'.")
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to create an account or type 'recover' to recover an account.")
    end

    if(not isPlayerGhost(cid)) then
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
    end

    registerCreatureEvent(cid, "Mail")
    registerCreatureEvent(cid, "GuildMotd")

    registerCreatureEvent(cid, "Idle")
    if(config.useFragHandler) then
        registerCreatureEvent(cid, "SkullCheck")
    end
  

    local outfits = {
        [1] = 3,
        [2] = 9,
        [3] = 2,
        [4] = 4,
        [9] = 38,  
      
        [5] = 10,
        [6] = 6,
        [7] = 13,
        [8] = 7,
        [10] = 39  
    }

    if(getPlayerStorageValue(cid, 55000) ~= 1) then
        doPlayerAddOutfit(cid, outfits[getPlayerVocation(cid)])
        setPlayerStorageValue(cid, 5500, 1)
    end  

    registerCreatureEvent(cid, "ReportBug")
    registerCreatureEvent(cid, "AdvanceSave")
    registerCreatureEvent(cid, "death")
    registerCreatureEvent(cid, "login")
    return true
end

BTW, if I add the one you said in login.lua, do I have to remove the one in creaturescripts?
 
Last edited:
Code:
local config = {
    loginMessage = getConfigValue('loginMessage'),
    useFragHandler = getBooleanFromString(getConfigValue('useFragHandler'))
}

function onLogin(cid)
    local loss = getConfigValue('deathLostPercent')
    if(loss ~= nil) then
        doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
    end

    local accountManager = getPlayerAccountManager(cid)
    if(accountManager == MANAGER_NONE) then
        local lastLogin, str = getPlayerLastLoginSaved(cid), config.loginMessage
        if(lastLogin > 0) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
            str = "Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
        else
            local outfits = {
                [1] = 3,
                [2] = 9,
                [3] = 2,
                [4] = 4,
                [9] = 38,  
             
                [5] = 10,
                [6] = 6,
                [7] = 13,
                [8] = 7,
                [10] = 39  
            }

            if(getPlayerStorageValue(cid, 55000) ~= 1) then
                doPlayerAddOutfit(cid, outfits[getPlayerVocation(cid)])
                setPlayerStorageValue(cid, 5500, 1)
            end
            str = str .. " Please choose your outfit."
            doPlayerSendOutfitWindow(cid)
        end

        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
    elseif(accountManager == MANAGER_NAMELOCK) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, it appears that your character has been namelocked, what would you like as your new name?")
    elseif(accountManager == MANAGER_ACCOUNT) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to manage your account and if you want to start over then type 'cancel'.")
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to create an account or type 'recover' to recover an account.")
    end

    if(not isPlayerGhost(cid)) then
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
    end

    registerCreatureEvent(cid, "Mail")
    registerCreatureEvent(cid, "GuildMotd")

    registerCreatureEvent(cid, "Idle")
    if(config.useFragHandler) then
        registerCreatureEvent(cid, "SkullCheck")
    end

    registerCreatureEvent(cid, "ReportBug")
    registerCreatureEvent(cid, "AdvanceSave")
    registerCreatureEvent(cid, "death")
    registerCreatureEvent(cid, "login")
    return true
end

This way the player only gets his outfit when s/he first login, change the config value for allow change outfit or something like that to false.
Before the else in the if statment.
 
Im getting this error when making a new char:
Code:
[18/06/2014 22:37:21] [Error - CreatureScript Interface] 
[18/06/2014 22:37:21] data/creaturescripts/scripts/login.lua:onLogin
[18/06/2014 22:37:21] Description: 
[18/06/2014 22:37:21] (luaDoPlayerAddOutfit) Player not found
And it gives them just a citizen outfit.
 
Missing parameter for addons (0, 1, 2 or 3 for both).
Code:
doPlayerAddOutfit(cid, looktype, addons)
For adding outfit ids use doPlayerAddOutfitId, when you use doPlayerAddOutfit use the looktype you want to add.
Code:
doPlayerAddOutfitId(cid, outfitid, addons)
 
Missing parameter for addons (0, 1, 2 or 3 for both).
Code:
doPlayerAddOutfit(cid, looktype, addons)
For adding outfit ids use doPlayerAddOutfitId, when you use doPlayerAddOutfit use the looktype you want to add.
Code:
doPlayerAddOutfitId(cid, outfitid, addons)
I can't make it work. There is no error now but the player doesnt get the outfit for some reason.
What tfs are you using?
Crying Damson 0.3.6
 
If you want to add the outfit by using doPlayerAddOutfit or doPlayerAddOutfitId, then use default="0" in outfits.xml.
If you want to add the outfits by storage, then use quest (or storageId and storageValue for a specific value, with quest the storagevalue should be 1) in outfits.xml.

Btw, The storage numbers aren't the same (55000 and 5500).
 
I can't make it work. There is no error now but the player doesnt get the outfit for some reason.

Crying Damson 0.3.6
As I said that script will only work THE FIRST TIME the player loggs in. If you rather want to doCreatureChangeOutfit the outfit you should use xx insted and move it to the else statment.
 
It shouldn't work just for the first time, once the player gets promoted his outfit changes and doesn't keep the older one.
What do you mean about "xx"? Dont get it.
 
Ye was abit drunk last night, you wanna use doCreatureChangeOutfit insted of doPlayerAddOutfit.
But I still don't get it, once the player is promoted he should get another outfit? In that case you shoulden't use the script I wrote for you. That will give the player his outfit once so he at a later point can change his outfit.
What you wanna do is use doCreatureChangeOutfit at the first login and then set the config value allowedToChangeOutfits or something like that to false. And then the king or w/e should set the new outfit with the same function.
 
At first I tried using this:
Code:
local config =
{
[0] = 136,
[4] = 131,
[9] = 25,
[10] = 29
}

function onLogin(cid)
local outfit = getCreatureOutfit(cid)
outfit.lookType = config[getPlayerVocation(cid)]

doCreatureChangeOutfit(cid, outfit)
return true
end
And it works alright, the player gets the outfit and once promoted he gets a new one and loses the old one. But how do I make so it uses outfit ID's instead lookTypes?
 
Why do you want to use outfit ids? If it's for different looktypes for male/female you can check for gender.
Code:
if getPlayerSex(cid) == 0 then
0 is female and 1 is male.
 
Because of different looktypes for male/female. How do I use that function :p?
I mean, do I have to add this twice one for male outfits and one for female? (with different looktypes)
Code:
local config =
{
[0] = 136,
[4] = 131,
[9] = 25,
[10] = 29
}
 
Code:
local outfit = getCreatureOutfit(cid)
if getPlayerSex(cid) == 0 then
     outfit.lookType = config[getPlayerVocation(cid)][1]
else
     outfit.lookType = config[getPlayerVocation(cid)][2]
end
doCreatureChangeOutfit(cid, outfit)

Then in the table, instead of "[0] = 136,", add a table with the second lookType.
Code:
[0] = {136, 128},
 
What are those [1] and [2] for?
Right now this is how it looks like for me, what Im missing? I can't log in.
Code:
local config =
{
[1] = {130,145},
[2] = {144,133},
[3] = {129,152},
[4] = {131,134},
[9] = {25,29}
}

function onLogin(cid)
local outfit = getCreatureOutfit(cid)
if getPlayerSex(cid) == 0 then
     outfit.lookType = config[getPlayerVocation(cid)][1]
else
     outfit.lookType = config[getPlayerVocation(cid)][2]
end
doCreatureChangeOutfit(cid, outfit)
end
 
Back
Top