• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

CreatureEvent [onLogin] the first items with different additives(ex. letter with txt) at login

andypsylon

be be
Joined
Jan 13, 2009
Messages
772
Reaction score
65
Location
de/pl
for this query

as in the title

in data\creaturescripts\creaturescripts.xml insert:
XML:
<event type="login" name="firstItems" event="script" value="firstItems.lua"/>

create data\creaturescripts\scripts\firstItems.lua and insert:
Lua:
-- ver. 2.3 2012-01-06
-- author tfs, otland.net/members/andypsylon
-- with a welcome letter
local c = {
	freeDays = nil, -- paste nr, for ex. 3 if you will 3 free premium days for players
	addLevel = nil, -- paste nr, for ex. 7 if you will 8 start level for players
-- letter
	text = "Hi ".. getCreatureName(cid) ..". WarOTS  Blabla bla. BlaaaBlabla Bla bla bla :) bla.", 
	writer = "Andy, (name of your ots)", 
	date = os.time()
--/letter
}
local commonItems = { -- items for all vocs
	{2120}, -- rope
	{2789, 100}, -- brown mushrooms
	{2305}, -- fire bomb rune
	{2261}, -- destroy field rune
	{2274} -- avalanche rune
}
local firstItems = {
	{ -- items for sorcerer
		{2323}, -- hat of the mad
		{8871}, -- focus cape
		{7730}, -- blue legs
		{2195}, -- boots of haste
		{8902}, -- spellbook of mind control
		{2187}, -- wand of inferno  
		{2268}, -- sd
		{2273}, -- uh
		{7590}, -- gmp
		{2293} -- mw
	},
	{ -- items for druid
		{2323}, -- hat of the mad
		{8871}, -- focus cape
		{7730}, -- blue legs
		{2195}, -- boots of haste
		{8902}, -- spellbook of mind control
		{2183}, -- hailstorm rod  
		{2268}, -- sd
		{2273}, -- uh
		{7590}, -- gmp
		{2293}, -- mw
		{2269}, -- wg
		{2278} -- para
	},
	{ -- items for palladin
		{2493}, -- demon helmet
		{8891}, -- paladin armor
		{7730}, -- blue legs
		{2195}, -- boots of haste
		{2514}, -- mastermind shield
		{7368, 10}, -- assassin stars
		{2268}, -- sd
		{2273}, -- uh
		{8472}, -- gsp
		{7589}, -- smp
		{7588}, -- shp
		{2293} -- mw
	},
	{ -- items for knight
		{2493}, -- demon helmet
		{2472}, -- magic plate armor
		{2470}, -- golden legs
		{2195}, -- boots of haste
		{2514}, -- mastermind shield
		{2400}, -- magic sword
		{2431}, -- Stonecutter Axe
		{7620}, -- mp
		{8473}, -- uhp
		{2313}, -- explosion
		{2293} -- mw
	}
}

for _, fitems in ipairs(firstItems) do
	for _, citems in ipairs(commonItems) do
		table.insert(fitems, citems)
	end
end

function onLogin(cid)
	if getPlayerGroupId(cid) < 2 then
		local hasReceivedFirstItems = getCreatureStorage(cid, 30001) -- 30001 - is standard storage in tfs ots, you can change for another one

		if hasReceivedFirstItems == -1 then
			local bp = doPlayerAddItem(cid, 2000, 1)
			local giveItems = firstItems[getPlayerVocation(cid)]

			if giveItems ~= nil then
				for _, v in ipairs(giveItems) do
					doAddContainerItem(bp, v[1], v[2] or 1)
				end
			end
			-- letter
			local item = doCreateItemEx(2598, 1)
			doSetItemText(item, c.text, c.writer, c.date) 
			doPlayerAddItemEx(cid, item, true)
			doShowTextDialog(cid, 2598, c.text)
			--/letter
			if c.freeDays ~= nil then
				doPlayerAddPremiumDays(cid, c.freeDays) -- how many free premium days? 3?
			end
			if c.addLevel ~= nil then
				doPlayerAddLevel(cid, c.addLevel) -- Level 8
			end
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have recieved your first equipment")
			doCreatureSetStorage(cid, 30001, 1)  
		end
	end
	return true
end

or mod
XML:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="First Items" version="2.3" author="andy" contact="otland.net/members/andypsylon" enabled="yes">
	<event type="login" name="firstItems" event="script"><![CDATA[
local c = {
	freeDays = nil -- paste nr, for ex. 3 if you will 3 free premium days for players
	addLevel = nil -- paste nr, for ex. 7 if you will 8 start level for players
-- letter
	text = "Hi ".. getCreatureName(cid) ..". WarOTS  Blabla bla. BlaaaBlabla Bla bla bla :) bla.", 
	writer = "Andy, (name of your ots)", 
	date = os.time()
--/letter
}
local commonItems = { -- items for all vocs
	{2120}, -- rope
	{2789, 100}, -- brown mushrooms
	{2305}, -- fire bomb rune
	{2261}, -- destroy field rune
	{2274} -- avalanche rune
}
local firstItems = {
	{ -- items for sorcerer
		{2323}, -- hat of the mad
		{8871}, -- focus cape
		{7730}, -- blue legs
		{2195}, -- boots of haste
		{8902}, -- spellbook of mind control
		{2187}, -- wand of inferno  
		{2268}, -- sd
		{2273}, -- uh
		{7590}, -- gmp
		{2293} -- mw
	},
	{ -- items for druid
		{2323}, -- hat of the mad
		{8871}, -- focus cape
		{7730}, -- blue legs
		{2195}, -- boots of haste
		{8902}, -- spellbook of mind control
		{2183}, -- hailstorm rod  
		{2268}, -- sd
		{2273}, -- uh
		{7590}, -- gmp
		{2293}, -- mw
		{2269}, -- wg
		{2278} -- para
	},
	{ -- items for palladin
		{2493}, -- demon helmet
		{8891}, -- paladin armor
		{7730}, -- blue legs
		{2195}, -- boots of haste
		{2514}, -- mastermind shield
		{7368, 10}, -- assassin stars
		{2268}, -- sd
		{2273}, -- uh
		{8472}, -- gsp
		{7589}, -- smp
		{7588}, -- shp
		{2293} -- mw
	},
	{ -- items for knight
		{2493}, -- demon helmet
		{2472}, -- magic plate armor
		{2470}, -- golden legs
		{2195}, -- boots of haste
		{2514}, -- mastermind shield
		{2400}, -- magic sword
		{2431}, -- Stonecutter Axe
		{7620}, -- mp
		{8473}, -- uhp
		{2313}, -- explosion
		{2293} -- mw
	}
}

for _, fitems in ipairs(firstItems) do
	for _, citems in ipairs(commonItems) do
		table.insert(fitems, citems)
	end
end

function onLogin(cid)
	if getPlayerGroupId(cid) < 2 then
		local hasReceivedFirstItems = getCreatureStorage(cid, 30001) -- 30001 - is standard storage in tfs ots, you can change for another one

		if hasReceivedFirstItems == -1 then
			local bp = doPlayerAddItem(cid, 2000, 1)
			local giveItems = firstItems[getPlayerVocation(cid)]

			if giveItems ~= nil then
				for _, v in ipairs(giveItems) do
					doAddContainerItem(bp, v[1], v[2] or 1)
				end
			end
			-- letter
			local item = doCreateItemEx(2598, 1)
			doSetItemText(item, c.text, c.writer, c.date) 
			doPlayerAddItemEx(cid, item, true)
			doShowTextDialog(cid, 2598, c.text)
			--/letter
			if c.freeDays ~= nil then
				doPlayerAddPremiumDays(cid, c.freeDays) -- how many free premium days? 3?
			end
			if c.addLevel ~= nil then
				doPlayerAddLevel(cid, c.addLevel) -- Level 8
			end
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have recieved your first equipment")
			doCreatureSetStorage(cid, 30001, 1)  
		end
	end
	return true
end
]]></event>
</mod>
 
Last edited:
Is there a reason its not working on 3884? Im pretty sure mine is perfectly the same, just different items and text.
local commonItems = { -- items for all vocs
{2120}, -- rope
{5710}, -- shovel
{2160, 2}, -- crystals
{2789, 100}, -- brown mushrooms
{2305}, -- fire bomb rune
{2261}, -- destroy field rune
{2274} -- avalanche rune
}
local firstItems = {
{ -- items for sorcerer
{2457}, -- steel helmet
{2463}, -- plate armor
{2647}, -- plate legs
{2643}, -- leather boots
{2525}, -- dwarven shield
{2188}, -- wand of decay
{2268}, -- sd
{2273}, -- uh
{7590}, -- gmp
{2293} -- mw
},
{ -- items for druid
{2457}, -- steel helmet
{2463}, -- plate armor
{2647}, -- plate legs
{2643}, -- leather boots
{2525}, -- dwarven shield
{2185}, -- necrotic rod
{2268}, -- sd
{2273}, -- uh
{7590}, -- gmp
{2293}, -- mw
{2269}, -- wg
{2278} -- para
},
{ -- items for palladin
{2457}, -- steel helmet
{2463}, -- plate armor
{2647}, -- plate legs
{2643}, -- leather boots
{2525}, -- dwarven shield
{7378, 1}, -- royal spear
{2268}, -- sd
{2273}, -- uh
{8472}, -- gsp
{7589}, -- smp
{7588}, -- shp
{2293} -- mw
},
{ -- items for knight
{2457}, -- steel helmet
{2463}, -- plate armor
{2647}, -- plate legs
{2643}, -- leather boots
{2525}, -- dwarven shield
{7385}, -- crimson sword
{7750}, -- knight axe
{7620}, -- mp
{8473}, -- uhp
{2313}, -- explosion
{2293} -- mw
}
}

for _, fitems in ipairs(firstItems) do
for _, citems in ipairs(commonItems) do
table.insert(fitems, citems)
end
end

function onLogin(cid)
if getPlayerGroupId(cid) < 2 then
local hasReceivedFirstItems = getPlayerStorageValue(cid, 30001) -- 30001 - is standard storage in tfs ots, you can change for another one

if hasReceivedFirstItems == -1 then
local backpack = doPlayerAddItem(cid, 2000, 1)
local giveItems = firstItems[getPlayerVocation(cid)]

if giveItems ~= nil then
for _, v in ipairs(giveItems) do
doAddContainerItem(backpack, v[1], v[2] or 1)
end
end
-- letter
local c = {
text = "Hello ".. getPlayerName(cid) ..". Welcome to Tibia Enforced! The only REAL PvP-Enforced server still alive after tibia updated and took out experience from players. We are here to provide you with a friendly RPG environment, that allows you to gain experience when you come to find yourself in combat against another player. Our staff is here to work with the community to establish a server where everyone can enjoy it! Please leave suggestions on the forums and continue to give your support by playing, Thank you guys!",
writer = "Hux, (Tibia Enforced)",
date = os.time(),
item = doCreateItemEx(2598, 1)
}
doSetItemText(c.item, c.text, c.writer, c.date)
doPlayerAddItemEx(cid, c.item, true)
doShowTextDialog(cid, 2598, c.text)
--/letter

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have recieved your first equipment")
setPlayerStorageValue(cid, 30001, 1)
end
end
return true
end
 
edited first post
sorry, forgot to fix it before :)

what exactly does not work on your ots?
 
don't work
[07/01/2012 15:00:08] [Error - CreatureScript Interface]
[07/01/2012 15:00:08] buffer
[07/01/2012 15:00:08] Description:
[07/01/2012 15:00:08] [string " config = {..."]:3: attempt to concatenate a boolean value
[07/01/2012 15:00:08] done.
 
@up sorry but this is not error from this script!
"08] [string" config = {..."]: 3 "
Where in my script is "config"? :p

@extrodus
and? work?
 
[16:54:02.545] [Error - LuaInterface::loadFile] data/creaturescripts/scripts/firstitems.lua:6: '}' expected (to close '{' at line 4) near 'addLevel'
[16:54:02.545] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/firstitems.lua)
 
[22/01/2012 11:22:40] [Error - CreatureScript Interface]
[22/01/2012 11:22:40] data/creaturescripts/scripts/firstItems.lua
[22/01/2012 11:22:40] Description:
[22/01/2012 11:22:40] (luaGetCreatureName) Creature not found

[22/01/2012 11:22:40] [Error - CreatureScript Interface]
[22/01/2012 11:22:40] data/creaturescripts/scripts/firstItems.lua
[22/01/2012 11:22:40] Description:
[22/01/2012 11:22:40] data/creaturescripts/scripts/firstItems.lua:8: attempt to concatenate a boolean value
[22/01/2012 11:22:40] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/firstItems.lua)


What's wrong?
 
post it, cuz i cant get it working for some reason o.o!
 
Here you go :)



Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="First Items" version="1.0" author="The Forgotten Server" contact="otland.net" enabled="yes">
	<config name="firstitems_config"><![CDATA[
		config = {
			storage = 30001,
			items = {2525, 2382}
		}
	]]></config>
	<event type="login" name="FirstItems" event="script"><![CDATA[
		domodlib('firstitems_config')

		function onLogin(cid)
			if(getPlayerStorageValue(cid, config.storage) > 0) then
				return true
			end

			for _, id in ipairs(config.items) do
				doPlayerAddItem(cid, id, 1)
			end

			if(getPlayerSex(cid) == PLAYERSEX_FEMALE) then
				doPlayerAddItem(cid, 2457, 1)
				doPlayerAddItem(cid, 2463, 1)
				doPlayerAddItem(cid, 2647, 1)
				doPlayerAddItem(cid, 2643, 1)
			else
				doPlayerAddItem(cid, 2457, 1)
				doPlayerAddItem(cid, 2463, 1)
				doPlayerAddItem(cid, 2647, 1)
				doPlayerAddItem(cid, 2643, 1)
			end

			doAddContainerItem(doPlayerAddItem(cid, 3940, 1), 2789, 25)
			doPlayerAddItem(cid, 2543, 10)
			doPlayerAddItem(cid, 2268, 100)
			doPlayerAddItem(cid, 2455, 1)
			doPlayerAddItem(cid, 2273, 100)
			setPlayerStorageValue(cid, config.storage, 1)
			return true
		end
	]]></event>
</mod>
 
Back
Top