• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Make Creaturescript Faster.

DukeeH

Active Member
Joined
Dec 6, 2010
Messages
550
Solutions
3
Reaction score
39
How to make this script faster? (it is too slow the first login of new characters)
LUA:
function onLogin(cid)
local playerVoc = getPlayerVocation(cid)
local reqTries = getPlayerRequiredSkillTries
local skillStor = 56364
local gotSkills = getPlayerStorageValue(cid, 56364)


if playerVoc == 5 and gotSkills == -1 then
	doPlayerAddMagLevel(cid, 55)
setPlayerStorageValue(cid, skillStor, 1)

elseif playerVoc == 6 and gotSkills == -1 then
	doPlayerAddMagLevel(cid, 55)
setPlayerStorageValue(cid, skillStor, 1)

elseif playerVoc == 7 and gotSkills == -1 then
doPlayerAddSkillTry(cid, SKILL_DISTANCE, reqTries(cid, SKILL_DISTANCE, 70))
doPlayerAddSkillTry(cid, SKILL_SHIELD, reqTries(cid, SKILL_SHIELD, 70))
	doPlayerAddMagLevel(cid, 18)
setPlayerStorageValue(cid, skillStor, 1)

elseif playerVoc == 8 and gotSkills == -1 then
doPlayerAddSkillTry(cid, SKILL_AXE, reqTries(cid, SKILL_AXE, 70))
doPlayerAddSkillTry(cid, SKILL_SWORD, reqTries(cid, SKILL_SWORD, 70))
doPlayerAddSkillTry(cid, SKILL_CLUB, reqTries(cid, SKILL_CLUB, 70))
doPlayerAddSkillTry(cid, SKILL_SHIELD, reqTries(cid, SKILL_SHIELD, 70))
	doPlayerAddMagLevel(cid, 12)
setPlayerStorageValue(cid, skillStor, 1)

end
return TRUE
end

Thanks.
DukeeH,
 
Last edited:
tried this one?
LUA:
  local commonItems = {
  -- ITEMS ALL VOCS RECEIVE
  {itemid=2120, count=1}, -- rope
  {itemid=2160, count=1}, -- cristal coin
  {itemid=5710, count=1}, -- shovel
  {itemid=2420, count=1}, -- machete
  {itemid=2789, count=100}, -- brown mushrooms
  {itemid=2305, count=1}, -- fire bomb rune
  {itemid=2261, count=1}, -- destroy field rune
}

local firstItems = {
  { -- SORC ITEMS
    {itemid=2323, count=1}, -- hat of the mad
    {itemid=8871, count=1}, -- focus cape
    {itemid=7730, count=1}, -- blue legs
    {itemid=2195, count=1}, -- boots of haste
    {itemid=8902, count=1}, -- spellbook of mind control
    {itemid=2187, count=1}, -- wand of inferno  

    {itemid=2268, count=1}, -- sd
    {itemid=2273, count=1}, -- uh
    {itemid=7590, count=1}, -- gmp
    {itemid=2293, count=1}, -- mw
  },
  { -- DRUID ITEMS
    {itemid=2323, count=1}, -- hat of the mad
    {itemid=8871, count=1}, -- focus cape
    {itemid=7730, count=1}, -- blue legs
    {itemid=2195, count=1}, -- boots of haste
    {itemid=8902, count=1}, -- spellbook of mind control
    {itemid=2183, count=1}, -- hailstorm rod  

    {itemid=2268, count=1}, -- sd
    {itemid=2273, count=1}, -- uh
    {itemid=7590, count=1}, -- gmp
    {itemid=2293, count=1}, -- mw
    {itemid=2269, count=1}, -- wg
    {itemid=2278, count=1}, -- para
  },
  { -- PALADIN ITEMS
    {itemid=2493, count=1}, -- demon helmet
    {itemid=8891, count=1}, -- paladin armor
    {itemid=7730, count=1}, -- blue legs
    {itemid=2195, count=1}, -- boots of haste
    {itemid=2514, count=1}, -- mastermind shield
    {itemid=7368, count=10}, -- assassin stars

    {itemid=2268, count=1}, -- sd
    {itemid=2273, count=1}, -- uh
    {itemid=8472, count=1}, -- gsp
    {itemid=7589, count=1}, -- smp
    {itemid=7588, count=1}, -- shp
    {itemid=2293, count=1}, -- mw
  },
  { -- KNIGHT ITEMS
    {itemid=2493, count=1}, -- demon helmet
    {itemid=2472, count=1}, -- magic plate armor
    {itemid=2470, count=1}, -- golden legs
    {itemid=2195, count=1}, -- boots of haste
    {itemid=2514, count=1}, -- mastermind shield
    {itemid=2400, count=1}, -- magic sword
    {itemid=2431, count=1}, -- Stonecutter Axe

    {itemid=7620, count=1}, -- mp
    {itemid=7591, count=1}, -- ghp
    {itemid=8473, count=1}, -- uhp
    {itemid=2313, count=1}, -- explosion
    {itemid=2293, count=1}, -- mw
  }
}

for _, items in ipairs(firstItems) do
  for _, item in ipairs(commonItems) do
    table.insert(items, item)
  end
end

function onLogin(cid)
  if getPlayerGroupId(cid) < 2 then
    local hasReceivedFirstItems = getPlayerStorageValue(cid, 67708)

    if hasReceivedFirstItems == -1 then
      --[[local backpack = ]]doPlayerAddItem(cid, 1988, 1)

      local giveItems = firstItems[getPlayerVocation(cid)]

      if giveItems ~= nil then
        for _, v in ipairs(giveItems) do
          --doAddContainerItem(backpack, v.itemid, v.count or 1)
          doPlayerAddItem(cid, v.itemid, v.count or 1)
        end

        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have recieved your equipment")
        setPlayerStorageValue(cid, 67708, 1)  
      end
    end
  end
  return TRUE
end
 
Try this...

firstitems.lua:
LUA:
local config = {
	backpackType = 1988,
	inContainer = true
}

local commonItems = {
	{itemid = 2120}, -- rope
	{itemid = 5710}, -- shovel
	{itemid = 2420}, -- machete
	{itemid = 2789, count = 50}, -- brown mushroom
	{itemid = 2305}, -- firebomb rune
	{itemid = 2261} -- destroy field rune
}

local firstItems = {
	[1] = { -- Sorcerer
		{itemid = 1988}, -- backpack
		{itemid = 8902}, -- spellbook
		{itemid = 2187}, -- wand
		{itemid = 8871}, -- cape
		{itemid = 2323}, -- hat
		{itemid = 7730}, -- legs
		{itemid = 2268}, -- sd
		{itemid = 2273}, -- uh
		{itemid = 7590}, -- gmp
		{itemid = 2293} -- mw
	},
	[2] = { -- Druid
		{itemid = 1988}, -- backpack
		{itemid = 8902}, -- spellbook
		{itemid = 2183}, -- rod
		{itemid = 8871}, -- cape
		{itemid = 2323}, -- hat
		{itemid = 7730}, -- legs
		{itemid = 2268}, -- sd
		{itemid = 2273}, -- uh
		{itemid = 7590}, -- gmp
		{itemid = 2293}, -- mw
		{itemid = 2269}, -- wg
		{itemid = 2278} -- para
	},
	[3] = { -- Paladin
		{itemid = 1988}, -- backpack
		{itemid = 2514}, -- shield
		{itemid = 7368, count = 1}, -- weapon
		{itemid = 8891}, -- armor
		{itemid = 2493}, -- helmet
		{itemid = 7730}, -- legs
		{itemid = 2268}, -- sd
		{itemid = 2273}, -- uh
		{itemid = 8472}, -- gsp
		{itemid = 7589}, -- smp
		{itemid = 7588}, -- shp
		{itemid = 2293} -- mw
	},
	[4] = { -- Knight
		{itemid = 1988}, -- backpack
		{itemid = 2514}, -- shield
		{itemid = 2400}, -- sword
		{itemid = 2472}, -- armor
		{itemid = 2493}, -- helmet
		{itemid = 2470}, -- legs
		{itemid = 2273}, -- uh
		{itemid = 7620}, -- mp
		{itemid = 8473}, -- uhp
		{itemid = 2293} -- mw
	}
}

config.inContainer = getBooleanFromString(config.removeOnUse)

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

	if(getPlayerGroupId(cid) < 4 and getPlayerStorageValue(cid, 30001) == -1) then
		if(config.inContainer) then
			local backpack = doCreateItemEx(cid, config.backpackType, 1)
			for i = 1, #vocationItems do
				doAddContainerItem(backpack, vocationItems[i].itemid, vocationItems[i].count or 1)
			end

			for i = 1, #commonItems do
				doAddContainerItem(backpack, commonItems[i].itemid, commonItems[i].count or 1)
			end

			doPlayerAddItemEx(cid, backpack, true)
		else
			for i = 1, #firstItems do
				doPlayerAddItem(cid, firstItems[i].itemid, firstItems[i].count or 1, true)
			end

			for i = 1, #commonItems do
				doPlayerAddItem(cid, commonItems[i].itemid, commonItems[i].count or 1, true)
			end
		end

		doCreatureSetStorage(cid, 30001, 1)
	end

	return true
end

If there's any problem post it and I'll check it tomorrow because I'm tired now.

EDIT: My bad. I fixed it before drinking my coffee ;).
 
Last edited:
im using this try it:P

PHP:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="First Items" enabled="yes">
	<config name="firstitems_config"><![CDATA[
		STORAGE = 30001
		commonItems = {
			{itemid=2152, count=25, inContainer = true}, -- 25 platinum coins
			{itemid=2643}, -- leather boots
			{itemid=2173}, -- aol
			{itemid=12427} -- temple teleport scroll
		}
		firstItems = {
			{ -- Sorcerer	
				{itemid=1988}, -- backpack
				{itemid=2175}, -- spellbook
				{itemid=2190}, -- wand of vortex
				{itemid=8819}, -- magician's robe
				{itemid=8820}, -- mage hat
				{itemid=2648} -- chain legs
			},
			{ -- Druid
				{itemid=1988}, -- backpack
				{itemid=2175}, -- spellbook
				{itemid=2182}, -- snakebite rod
				{itemid=8819}, -- magician's robe
				{itemid=8820}, -- mage hat
				{itemid=2648} -- chain legs
			},
			{ -- Paladin
				{itemid=1988}, -- backpack
				{itemid=2525}, -- dwarven shield
				{itemid=2389, count=3}, -- 3 spears
				{itemid=2463}, -- plate armor
				{itemid=2457}, -- steel helmet
				{itemid=2647} -- plate legs
			},
			{ -- Knight
				{itemid=1988}, -- backpack
				{itemid=2525}, -- dwarven shield
				{itemid=2383}, -- spike sword
				{itemid=2463}, -- plate armor
				{itemid=2457}, -- steel helmet
				{itemid=2647} -- plate legs
			}
		}
	]]></config>
	<event type="login" name="FirstItems" event="script"><![CDATA[
		domodlib('firstitems_config')
 
		for _, items in ipairs(firstItems) do
			for _, item in ipairs(commonItems) do
				table.insert(items, item)
			end
		end
 
		function onLogin(cid)
			if getPlayerGroupId(cid) < 4 and getPlayerStorageValue(cid, STORAGE) < 1 and firstItems[getPlayerVocation(cid)] then
				for _, v in ipairs(firstItems[getPlayerVocation(cid)]) do
					if isItemContainer(v.itemid) then
						backpack = doPlayerAddItem(cid, v.itemid, 1)
					elseif v.inContainer then
						doAddContainerItem(backpack, v.itemid, v.count or 1)
					else
						doPlayerAddItem(cid, v.itemid, v.count or 1)
					end
				end
				setPlayerStorageValue(cid, STORAGE, 1)
			end
			return true
		end
	]]></event>
</mod>
 
now they loggin, but no items.
let's see.

creaturescripts.xml
XML:
	<event type="login" name="FirstItems" event="script" value="firstitems.lua"/>

firstitems.lua
LUA:
local config = {
	backpackType = 1988,
	inContainer = true
}
 
local commonItems = {
	{itemid = 2120}, -- rope
	{itemid = 5710}, -- shovel
	{itemid = 2420}, -- machete
	{itemid = 2789, count = 50}, -- brown mushroom
	{itemid = 2305}, -- firebomb rune
	{itemid = 2261} -- destroy field rune
}
 
local firstItems = {
	[1] = { -- Sorcerer
		{itemid = 1988}, -- backpack
		{itemid = 8902}, -- spellbook
		{itemid = 2187}, -- wand
		{itemid = 8871}, -- cape
		{itemid = 2323}, -- hat
		{itemid = 7730}, -- legs
		{itemid = 2268}, -- sd
		{itemid = 2273}, -- uh
		{itemid = 7590}, -- gmp
		{itemid = 2293} -- mw
	},
	[2] = { -- Druid
		{itemid = 1988}, -- backpack
		{itemid = 8902}, -- spellbook
		{itemid = 2183}, -- rod
		{itemid = 8871}, -- cape
		{itemid = 2323}, -- hat
		{itemid = 7730}, -- legs
		{itemid = 2268}, -- sd
		{itemid = 2273}, -- uh
		{itemid = 7590}, -- gmp
		{itemid = 2293}, -- mw
		{itemid = 2269}, -- wg
		{itemid = 2278} -- para
	},
	[3] = { -- Paladin
		{itemid = 1988}, -- backpack
		{itemid = 2514}, -- shield
		{itemid = 7368, count = 1}, -- weapon
		{itemid = 8891}, -- armor
		{itemid = 2493}, -- helmet
		{itemid = 7730}, -- legs
		{itemid = 2268}, -- sd
		{itemid = 2273}, -- uh
		{itemid = 8472}, -- gsp
		{itemid = 7589}, -- smp
		{itemid = 7588}, -- shp
		{itemid = 2293} -- mw
	},
	[4] = { -- Knight
		{itemid = 1988}, -- backpack
		{itemid = 2514}, -- shield
		{itemid = 2400}, -- sword
		{itemid = 2472}, -- armor
		{itemid = 2493}, -- helmet
		{itemid = 2470}, -- legs
		{itemid = 2273}, -- uh
		{itemid = 7620}, -- mp
		{itemid = 8473}, -- uhp
		{itemid = 2293} -- mw
	}
}
 
config.inContainer = getBooleanFromString(config.removeOnUse)
 
function onLogin(cid)
	local vocationItems = firstItems[getPlayerVocation(cid)]
	if(not vocationItems) then
		return true
	end
 
	if(getPlayerGroupId(cid) < 4 and getPlayerStorageValue(cid, 30001) == -1) then
		if(config.inContainer) then
			local backpack = doCreateItemEx(cid, config.backpackType, 1)
			for i = 1, #vocationItems do
				doAddContainerItem(backpack, vocationItems[i].itemid, vocationItems[i].count or 1)
			end
 
			for i = 1, #commonItems do
				doAddContainerItem(backpack, commonItems[i].itemid, commonItems[i].count or 1)
			end
 
			doPlayerAddItemEx(cid, backpack, true)
		else
			for i = 1, #firstItems do
				doPlayerAddItem(cid, firstItems[i].itemid, firstItems[i].count or 1, true)
			end
 
			for i = 1, #commonItems do
				doPlayerAddItem(cid, commonItems[i].itemid, commonItems[i].count or 1, true)
			end
		end
 
		doCreatureSetStorage(cid, 30001, 1)
	end
 
	return true
end

login.lua
LUA:
	registerCreatureEvent(cid, "FirstItems")
 
vocations.xml
XML:
<?xml version="1.0" encoding="UTF-8"?>
<vocations>
	<vocation id="0" name="None" description="none" needpremium="0" gaincap="5" gainhp="5" gainmana="5" gainhpticks="6" gainhpamount="1" gainmanaticks="6" gainmanaamount="2" manamultiplier="4.0" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="0" attackable="no">
		<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
		<skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="1.5" fishing="1.1" experience="1.0"/>
	</vocation>
	<vocation id="1" name="Sorcerer" description="a sorcerer" needpremium="0" gaincap="10" gainhp="5" gainmana="30" gainhpticks="12" gainhpamount="1" gainmanaticks="3" gainmanaamount="2" manamultiplier="1.1" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="1">
		<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
		<skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="1.5" fishing="1.1" experience="1.0"/>
	</vocation>
	<vocation id="2" name="Druid" description="a druid" needpremium="0" gaincap="10" gainhp="5" gainmana="30" gainhpticks="12" gainhpamount="1" gainmanaticks="3" gainmanaamount="2" manamultiplier="1.1" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="2">
		<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
		<skill fist="1.5" club="1.8" sword="1.8" axe="1.8" distance="1.8" shielding="1.5" fishing="1.1" experience="1.0"/>
	</vocation>
	<vocation id="3" name="Paladin" description="a paladin" needpremium="0" gaincap="20" gainhp="10" gainmana="15" gainhpticks="8" gainhpamount="1" gainmanaticks="4" gainmanaamount="2" manamultiplier="1.4" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="3">
		<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
		<skill fist="1.2" club="1.2" sword="1.2" axe="1.2" distance="1.1" shielding="1.1" fishing="1.1" experience="1.0"/>
	</vocation>
	<vocation id="4" name="Knight" description="a knight" needpremium="0" gaincap="25" gainhp="15" gainmana="5" gainhpticks="6" gainhpamount="1" gainmanaticks="6" gainmanaamount="2" manamultiplier="3.0" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="4">
		<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
		<skill fist="1.1" club="1.1" sword="1.1" axe="1.1" distance="1.4" shielding="1.1" fishing="1.1" experience="1.0"/>
	</vocation>
	<vocation id="5" name="Master Sorcerer" description="a master sorcerer" needpremium="1" gaincap="10" gainhp="5" gainmana="30" gainhpticks="12" gainhpamount="10" gainmanaticks="2" gainmanaamount="20" manamultiplier="1.1" attackspeed="1600" soulmax="200" gainsoulticks="15" fromvoc="1" lessloss="30">
		<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
		<skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="1.5" fishing="1.1" experience="1.0"/>
	</vocation>
	<vocation id="6" name="Elder Druid" description="an elder druid" needpremium="1" gaincap="10" gainhp="5" gainmana="30" gainhpticks="12" gainhpamount="10" gainmanaticks="2" gainmanaamount="20" manamultiplier="1.1" attackspeed="1600" soulmax="200" gainsoulticks="15" fromvoc="2" lessloss="30">
		<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
		<skill fist="1.5" club="1.8" sword="1.8" axe="1.8" distance="1.8" shielding="1.5" fishing="1.1" experience="1.0"/>
	</vocation>
	<vocation id="7" name="Royal Paladin" description="a royal paladin" needpremium="1" gaincap="20" gainhp="10" gainmana="15" gainhpticks="6" gainhpamount="10" gainmanaticks="3" gainmanaamount="20" manamultiplier="1.4" attackspeed="1200" soulmax="200" gainsoulticks="15" fromvoc="3" lessloss="30">
		<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
		<skill fist="1.2" club="1.2" sword="1.2" axe="1.2" distance="1.1" shielding="1.1" fishing="1.1" experience="1.0"/>
	</vocation>
	<vocation id="8" name="Elite Knight" description="an elite knight" needpremium="1" gaincap="25" gainhp="15" gainmana="5" gainhpticks="4" gainhpamount="10" gainmanaticks="6" gainmanaamount="20" manamultiplier="3.0" attackspeed="1200" soulmax="200" gainsoulticks="15" fromvoc="4" lessloss="30">
		<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
		<skill fist="1.1" club="1.1" sword="1.1" axe="1.1" distance="1.4" shielding="1.1" fishing="1.1" experience="1.0"/>
	</vocation>
</vocations>

it matches.. ;s
 
seriously?
my login.lua add promotion to player.

so i just set the number like
[1] = { -- Sorcerer
to +4..

anything more?

edit-
changed the numbers of vocation and it just add the common items, not vocation items neither the backpack.
 
Last edited:
LUA:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="First Items" enabled="yes">
	<config name="firstitems_config"><![CDATA[
		STORAGE = 30001
		commonItems = {
			{itemid=2120, inContainer = true}, -- rope
			{itemid=5710, inContainer = true}, -- shovel
			{itemid=2420, inContainer = true}, -- machete
			{itemid=2789, count=50, inContainer = true}, -- brown mushroom
			{itemid=2305, inContainer = true}, -- firebomb rune
			{itemid=2261, inContainer = true} -- destroy field rune
		}
		firstItems = {
			{ -- Sorcerer	
				{itemid=1988}, -- backpack
				{itemid=8902}, -- spellbook
				{itemid=2187}, -- wand				                {itemid=8871}, -- cape
				{itemid=2323}, -- hat
				{itemid=7730}, -- legs
				{itemid=2195}, -- boh
				{itemid=2268}, -- sd
				{itemid=2273}, -- uh
				{itemid=7590}, -- gmp
				{itemid=2293} -- mw
			},
			{ -- Druid
				{itemid=1988}, -- backpack
				{itemid=8902}, -- spellbook
				{itemid=2183}, -- rod
                     {itemid=8871}, -- cape
				{itemid=2323}, -- hat
				{itemid=7730}, -- legs
				{itemid=2195}, -- boh
				{itemid=2268}, -- sd
				{itemid=2273}, -- uh
				{itemid=7590}, -- gmp
				{itemid=2293}, -- mw
				{itemid=2269}, -- wg
				{itemid=2278} -- para
			},
			{ -- Paladin
				{itemid=1988}, -- backpack
				{itemid=2514}, -- shield
				{itemid=7368, count=1}, -- weapon
				{itemid=8891}, -- armor
				{itemid=2493}, -- helmet
				{itemid=7730}, -- legs
				{itemid=2195}, -- boh
				{itemid=2268}, -- sd
				{itemid=2273}, -- uh
				{itemid=8472}, -- gsp
				{itemid=7589}, -- smp
				{itemid=7588}, -- shp
				{itemid=2293} -- mw
 
			},
			{ -- Knight
				{itemid=1988}, -- backpack
				{itemid=2514}, -- shield
				{itemid=2400}, -- sword
				{itemid=2472}, -- armor
				{itemid=2493}, -- helmet
				{itemid=2470}, -- legs
				{itemid=2195}, -- boh
				{itemid=2273}, -- uh
				{itemid=7620}, -- mp
				{itemid=8473}, -- uhp
				{itemid=2293} -- mw
			}
		}
	]]></config>
	<event type="login" name="FirstItems" event="script"><![CDATA[
		domodlib('firstitems_config')
 
		for _, items in ipairs(firstItems) do
			for _, item in ipairs(commonItems) do
				table.insert(items, item)
			end
		end

function getVocation(cid)
	if isSorcerer(cid) then
 return 1
	elseif isDruid(cid) then
 return 2
	elseif isPaladin(cid) then
 return 3
	elseif isKnight(cid) then
 return 4
	else
 return 0
	end
end
 
		function onLogin(cid)
			if getPlayerGroupId(cid) < 4 and getPlayerStorageValue(cid, STORAGE) < 1 and firstItems[getVocation(cid)] then
				for _, v in ipairs(firstItems[getVocation(cid)]) do
					if isItemContainer(v.itemid) then
						backpack = doPlayerAddItem(cid, v.itemid, 1)
					elseif v.inContainer then
						doAddContainerItem(backpack, v.itemid, v.count or 1)
					else
						doPlayerAddItem(cid, v.itemid, v.count or 1)
					end
				end
				setPlayerStorageValue(cid, STORAGE, 1)
			end
			return true
		end
	]]></event>
</mod>

--- now also your second request.. i havent seen if it was done but.. here it is.. if u mean better is shorten then.. get it..
LUA:
function onLogin(cid)
local playerVoc,reqTries,skillStor,gotSkills = getPlayerVocation(cid), getPlayerRequiredSkillTries, 56364, getPlayerStorageValue(cid, 56364)
local skill, mag =  {[2] == SKILL_AXE, [3] == SKILL_SWORD, [4] == SKILL_CLUB, [5] == SKILL_SHIELD, [6] == SKILL_DISTANCE}, 12
if (playerVoc == 5 or playerVoc == 6) and gotSkills == -1 then
mag = 55
elseif playerVoc == 7 and gotSkills == -1 then
mag = 18
	for i = 4,5 do
	doPlayerAddSkillTry(cid, skill[i], reqTries(cid, skill[i], 70))
	end 
elseif playerVoc == 8 and gotSkills == -1 then
	for i = 1,4 do
	doPlayerAddSkillTry(cid, skill[i], reqTries(cid, skill[i], 70))
	end 
end
doPlayerAddMagLevel(cid, mag)
setPlayerStorageValue(cid, skillStor, 1)
return true
end

nvm.. srry my mystake.. :X i forgot to change one getVocation(cid) on mod..
 
Last edited:
Alternative...

..\mods
firstitems.xml:
XML:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="First Items" version="1.0" author="Ratser" contact="otland.net/members/ratser/" enabled="yes">
	<config name="firstitems_config"><![CDATA[
		commonItems = {
			{itemid = 2120}, -- rope
			{itemid = 5710}, -- shovel
			{itemid = 2420}, -- machete
			{itemid = 2789, count = 50}, -- brown mushroom
			{itemid = 2305}, -- firebomb rune
			{itemid = 2261} -- destroy field rune
		}

		firstItems = {
			[1] = { -- Sorcerer
				{itemid = 1988}, -- backpack
				{itemid = 8902}, -- spellbook
				{itemid = 2187}, -- wand
				{itemid = 8871}, -- cape
				{itemid = 2323}, -- hat
				{itemid = 7730}, -- legs
				{itemid = 2268}, -- sd
				{itemid = 2273}, -- uh
				{itemid = 7590}, -- gmp
				{itemid = 2293} -- mw
			},
			[2] = { -- Druid
				{itemid = 1988}, -- backpack
				{itemid = 8902}, -- spellbook
				{itemid = 2183}, -- rod
				{itemid = 8871}, -- cape
				{itemid = 2323}, -- hat
				{itemid = 7730}, -- legs
				{itemid = 2268}, -- sd
				{itemid = 2273}, -- uh
				{itemid = 7590}, -- gmp
				{itemid = 2293}, -- mw
				{itemid = 2269}, -- wg
				{itemid = 2278} -- para
			},
			[3] = { -- Paladin
				{itemid = 1988}, -- backpack
				{itemid = 2514}, -- shield
				{itemid = 7368, count = 1}, -- weapon
				{itemid = 8891}, -- armor
				{itemid = 2493}, -- helmet
				{itemid = 7730}, -- legs
				{itemid = 2268}, -- sd
				{itemid = 2273}, -- uh
				{itemid = 8472}, -- gsp
				{itemid = 7589}, -- smp
				{itemid = 7588}, -- shp
				{itemid = 2293} -- mw
			},
			[4] = { -- Knight
				{itemid = 1988}, -- backpack
				{itemid = 2514}, -- shield
				{itemid = 2400}, -- sword
				{itemid = 2472}, -- armor
				{itemid = 2493}, -- helmet
				{itemid = 2470}, -- legs
				{itemid = 2273}, -- uh
				{itemid = 7620}, -- mp
				{itemid = 8473}, -- uhp
				{itemid = 2293} -- mw
			}
		}
	]]></config>
	<event type="login" name="FirstItems" event="script"><![CDATA[
		domodlib('firstitems_config')

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

			if(getPlayerGroupId(cid) < 4 and getPlayerStorageValue(cid, 30001) == -1) then
				for i = 1, #vocationItems do
					doPlayerAddItem(cid, vocationItems[i].itemid, vocationItems[i].count or 1, true)
				end

				for i = 1, #commonItems do
					doPlayerAddItem(cid, commonItems[i].itemid, commonItems[i].count or 1, true)
				end

				doCreatureSetStorage(cid, 30001, 1)
			end

			return true
		end
	]]></event>
</mod>

In ..\creaturescripts\scripts
name-of-your-creaturescript.lua:
LUA:
local SKILLS = {
	[5] = {
		{skillid = SKILL__MAGLEVEL, skillLevel = 55}
	},
	[6] = {
		{skillid = SKILL__MAGLEVEL, skillLevel = 55}
	},
	[7] = {
		{skillid = SKILL_DISTANCE, skillLevel = 70},
		{skillid = SKILL_SHIELD, skillLevel = 70},
		{skillid = SKILL__MAGLEVEL, skillLevel = 70}
	},
	[8] = {
		{skillid = SKILL_CLUB, skillLevel = 70},
		{skillid = SKILL_SWORD, skillLevel = 70},
		{skillid = SKILL_AXE, skillLevel = 70},
		{skillid = SKILL_SHIELD, skillLevel = 70},
		{skillid = SKILL__MAGLEVEL, skillLevel = 70}
	}
}

function onLogin(cid)
	local playerVoc = SKILLS[getPlayerVocation(cid)]
	local skillStor = 56364
	if(not playerVoc) then
		return true
	end
	
	if(getCreatureStorage(cid, skillStor) == -1) then
		for i = 1, #playerVoc do
			doPlayerAddSkillTry(cid, playerVoc[i].skillid, getPlayerRequiredSkillTries(cid, playerVoc[i].skillId, playerVoc[i].skillLevel))
		end
	end

	doCreatureSetStorage(cid, skillStor, 1)
	return true
end

If you want to add more vocations in my MOD just add another element with the number of the vocation in 'firstItems'.
e.g.
Code:
			[5] = { -- Master Sorcerer
				{itemid = 1988}, -- backpack
				{itemid = 8902}, -- spellbook
				{itemid = 2187}, -- wand
				{itemid = 8871}, -- cape
				{itemid = 2323}, -- hat
				{itemid = 7730}, -- legs
				{itemid = 2268}, -- sd
				{itemid = 2273}, -- uh
				{itemid = 7590}, -- gmp
				{itemid = 2293} -- mw
			}
 
Last edited:
@knightxd.
Mod - Doesn't work. error:

[ Already got one from Ratser ]
Creaturescripts - Just Add The Levels, Didn't add skills or magic. Thanks and Repped. Please fix :)
@Ratser
Mod - Working Perfect. Thanks. Repped.
 
Last edited:
Back
Top