• 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.
 
You can set the outfits to default 0 in outfits.xml
Code:
 <outfit id="2" default="0">
Then add the outfits to the right vocations on login.
 
You can set the outfits to default 0 in outfits.xml
Code:
 <outfit id="2" default="0">
Then add the outfits to the right vocations on login.

How should it look like?


EDIT: NVM, I think that I got it :p
Will post again if I get stuck with something.
 
Last edited:
You can put this for example:

Code:
    <outfit id="1" quest="22222">
        <list gender="0" lookType="155" name="Pirate"/>
        <list gender="1" lookType="151" name="Pirate"/>
    </outfit>
Then, only players with storage ID 22222 will have this outfit.
Which means if you go to creaturescripts/scripts/login.lua and add:

Code:
local vocationNum = ## -- number of vocation that you want to have this Pirate outfit

if getPlayerVocation(cid) == vocationNum and getPlayerStorageValue(cid, 22222) < 0 then
setPlayerStorageValue(cid, 22222, 1)
end
So when any character logs in, this will check if he has the vocation and the appropriate outfit (storage) for it. If not, it will add it to him.
 
Thanks to both, tried it and it works, used this script to make it:
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
What do I have to change so it gives X outfit depending on the player's gender too?

EDIT:
If anyone knows what the problem is, I tried to promote myself and when I asked the NPC for promotion and it said that I dont have enough money, but he takes the 20k away. If I have less than 20k, it promotes me without taking it.
 
Last edited:
Thanks to both, tried it and it works, used this script to make it:
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
What do I have to change so it gives X outfit depending on the player's gender too?

EDIT:
If anyone knows what the problem is, I tried to promote myself and when I asked the NPC for promotion and it said that I dont have enough money, but he takes the 20k away. If I have less than 20k, it promotes me without taking it.

The script you posted is not going to unlock that outfit for the vocation permanently, it will just set it once the player logs in. Unless you want them to have 1 outfit all the time without any other outfit available to them, in which case this is ok.

Also post the other script so someone can take a look at it. Nobody can see the problem if we can't see the script :p
 
The script you posted is not going to unlock that outfit for the vocation permanently, it will just set it once the player logs in. Unless you want them to have 1 outfit all the time without any other outfit available to them, in which case this is ok.

Also post the other script so someone can take a look at it. Nobody can see the problem if we can't see the script :p

It's alright, I don't want it to be permanently anyway. It's meant to be like promoting from X vocation to Y vocation will give you a different outfit also, but you dont keep the older one. Now I just need so it gives different outfit depending on the player's gender.
About the NPC problem, I've found out whats wrong and it's fixed now. :D
 
How do I add that, dont get it o_O
If I put the looktype number where it says looktype, it will give him just that one that I added? Can I add 2 looktypes there or I must add that function twice? Don't get it much :confused:
Is it possible like making it so it loads the outfit ID from outfits.xml and use that for both male/female in that script?
 
Yeah, I am sorry. I just examined it and that wouldn't work that way. The best way to do it is to do what I wrote in my first post on this thread.

I will give you everything again -
The STORAGEID number that you put in this script is the same one referred to in the second script

This is for outfits.xml:

Code:
<outfit id="#" quest="STORAGEID1">
        <list gender="0" lookType="IDFemale" name="OutfitNameFemale"/>
        <list gender="1" lookType="IDMale" name="OutfitNameMale"/>
    </outfit>
<outfit id="#" quest="STORAGEID2">
        <list gender="0" lookType="IDFemale" name="OutfitNameFemale"/>
        <list gender="1" lookType="IDMale" name="OutfitNameMale"/>
    </outfit>

This is for the creaturescript:

Code:
local config =
{
[vocationID] = STORAGE1,
[vocationID] = STORAGE2
-- add more if needed
}

function onLogin(cid)
local hasObtained = #### -- Some storage that you want to use only in this script.

if getPlayerStorageValue(cid, hasObtained) == -1 then
    for k, v in pairs(config) do
        if getPlayerVocation(cid) == k then
            setPlayerStorageValue(cid, v, 1)
            setPlayerStorageValue(cid, hasObtained, 1)
        end
    end
end

return true
end
 
It works alright for genders now but if I promote a knight to elite knight, his outfit doesn't change:
Code:
    <outfit id="4" quest="4503">
        <list gender="0" lookType="139" name="Knight"/>
        <list gender="1" lookType="131" name="Knight"/>
    </outfit>

...

    <outfit id="7" quest="4504">
        <list gender="0" lookType="142" name="Warrior"/>
        <list gender="1" lookType="134" name="Warrior"/>
    </outfit>
Code:
local config =
{
[4] = 4503,
[8] = 4504,
[9] = 4501,
[10] = 4502
-- add more if needed
}

function onLogin(cid)
local hasObtained = 45000 -- Some storage that you want to use only in this script.

if getPlayerStorageValue(cid, hasObtained) == -1 then
    for k, v in pairs(config) do
        if getPlayerVocation(cid) == k then
            setPlayerStorageValue(cid, v, 1)
            setPlayerStorageValue(cid, hasObtained, 1)
        end
    end
end

return true
end

Code:
[9] = 4501,
[10] = 4502
This is for a custom vocation, also doesn't work when promoting.
 
Add this to your login.lua file or post it if it dosen't work.
Code:
    local outfits = {
        [4] = id,
        [8] = id,
        [9] = id,
        [10] = id
    }

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

Always use ~= 1 insted of < 1 and NEVER EVER EVER use ANOTHER file when you can just as easy merge them into one.

And remember to change your table to use outfit ids insted of the storage value(you can find them in your outfits.xml file).
 
Its just plain stupid its the same thing like opening another beer when one is already opened? It would just put more stress on the server dosen't matter how big the stress is to load another script insted of loading one.
Trust me ive changed almost every script from the github project and my server has decreased alot with cpu usage and ram usage, especially globalevents and creaturescripts.
 
Add this to your login.lua file or post it if it dosen't work.
Code:
    local outfits = {
        [4] = id,
        [8] = id,
        [9] = id,
        [10] = id
    }

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

Always use ~= 1 insted of < 1 and NEVER EVER EVER use ANOTHER file when you can just as easy merge them into one.

And remember to change your table to use outfit ids insted of the storage value(you can find them in your outfits.xml file).

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.
 
Last edited:
Back
Top