Olá,
Vou postar um tutorial de como criar um arquivo "Firstitems.lua", e vou explicar.
Para quem não sabe o "Firstitems.lua" serve para configurar os itens iniciais do player.
Bom, então vamos lá!
1º Passo:
Abra a pasta do seu servidor, vá em (Data/Creaturescripts/Scripts) e crie um arquivo chamado "Firstitems.lua", e adicione o seguinte código:
local firstItems = {} firstItems[0] = { 2383, 2525, 2647, 2173, 2457, 2463, 2643 } firstItems[1] = { 2190, 2525, 2647, 2173, 2457, 2463, 2643 } firstItems[2] = { 2182, 2525, 2647, 2173, 2457, 2463, 2643 } firstItems[3] = { 2389, 2525, 2647, 2173, 2457, 2463, 2643 } firstItems[4] = { 2383, 2525, 2647, 2173, 2457, 2463, 2643 } function onLogin(cid) if getPlayerStorageValue(cid, 30001) == -1 then for i = 1, table.maxn(firstItems[getPlayerVocation(cid)]) do doPlayerAddItem(cid, firstItems[getPlayerVocation(cid)][i], 1) end if getPlayerSex(cid) == 0 then doPlayerAddItem(cid, 2554, 1) else doPlayerAddItem(cid, 2120, 1) end local bag = doPlayerAddItem(cid, 10518, 1) doAddContainerItem(bag, 7620, 1) doAddContainerItem(bag, 7618, 1) doAddContainerItem(bag, 2160, 3) doAddContainerItem(bag, 2554, 1) setPlayerStorageValue(cid, 30001, 1) end return TRUE end
2º Passo:
Depois, vá em (Data/Creaturescript), abra o arquivo "Creaturescripts.xml" e adicione a seguinte tag:
<event type="login" name="FirstItems" event="script" value="firstitems.lua"/>
Pronto, agora vamos para a explicação.
Explicação:
local firstItems = {}
firstItems[0] = No Vocation (Sem Vocações) ou seja ACCOUNT MANAGER
{
Esses números são os id dos itens->2383, ou seja é uma-Spike Sword
2525, -Dwarven Shield
2647, -Plate Legs
2173, -Aol
2457, -Steel Helmeth
2463, -Plate Armor
2643 -Leather Boots
}
firstItems[1] = Sorcerer
{
2190, -Wand of Vortex
2525, -Dwarven Shield
2647, -Plate Legs
2173, -Aol
2457, -Steel Helmet
2463, -Plate Armor
2643 -Leather Boots
}
firstItems[2] = Druid
{
2182, -Snakebite Rod
2525, -Dwarven Shield
2647, -Plate Legs
2173, -Aol
2457, -Steel Helmet
2463, -Plate Armor
2643 -Leather Boots
}
firstItems[3] = Paladin
{
2389, -Spears
2525, -Dwarven Shield
2647, -Plate Legs
2173, -Aol
2457, -Steel Helmet
2463, -Plate Armor
2643 -Leather Boots
}
firstItems[4] = Knight
{
2383, -Spike Sword
2525, -Dwarven Shield
2647, -Plate Legs
2173, -Aol
2457, -Steel Helmet
2463, -Plate Armor
2643 -Leather Boots
}
function onLogin(cid)
if getPlayerStorageValue(cid, 30001) == -1 then
for i = 1, table.maxn(firstItems[getPlayerVocation(cid)]) do
doPlayerAddItem(cid, firstItems[getPlayerVocation(cid)], 1)
end
if getPlayerSex(cid) == 0 then
doPlayerAddItem(cid, 2554<- Shovel, 1)
else
doPlayerAddItem(cid, 2120<-Rope, 1)
end
local bag = doPlayerAddItem(cid, 10518, 1)
doAddContainerItem(bag, 7620<- Mana Potion,, 1)
doAddContainerItem(bag, 7618<-Health Potion,1)
doAddContainerItem(bag, 2160<-Crystal Coin, 3)
setPlayerStorageValue(cid, 30001, 1)
end
return TRUE
end
Se quiser adicionar mais coisas na backpack, adicione mais uma linha:
doAddContainerItem(bag,2383 <- ID DO ITEM,1 <- QUANTIDADE)
Espero que gostem do tutorial, feito por mim!
Demorei para fazer, mais fiz o meu melhor.
Quando comecei a mexer com otservs, eu precisava trocar os itens inicias dos players, eu procurei muito, até achei alguns tutoriais, mais nenhum explicava direito, por fim tive que aprende sozinho, então decidi criar esse tutorial para ajudar vocês!
Sugestões e criticas são bem vindas, comentem!