Servidor 12x First Items

O

Ozzwelito

Invitado
Hola buen dia, alguien tiene algun codigo para dar los primeros items del juego a los nuevos players? he intentado con algunos pero ninguno me funciona, los players puede elegir su vocacion en la pagina y la ciudad a donde quieren aparecer, este es el codigo que estaba usando pero no me funciona:

Código:
local config = {
    [1] = { -- sorcerer
        items = {
            {2525}, -- dwarven shield
            {2190}, -- wand of vortex
            {8819}, -- magician's robe
            {8820}, -- mage hat
            {2478}, -- brass legs
            {2643}, -- leather boots
        },
        backpack = {
            {7620, 15}, -- mana potion
            {2120}, -- rope
        }
    },
    [2] = { -- druid
        items = {
            {2525}, -- dwarven shield
            {2182}, -- snakebite rod
            {8819}, -- magician's robe
            {8820}, -- mage hat
            {2478}, -- brass legs
            {2643}, -- leather boots
        },
        backpack = {
            {7620, 15}, -- mana potion
            {2120}, -- rope
        }
    },
    [3] = { -- paladin
        items = {
            {2525}, -- dwarven shield
            {2389, 5}, -- spear
            {2660}, -- ranger's cloak
            {8923}, -- ranger legs
            {2643}, -- leather boots
            {2121}, -- wedding ring
            {2460}, -- brass helmet
        },
        backpack = {
            {7618, 10}, -- health potion
            {7620, 10}, -- mana potion
            {2120}, -- rope
        }
    },
    [4] = { -- knight
        items = {
            {2525}, -- dwarven shield
            {8602}, -- jagged sword
            {2465}, -- brass armor
            {2460}, -- brass helmet
            {2478}, -- brass legs
            {2643}, -- leather boots
        },
        backpack = {
            {8601}, -- steel axe
            {2439}, -- daramian mace
            {7618, 5}, -- health potion
            {7620, 5}, -- mana potion
            {2120}, -- rope
        }
    }
}

function onLogin(player)
    player:registerEvent("firstItems")
    local targetVocation = config[player:getVocation():getId()]
    if not targetVocation then
        return true
    end

    if player:getLastLoginSaved() ~= 0 then
        return true
    end

    if player:getSlotItem(CONST_SLOT_LEFT) then
        return true
    end

    for i = 1, #targetVocation.items do
        player:addItem(targetVocation.items[i][1], targetVocation.items[i][2] or 1)
    end

    local demonBackpack = player:addItem(10518) -- demon backpack
    if not demonBackpack then
        return true
    end

    for i = 1, #targetVocation.backpack do
        demonBackpack:addItem(targetVocation.backpack[i][1], targetVocation.backpack[i][2] or 1, false)
    end
    return true
end

si me pudieran apoyar por favor
 

Alex

Miembro del equipo
Webdesigner
LV
58
 
Awards
38
Hola buen dia, alguien tiene algun codigo para dar los primeros items del juego a los nuevos players? he intentado con algunos pero ninguno me funciona, los players puede elegir su vocacion en la pagina y la ciudad a donde quieren aparecer, este es el codigo que estaba usando pero no me funciona:

Código:
local config = {
    [1] = { -- sorcerer
        items = {
            {2525}, -- dwarven shield
            {2190}, -- wand of vortex
            {8819}, -- magician's robe
            {8820}, -- mage hat
            {2478}, -- brass legs
            {2643}, -- leather boots
        },
        backpack = {
            {7620, 15}, -- mana potion
            {2120}, -- rope
        }
    },
    [2] = { -- druid
        items = {
            {2525}, -- dwarven shield
            {2182}, -- snakebite rod
            {8819}, -- magician's robe
            {8820}, -- mage hat
            {2478}, -- brass legs
            {2643}, -- leather boots
        },
        backpack = {
            {7620, 15}, -- mana potion
            {2120}, -- rope
        }
    },
    [3] = { -- paladin
        items = {
            {2525}, -- dwarven shield
            {2389, 5}, -- spear
            {2660}, -- ranger's cloak
            {8923}, -- ranger legs
            {2643}, -- leather boots
            {2121}, -- wedding ring
            {2460}, -- brass helmet
        },
        backpack = {
            {7618, 10}, -- health potion
            {7620, 10}, -- mana potion
            {2120}, -- rope
        }
    },
    [4] = { -- knight
        items = {
            {2525}, -- dwarven shield
            {8602}, -- jagged sword
            {2465}, -- brass armor
            {2460}, -- brass helmet
            {2478}, -- brass legs
            {2643}, -- leather boots
        },
        backpack = {
            {8601}, -- steel axe
            {2439}, -- daramian mace
            {7618, 5}, -- health potion
            {7620, 5}, -- mana potion
            {2120}, -- rope
        }
    }
}

function onLogin(player)
    player:registerEvent("firstItems")
    local targetVocation = config[player:getVocation():getId()]
    if not targetVocation then
        return true
    end

    if player:getLastLoginSaved() ~= 0 then
        return true
    end

    if player:getSlotItem(CONST_SLOT_LEFT) then
        return true
    end

    for i = 1, #targetVocation.items do
        player:addItem(targetVocation.items[i][1], targetVocation.items[i][2] or 1)
    end

    local demonBackpack = player:addItem(10518) -- demon backpack
    if not demonBackpack then
        return true
    end

    for i = 1, #targetVocation.backpack do
        demonBackpack:addItem(targetVocation.backpack[i][1], targetVocation.backpack[i][2] or 1, false)
    end
    return true
end

si me pudieran apoyar por favor

Hola, en este caso, será que estás utilizando una version 12x, que utiliza un sistema de revscripts, por lo cual ya no detiene archivos .xml como actions, movements, etc.

Debes de este caso adaptar algunos scripts, aquí lo tienes:


Código:
local creatureevent = CreatureEvent("FirstItems")

local config = {
    [1] = { -- Sorcerer
        items = {
            {2175, 1}, -- spellbook
            {2190, 1}, -- wand of vortex
            {8819, 1}, -- magician's robe
            {8820, 1}, -- mage hat
            {2468, 1}, -- studded legs
            {2643, 1}, -- leather boots
            {2661, 1}  -- scarf
        },
        container = {
            {2120, 1}, -- rope
            {2554, 1}, -- shovel
            {7620, 1}  -- mana potion
        }
    },
    [2] = { -- Druid
        items = {
            {2175, 1}, -- spellbook
            {2182, 1}, -- snakebite rod
            {8819, 1}, -- magician's robe
            {8820, 1}, -- mage hat
            {2468, 1}, -- studded legs
            {2643, 1}, -- leather boots
            {2661, 1}  -- scarf
        },
        container = {
            {2120, 1}, -- rope
            {2554, 1}, -- shovel
            {7620, 1}  -- mana potion
        }
    },
    [3] = { -- Paladin
        items = {
            {2525, 1}, -- dwarven shield
            {2389, 5}, -- 5 spears
            {2660, 1}, -- ranger's cloak
            {8923, 1}, -- ranger legs
            {2643, 1}, -- leather boots
            {2661, 1}, -- scarf
            {2480, 1}  -- legion helmet
        },
        container = {
            {2120, 1},  -- rope
            {2554, 1},  -- shovel
            {7618, 1},  -- health potion
            {2456, 1},  -- bow
            {2544, 50}  -- 50 arrows
        }
    },
    [4] = { -- Knight
        items = {
            {2525, 1}, -- dwarven shield
            {8601, 1}, -- steel axe
            {2465, 1}, -- brass armor
            {2460, 1}, -- brass helmet
            {2478, 1}, -- brass legs
            {2643, 1}, -- leather boots
            {2661, 1}  -- scarf
        },
        container = {
            {8602, 1}, -- jagged sword
            {2439, 1}, -- daramanian mace
            {2120, 1}, -- rope
            {2554, 1}, -- shovel
            {7618, 1}  -- health potion
        }
    },
    [9] = { -- Crusader
        items = {
            {2525, 1}, -- dwarven shield
            {8601, 1}, -- steel axe
            {2465, 1}, -- brass armor
            {2460, 1}, -- brass helmet
            {2478, 1}, -- brass legs
            {2643, 1}, -- leather boots
            {2661, 1}  -- scarf
        },
        container = {
            {8602, 1}, -- jagged sword
            {2439, 1}, -- daramanian mace
            {2120, 1}, -- rope
            {2554, 1}, -- shovel
            {7618, 1}  -- health potion
        }
    }
}

function creatureevent.onLogin(player)
    local targetVocation = config[player:getVocation():getId()]
    if not targetVocation then
        return true
    end

    if player:getLastLoginSaved() ~= 0 then
        return true
    end

    for i = 1, #targetVocation.items do
        player:addItem(targetVocation.items[i][1], targetVocation.items[i][2])
    end

    local backpack = player:addItem(1988) -- backpack
    if not backpack then
        return true
    end

    for i = 1, #targetVocation.container do
        backpack:addItem(targetVocation.container[i][1], targetVocation.container[i][2])
    end
    return true
end

creatureevent:register()
 
Arriba