• 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 New vocation starting items

Powtreeman

Member
Joined
Sep 26, 2011
Messages
400
Reaction score
6
Location
USA
I made a new vocation rogue and he promotes and works just fine but he starts with nothing at all. once he died he gets a bag but thats it. I tried adding another line for him but i need to know how to add this function

isRogue

unless there is a more simple way to do this. im using 0.2 tfs on 9.6
 
you can add the items to the vocation sample
or you can add first items script to give the new vocation items when they start
 
i made the new vocation with vocations.xml
i tried adding the rogues scripts to firstitems.lua but it gives me an error saying isRogue isnt a function or whatever and any character who is a rogue cannot log in.
 
You need to add a new function in global.lua.
Code:
function isRogue(cid)
    if(isPlayer(cid) == FALSE) then
        debugPrint("isRogue: Player not found.")
        return false
    end

    return (isInArray({[COLOR=#ff0000]VOCATION_ID[/COLOR],[COLOR=#ff0000]VOCATION_ID[/COLOR]}, getPlayerVocation(cid)) == TRUE)
end
 
hmm mod?
XML:
<?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 = {2418, 2376}
		}
	]]></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, 2651, 1)
			else
				doPlayerAddItem(cid, 2650, 1)
			end

			doAddContainerItem(doPlayerAddItem(cid, 1987, 1), 2674, 1)
			setPlayerStorageValue(cid, config.storage, 1)
			return true
		end
	]]></event>
</mod>
 
thanks ninja :) i can add the rogue part in firstitems.lua but the rogue still starts with nothing. here is the script.

Lua:
 elseif isRogue(cid) then
			local bag = doPlayerAddItem(cid, 1988, 1)
			doAddContainerItem(bag, 2120, 1)
			doAddContainerItem(bag, 2554, 1)
			doAddContainerItem(bag, 2152, 2)
			doAddContainerItem(bag, 2412, 6)
			doAddContainerItem(bag, 2410, 1)
 
			doPlayerAddItem(cid, 2509, 1)
			doPlayerAddItem(cid, 2467, 4)
			doPlayerAddItem(cid, 2461, 1)
			doPlayerAddItem(cid, 2469, 1)
			doPlayerAddItem(cid, 2643, 8)
 
			setPlayerStorageValue(cid, 50000, 1)

- - - Updated - - -

hmm mod?
XML:
<?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"><=!=[=C=D=A=T=A=[
		config = {
			storage = 30001,
			items = {2418, 2376}
		}
	]=]=></config>
	<event type="login" name="FirstItems" event="script"><=!=[=C=D=A=T=A=[
		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, 2651, 1)
			else
				doPlayerAddItem(cid, 2650, 1)
			end

			doAddContainerItem(doPlayerAddItem(cid, 1987, 1), 2674, 1)
			setPlayerStorageValue(cid, config.storage, 1)
			return true
		end
	]=]=></event>
</mod>


When I search first items in my folder the mod stuff pops up but it wont let me open it.
 
Use the firstitems script on creaturescripts.

PHP:
local firstItems_storage = 30001

local commonItems = {
	{itemid=2554, inContainer = TRUE}, -- shovel
	{itemid=2120, inContainer = TRUE}, -- rope
	{itemid=2160, count=2, inContainer = TRUE}, -- 2 crystal coins
	{itemid=2643} -- leather boots
}
local firstItems = {
	{ -- Sorcerer 
		{itemid=1988, container = TRUE}, -- backpack
		{itemid=2175}, -- spellbook
		{itemid=2190}, -- wand of vortex
		{itemid=8819}, -- magician's robe
		{itemid=8820}, -- mage hat
		{itemid=2468} -- studded legs
	},
	{ -- Druid
		{itemid=1988, container = TRUE}, -- backpack
		{itemid=2175}, -- spellbook
		{itemid=2182}, -- snakebite rod
		{itemid=8819}, -- magician's robe
		{itemid=8820}, -- mage hat
		{itemid=2468} -- studded legs
	},
	{ -- Paladin
		{itemid=1988, container = TRUE}, -- backpack
		{itemid=2456}, -- bow
		{itemid=2544, count = 100}, -- 100 arrows
		{itemid=2660}, -- ranger's cloak
		{itemid=2480}, -- legion helmet
		{itemid=8923} -- ranger legs
	},
	{ -- Knight
		{itemid=1988, container = TRUE}, -- backpack
		{itemid=2439, inContainer = TRUE}, -- daramanian mace
		{itemid=8601, inContainer = TRUE}, -- steel axe
		{itemid=2509}, -- steel shield
		{itemid=8602}, -- jagged sword
		{itemid=2465}, -- brass armor
		{itemid=2481}, -- soldier helmet
		{itemid=2478} -- brass legs
	}
}

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 and getPlayerStorageValue(cid, firstItems_storage) <= 0 then
		local currvoc = getPlayerVocation(cid)
		local vocation = 5 > currvoc and currvoc or currvoc - 4
		local giveItems = firstItems[vocation]
	if giveItems then
		for _, v in ipairs(giveItems) do
	if v.container == TRUE then
		backpack = doPlayerAddItem(cid, v.itemid, 1)
	elseif v.inContainer == TRUE then
		doAddContainerItem(backpack, v.itemid, v.count or 1)
	else
		doPlayerAddItem(cid, v.itemid, v.count or 1)
		end
	end
end
setPlayerStorageValue(cid, firstItems_storage, 1)
end
return TRUE
end
 
Back
Top