• 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 First Items not stable

MaR0

Banned User
Joined
Apr 16, 2018
Messages
272
Solutions
3
Reaction score
29
Using tfs 0.3.7_svn. Sometimes when players make new characters the first items won't be taken dunno why? if there something wrong please post below the correct would be nice :).
here is the script that i follow
XML:
<event type="login" name="FirstItems" event="script" value="first items.lua"/>
Lua:
local SORCERER = 1
local DRUID = 2
local PALADIN = 3
local KNIGHT = 4

local items =
{
    [SORCERER] =
    {
         {item=1988, count=1}, -- backpack
        {item=7462, count=1}, --helmet
        {item=2138, count=1}, -- an amulet (for test purpose)
         {item=2121, count=1}, -- ring
         {item=2190, count=1}, -- staff
         {item=2361, count=1}, --frozen
         {item=7460, count=1}, ---shield
         {item=7463, count=1}, ---armor
         {item=7464, count=1}, ---legs
         {item=2643, count=1} ---boots
    },
    [DRUID] =
    {
        {item=1988, count=1}, -- backpack
        {item=7462, count=1}, --helmet
        {item=2138, count=1}, -- an amulet (for test purpose)
         {item=2121, count=1}, -- ring
         {item=2190, count=1}, -- staff
         {item=2361, count=1}, --frozen
         {item=7460, count=1}, ---shield
         {item=7463, count=1}, ---armor
         {item=7464, count=1}, ---legs
         {item=2643, count=1} ---boots
    },
    [PALADIN] =
    {
        {item=1988, count=1}, -- backpack
        {item=7462, count=1}, --helmet
        {item=2138, count=1}, -- an amulet (for test purpose)
         {item=2121, count=1}, -- ring
         {item=2543, count=1}, -- bolt
          {item=2455, count=1}, -- bolt
         {item=2361, count=1}, --frozen
         {item=7460, count=1}, ---shield
         {item=7463, count=1}, ---armor
         {item=2643, count=1}, ---boots
         {item=7464, count=1} ---legs
    },
    [KNIGHT] =
    {
       {item=1988, count=1}, -- backpack
        {item=7462, count=1}, --helmet
        {item=2138, count=1}, -- an amulet (for test purpose)
         {item=2121, count=1}, -- ring
         {item=2383, count=1}, -- sword
         {item=2361, count=1}, --frozen
         {item=7460, count=1}, ---shield
         {item=7463, count=1}, ---armor
         {item=2643, count=1}, ---boots
         {item=7464, count=1} ---legs
    }
}

function onLogin(cid)
    local vocation = items[getPlayerVocation(cid)]
    if(not vocation) then
        return true
    end

    local storage = getPlayerStorageValue(cid, 30001)
    if(storage > 0) then
        return true
    end

    for _, voc in ipairs(vocation) do
        doPlayerAddItem(cid, voc.item, voc.count)
    end

    setPlayerStorageValue(cid, 30001, 1)
     return true
end
in login.lua:-
Lua:
registerCreatureEvent(cid, "FirstItems")
 
You should start by debugging each part of the script, new characters most likely have promoted vocations and that's why the script exits return true. Post what you get on console.
Lua:
local SORCERER = 1
local DRUID = 2
local PALADIN = 3
local KNIGHT = 4

local items =
{
    [SORCERER] =
    {
        {item=1988, count=1}, -- backpack
            {item=7462, count=1}, --helmet
            {item=2138, count=1}, -- an amulet (for test purpose)
            {item=2121, count=1}, -- ring
            {item=2190, count=1}, -- staff
            {item=2361, count=1}, --frozen
            {item=7460, count=1}, ---shield
            {item=7463, count=1}, ---armor
            {item=7464, count=1}, ---legs
            {item=2643, count=1} ---boots
    },
    [DRUID] =
    {
            {item=1988, count=1}, -- backpack
            {item=7462, count=1}, --helmet
            {item=2138, count=1}, -- an amulet (for test purpose)
            {item=2121, count=1}, -- ring
            {item=2190, count=1}, -- staff
            {item=2361, count=1}, --frozen
            {item=7460, count=1}, ---shield
            {item=7463, count=1}, ---armor
            {item=7464, count=1}, ---legs
            {item=2643, count=1} ---boots
    },
    [PALADIN] =
    {
            {item=1988, count=1}, -- backpack
            {item=7462, count=1}, --helmet
            {item=2138, count=1}, -- an amulet (for test purpose)
            {item=2121, count=1}, -- ring
            {item=2543, count=1}, -- bolt
            {item=2455, count=1}, -- bolt
            {item=2361, count=1}, --frozen
            {item=7460, count=1}, ---shield
            {item=7463, count=1}, ---armor
            {item=2643, count=1}, ---boots
            {item=7464, count=1} ---legs
    },
    [KNIGHT] =
    {
            {item=1988, count=1}, -- backpack
            {item=7462, count=1}, --helmet
            {item=2138, count=1}, -- an amulet (for test purpose)
            {item=2121, count=1}, -- ring
            {item=2383, count=1}, -- sword
            {item=2361, count=1}, --frozen
            {item=7460, count=1}, ---shield
            {item=7463, count=1}, ---armor
            {item=2643, count=1}, ---boots
            {item=7464, count=1} ---legs
    }
}

function onLogin(cid)
    local vocation = items[getPlayerVocation(cid)]
    if(not vocation) then
            print("[ERROR]: vocation not found.")
        return true
    end

    local storage = getPlayerStorageValue(cid, 30001)
    if(storage > 0) then
            print("[ERROR]: storage is already on player.")
        return true
    end

    for _, voc in ipairs(vocation) do
        doPlayerAddItem(cid, voc.item, voc.count)
    end

    setPlayerStorageValue(cid, 30001, 1)
     return true
end
 
You should start by debugging each part of the script, new characters most likely have promoted vocations and that's why the script exits return true. Post what you get on console.
Lua:
local SORCERER = 1
local DRUID = 2
local PALADIN = 3
local KNIGHT = 4

local items =
{
    [SORCERER] =
    {
        {item=1988, count=1}, -- backpack
            {item=7462, count=1}, --helmet
            {item=2138, count=1}, -- an amulet (for test purpose)
            {item=2121, count=1}, -- ring
            {item=2190, count=1}, -- staff
            {item=2361, count=1}, --frozen
            {item=7460, count=1}, ---shield
            {item=7463, count=1}, ---armor
            {item=7464, count=1}, ---legs
            {item=2643, count=1} ---boots
    },
    [DRUID] =
    {
            {item=1988, count=1}, -- backpack
            {item=7462, count=1}, --helmet
            {item=2138, count=1}, -- an amulet (for test purpose)
            {item=2121, count=1}, -- ring
            {item=2190, count=1}, -- staff
            {item=2361, count=1}, --frozen
            {item=7460, count=1}, ---shield
            {item=7463, count=1}, ---armor
            {item=7464, count=1}, ---legs
            {item=2643, count=1} ---boots
    },
    [PALADIN] =
    {
            {item=1988, count=1}, -- backpack
            {item=7462, count=1}, --helmet
            {item=2138, count=1}, -- an amulet (for test purpose)
            {item=2121, count=1}, -- ring
            {item=2543, count=1}, -- bolt
            {item=2455, count=1}, -- bolt
            {item=2361, count=1}, --frozen
            {item=7460, count=1}, ---shield
            {item=7463, count=1}, ---armor
            {item=2643, count=1}, ---boots
            {item=7464, count=1} ---legs
    },
    [KNIGHT] =
    {
            {item=1988, count=1}, -- backpack
            {item=7462, count=1}, --helmet
            {item=2138, count=1}, -- an amulet (for test purpose)
            {item=2121, count=1}, -- ring
            {item=2383, count=1}, -- sword
            {item=2361, count=1}, --frozen
            {item=7460, count=1}, ---shield
            {item=7463, count=1}, ---armor
            {item=2643, count=1}, ---boots
            {item=7464, count=1} ---legs
    }
}

function onLogin(cid)
    local vocation = items[getPlayerVocation(cid)]
    if(not vocation) then
            print("[ERROR]: vocation not found.")
        return true
    end

    local storage = getPlayerStorageValue(cid, 30001)
    if(storage > 0) then
            print("[ERROR]: storage is already on player.")
        return true
    end

    for _, voc in ipairs(vocation) do
        doPlayerAddItem(cid, voc.item, voc.count)
    end

    setPlayerStorageValue(cid, 30001, 1)
     return true
end
nothing appear on my console, i'm using the correct vocations
edit i will try to use this
 
You should start by debugging each part of the script, new characters most likely have promoted vocations and that's why the script exits return true. Post what you get on console.
Lua:
local SORCERER = 1
local DRUID = 2
local PALADIN = 3
local KNIGHT = 4

local items =
{
    [SORCERER] =
    {
        {item=1988, count=1}, -- backpack
            {item=7462, count=1}, --helmet
            {item=2138, count=1}, -- an amulet (for test purpose)
            {item=2121, count=1}, -- ring
            {item=2190, count=1}, -- staff
            {item=2361, count=1}, --frozen
            {item=7460, count=1}, ---shield
            {item=7463, count=1}, ---armor
            {item=7464, count=1}, ---legs
            {item=2643, count=1} ---boots
    },
    [DRUID] =
    {
            {item=1988, count=1}, -- backpack
            {item=7462, count=1}, --helmet
            {item=2138, count=1}, -- an amulet (for test purpose)
            {item=2121, count=1}, -- ring
            {item=2190, count=1}, -- staff
            {item=2361, count=1}, --frozen
            {item=7460, count=1}, ---shield
            {item=7463, count=1}, ---armor
            {item=7464, count=1}, ---legs
            {item=2643, count=1} ---boots
    },
    [PALADIN] =
    {
            {item=1988, count=1}, -- backpack
            {item=7462, count=1}, --helmet
            {item=2138, count=1}, -- an amulet (for test purpose)
            {item=2121, count=1}, -- ring
            {item=2543, count=1}, -- bolt
            {item=2455, count=1}, -- bolt
            {item=2361, count=1}, --frozen
            {item=7460, count=1}, ---shield
            {item=7463, count=1}, ---armor
            {item=2643, count=1}, ---boots
            {item=7464, count=1} ---legs
    },
    [KNIGHT] =
    {
            {item=1988, count=1}, -- backpack
            {item=7462, count=1}, --helmet
            {item=2138, count=1}, -- an amulet (for test purpose)
            {item=2121, count=1}, -- ring
            {item=2383, count=1}, -- sword
            {item=2361, count=1}, --frozen
            {item=7460, count=1}, ---shield
            {item=7463, count=1}, ---armor
            {item=2643, count=1}, ---boots
            {item=7464, count=1} ---legs
    }
}

function onLogin(cid)
    local vocation = items[getPlayerVocation(cid)]
    if(not vocation) then
            print("[ERROR]: vocation not found.")
        return true
    end

    local storage = getPlayerStorageValue(cid, 30001)
    if(storage > 0) then
            print("[ERROR]: storage is already on player.")
        return true
    end

    for _, voc in ipairs(vocation) do
        doPlayerAddItem(cid, voc.item, voc.count)
    end

    setPlayerStorageValue(cid, 30001, 1)
     return true
end
ohh i didn't include
Code:
registerCreatureEvent(cid, "FirstItems")
in my login file thanks for help anyway :) appreciated
 
Back
Top