• 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!

[Mod & Lua] Advanced First Items (useRunes, useSlot, slotType, useMessage, inContainer)

Do you find this MOD useful?

  • Yes, of course! Thank you!

  • No, not exactly. But thank you.

  • Somewhat, yes. Thank you.


Results are only viewable after voting.

J.Dre

Unity Games
Joined
May 18, 2011
Messages
2,647
Solutions
3
Reaction score
648
Location
United States
Hello, this is another release I would like to provide to the community. This mod's default items are similar to those acquired on the Island of Destiny in Tibia. All of which can be easily changed or removed. Be careful while editing, a missing comma is all it takes to get errors. ;)

Tested & Working on TFS 0.3 + 0.4. It will not work on TFS 0.2!

Update Log:

    • [v2.0] - Initial Release
      *Added new slot system.
      *Added new message system.
      *Adjusted config to be user-friendly.
      *Added message config (within script).
    • [v2.1] - Upgrade
      *Replaced check for 'group' to 'access' - faster.
      *Replaced the need for 'storage' with getPlayerLastLoginSaved(cid).
    • [v2.2] - Repair
      *Fixed an issue with the script.
    • [v2.3] New version

Paladin Example:

ostnog.png


[v2.2] Mod (NO RUNES)

[v2.2] Mod (WITH RUNES)


[v2.3] Lua Script (WITH RUNES)

Warning! The 'message config' itself may be tricky to edit. You will find the config located within the script, right before adding the actual item.

If you need help with editing the script, please send me a private message as soon as possible. I will do my best to assist you.
 
Last edited:
prefer getPlayerAccess over getPlayerGroupId, and storage is waste if you can just check lastlogin (getPlayerLastLogin)
 
how can i edit to make a gray bp containing 200 sd a purple bp containing 200 mana pots etcc..
 
That would require some additions to this script. Do you want another backpack to be added, inside the brown backpack?
 
main backpack should contain rope shovel and two backpack
inside the backpack there should be runes

i plan on making a war server where the runes rune out of charges.
 
I have made your request, but there are two problems.

1. Auto-stack makes it difficult. For example, it should make 20 runes with 3 charges each - instead it makes 1 rune with 60 charges.
2. If the player level is not high enough, he/she will drop items (i.e. 100 charges = 20 runes with 100 charges each = a lot of cap).

Just make sure the level of the new players are high enough.

Lua:
{useRunes=true, container=1988, runeId=2268, charges=3} -- charges are multiplied by the container size (20 x 3 = 60 SD runes).
Lua:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="First Items" version="2.0" author="J.Dre" contact="[email protected]" enabled="yes">
	<config name="firstitems_config"><![CDATA[
		commonItems = {
			{itemid=8707, count=1, useMessage=true}, -- a book (or whatever) with a message
			{itemid=2789, count=10, inContainer = true}, -- 10 brown mushrooms
			{itemid=2152, count=10, inContainer = true}, -- 10 platinum coins
			{itemid=2200, count=100, useSlot=true, slotType=CONST_SLOT_NECKLACE}, -- protection amulet
			{itemid=2643} -- leather boots
		}
		firstItems = {
			{ -- Sorcerer	
				{itemid=1988}, -- backpack
				{itemid=2175}, -- spellbook
				{itemid=2190}, -- wand of vortex
				{itemid=8819}, -- magician's robe
				{itemid=8820}, -- mage hat
				{itemid=2468}, -- studded legs
				{itemid=7620, count=3, inContainer=true}, -- mana potion
				{useRunes=true, container=1988, runeId=2268, charges=3}
			},
			{ -- Druid
				{itemid=1988}, -- backpack
				{itemid=2175}, -- spellbook
				{itemid=2182}, -- snakebite rod
				{itemid=8819}, -- magician's robe
				{itemid=8820}, -- mage hat
				{itemid=2468}, -- studded legs
				{itemid=7620, count=3, inContainer=true}, -- mana potion
				{useRunes=true, container=1988, runeId=2268, charges=3}
			},
			{ -- Paladin
				{itemid=1988}, -- backpack
				{itemid=2456, count=1, useSlot=true, slotType=CONST_SLOT_LEFT}, -- bow
				{itemid=2544, count=100, useSlot=true, slotType=CONST_SLOT_LAST}, -- 100 arrow's
				{itemid=2660}, -- ranger's cloak
				{itemid=2481}, -- soldier helmet
				{itemid=8923}, -- ranger legs
				{itemid=7618, count=1, inContainer=true}, -- health potion
				{itemid=7620, count=2, inContainer=true}, -- mana potion
				{useRunes=false, container=1988, runeId=2268, charges=3}
			},
			{ -- Knight
				{itemid=1988}, -- backpack
				{itemid=2509}, -- steel shield
				{itemid=8602}, -- jagged sword
				{itemid=8601, inContainer=true}, -- steel axe
				{itemid=2439, inContainer=true}, -- daramanian mace
				{itemid=2465}, -- brass armor
				{itemid=2481}, -- soldier helmet
				{itemid=2478}, -- brass legs
				{itemid=7618, count=3, inContainer=true}, -- health potion
				{useRunes=false, container=1988, runeId=2268, charges=3}
			}
		}
	]]></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(getPlayerAccess(cid) < 3 and (getPlayerLastLoginSaved(cid) < 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, false)
					elseif v.inContainer then
						doAddContainerItem(backpack, v.itemid, v.count or 1)
					elseif v.useSlot then
						local id = doCreateItemEx(v.itemid, v.count or 1)
						doPlayerAddItemEx(cid, id, false, v.slotType)
					elseif v.useMessage then
						local t, k = {
							writer = "Server Staff", date = os.time(),
							text = "Welcome to " .. getConfigValue('serverName') .. ", " .. getCreatureName(cid) .. ".\n\nIf you need help with anything, please refer to the help channel and our staff will gladly assist you. Please remember to report any errors, bugs, or abuse to the Gamemasters.\n\nNote: If your Protection Amulet is below 100 charges, you may click it and it will recharge itself. This will only work until you reach level 10."
						}, doPlayerAddItem(cid, v.itemid, v.count or 1, false)
						doSetItemText(k, t.text, t.writer, t.date)
					elseif v.useRunes then
						local weight = getItemWeightById(v.runeId, tonumber(getItemInfo(v.container).maxItems)) + getItemWeightById(v.container, 1)
						if(getPlayerFreeCap(cid) >= weight) then
							local bp = doCreateItemEx(cid, v.container, 1)
							if(doPlayerAddItemEx(cid, bp) ~= RETURNVALUE_NOERROR) then
								return false
							else
								for i = 1, tonumber(getItemInfo(v.container).maxItems) do
									doAddContainerItem(bp, v.runeId, v.charges or 1)
								end
							end
						end
					else
						doPlayerAddItem(cid, v.itemid, v.count or 1)
					end
				end
			end
			
			return true
		end
	]]></event>
</mod>
I'll do some work with this tomorrow or my next free day. My goal is to perfect the rune part, and update the main post. For now, this will have to do.
 
Last edited:
cool thanks a lot im going to try it

edit:
it work fine so far

i have another request. how can i make this mod give first items every loging.
 
Last edited:
You remove this part from the script:

Lua:
and (getPlayerLastLoginSaved(cid) < 1)
I do not recommend this. It may cause errors and problems with "log-spam," creating items on the ground.
 
is there a way to remove all items from inventory everytime someone loges in so they can get first item with out spam on ground?
 
Back
Top