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

Solved First Items

Byte

* * * * *
Joined
Jul 23, 2013
Messages
130
Reaction score
19
Location
???
Problem: When a new character is created, it does not get any items at all. I have tried different scripts and what not to get the first items to work and I just can't get it.

I am working a real map server (9.80-9.86). I am using http://otland.net/f18/9-80-9-86-forgotten-server-v0-2-15-mystic-spirit-188228/

Here's my creaturescripts.xml

Code:
<?xml version="1.0" encoding="UTF-8"?>
<creaturescripts>
    <event type="login" name="onLogin" script="onLogin.lua"/>
	<!-- Bigfoot Burden Quest -->
	<event type="kill" name="bigfootBurdenQuestVesperoth" script="bigfoot burden quest/bigfootBurdenQuestVesperoth.lua"/>
	<event type="kill" name="bigfootBurdenQuestWarzone" script="bigfoot burden quest/bigfootBurdenQuestWarzone.lua"/>
	<event type="kill" name="bigfootBurdenQuestWeeper" script="bigfoot burden quest/bigfootBurdenQuestWeeper.lua"/>
	<event type="kill" name="bigfootBurdenQuestWiggler" script="bigfoot burden quest/bigfootBurdenQuestWiggler.lua"/>
	
	<!-- Boss Summoning -->
	<event type="kill" name="bossSummoning" script="boss summoning/bossSummoning.lua"/>
	
	<!-- In Service Of Yalahar Quest -->
	<event type="kill" name="inServiceOfYalaharQuestsDiseased" script="in service of yalahar quest/inServiceOfYalaharQuestsDiseased.lua"/>
	<event type="kill" name="inServiceOfYalaharQuestsMorik" script="in service of yalahar quest/inServiceOfYalaharQuestsMorik.lua"/>
	<event type="kill" name="inServiceOfYalaharQuestsQuara" script="in service of yalahar quest/inServiceOfYalaharQuestsQuara.lua"/>
	
	<!-- Inquisition Quest -->
	<event type="kill" name="inquisitionQuestBosses" script="inquisition quest/inquisitionQuestBosses.lua"/>
	<event type="kill" name="inquisitionQuestUngreez" script="inquisition quest/inquisitionQuestUngreez.lua"/>
	
	<!-- Killing In The Name Of Quest -->
	<event type="kill" name="killingInTheNameOfQuestAchievements" script="killing in the name of quest/killingInTheNameOfQuestAchievements.lua"/>
	
	<!-- The Masters Voice Quest -->
	<event type="kill" name="masterVoiceQuest" script="their master's voice quest/masterVoiceQuest.lua"/>

	<!-- Level Money -->
	<event type="advance" name="levelMoney" script="levelMoney/levelMoney.lua"/>
	<event type="login" name="firstitems" event="script" value="firstitems.lua"/>
</creaturescripts>


My firstitems.lua
Code:
local firstItems = {2050, 2382}

function onLogin(cid)
	if getPlayerLastLoginSaved(cid) == 0 then
		for i = 1, table.maxn(firstItems) do
			doPlayerAddItem(cid, firstItems[i], 1)
		end
		doPlayerAddItem(cid, getPlayerSex(cid) == 0 and 2651 or 2650, 1)
		local bag = doPlayerAddItem(cid, 1987, 1)
		doAddContainerItem(bag, 2674, 1)

    if getPlayerGroupId(cid) == 1 and getPlayerStorageValue(cid, 50000) == -1 then 
        if isSorcerer(cid) then 
            local bag = doPlayerAddItem(cid, 9774, 1) 
     
            doAddContainerItem(bag, 2120, 1) 
            doAddContainerItem(bag, 2554, 1) 
            doAddContainerItem(bag, 2160, 5) 
         
            doPlayerAddItem(cid, 2525, 1) 
            doPlayerAddItem(cid, 2190, 1) 
            doPlayerAddItem(cid, 2463, 1) 
            doPlayerAddItem(cid, 2457, 1) 
            doPlayerAddItem(cid, 2647, 1) 
            doPlayerAddItem(cid, 2643, 1) 

        setPlayerStorageValue(cid, 50000, 1) 

        elseif isDruid(cid) then 
            local bag = doPlayerAddItem(cid, 9774, 1) 
            doAddContainerItem(bag, 2120, 1) 
            doAddContainerItem(bag, 2554, 1) 
            doAddContainerItem(bag, 2160, 5) 
         
            doPlayerAddItem(cid, 2525, 1) 
            doPlayerAddItem(cid, 2182, 1) 
            doPlayerAddItem(cid, 2463, 1) 
            doPlayerAddItem(cid, 2457, 1) 
            doPlayerAddItem(cid, 2647, 1) 
            doPlayerAddItem(cid, 2643, 1) 

            setPlayerStorageValue(cid, 50000, 1) 

        elseif isPaladin(cid) then 
            local bag = doPlayerAddItem(cid, 9774, 1) 
            doAddContainerItem(bag, 2120, 1) 
            doAddContainerItem(bag, 2554, 1) 
            doAddContainerItem(bag, 2160, 5) 
         
            doPlayerAddItem(cid, 2389, 3) 
            doPlayerAddItem(cid, 2525, 1) 
            doPlayerAddItem(cid, 2457, 1) 
            doPlayerAddItem(cid, 2643, 1) 
            doPlayerAddItem(cid, 2647, 1) 
                  doPlayerAddItem(cid, 2463, 1) 
            setPlayerStorageValue(cid, 50000, 1) 

        elseif isKnight(cid) then 
            local bag = doPlayerAddItem(cid, 9774, 1) 
            doAddContainerItem(bag, 2120, 1) 
            doAddContainerItem(bag, 2554, 1) 
            doAddContainerItem(bag, 2160, 5) 
            doAddContainerItem(bag, 8601, 1) 
         
                doPlayerAddItem(cid, 2525, 1) 
            doPlayerAddItem(cid, 2463, 1) 
            doPlayerAddItem(cid, 2457, 1) 
            doPlayerAddItem(cid, 2647, 1) 
            doPlayerAddItem(cid, 2643, 1) 

            setPlayerStorageValue(cid, 50000, 1) 
        end 
    end 
     return TRUE 
end


And just in case, my login.lua

Code:
function onLogin(cid)
	registerCreatureEvent(cid, "PlayerDeath")
	return TRUE
end


And finally, my onLogin.lua

Code:
function onLogin(cid)
	registerCreatureEvent(cid, "bigfootBurdenQuestVesperoth")
	registerCreatureEvent(cid, "bigfootBurdenQuestWarzone")
	registerCreatureEvent(cid, "bigfootBurdenQuestWeeper")
	registerCreatureEvent(cid, "bigfootBurdenQuestWiggler")
	registerCreatureEvent(cid, "bossSummoning")
	registerCreatureEvent(cid, "inServiceOfYalaharQuestsDiseased")
	registerCreatureEvent(cid, "inServiceOfYalaharQuestsMorik")
	registerCreatureEvent(cid, "inServiceOfYalaharQuestsQuara")
	registerCreatureEvent(cid, "inquisitionQuestBosses")
	registerCreatureEvent(cid, "inquisitionQuestUngreez")
	registerCreatureEvent(cid, "killingInTheNameOfQuestAchievements")
	registerCreatureEvent(cid, "masterVoiceQuest")
	registerCreatureEvent(cid, "levelMoney")
	registerCreatureEvent(cid, "Firstitems") 
	return true
end
 
Rewritten your script.
Tested on TFS 0.2.15 (Mystic Spirit).
LUA:
local vocitems = {
	[1] = {
		container = {{id = 2120, count = 1}, {id = 2554, count = 1}, {id = 2160, count = 5}},
		eq = {2525, 2190, 2463, 2457, 2647, 2643}
	},
	[2] = {
		container = {{id = 2120, count = 1}, {id = 2554, count = 1}, {id = 2160, count = 5}},
		eq = {2525, 2182, 2463, 2457, 2647, 2643}
	},
	[3] = {
		container = {{id = 2120, count = 1}, {id = 2554, count = 1}, {id = 2160, count = 5}},
		eq = {2389, 2525, 2457, 2463, 2647, 2643}
	},
	[4] = {
		container = {{id = 2120, count = 1}, {id = 2554, count = 1}, {id = 2160, count = 5}},
		eq = {2525, 8601, 2463, 2457, 2647, 2643}
	}
}

function onLogin(cid)

	if(getPlayerGroupId(cid) == 1 and getPlayerLastLoginSaved(cid) == 0) then 
		local x = vocitems[getPlayerVocation(cid)]
		if x then
			for e = 1, #x.eq do
				doPlayerAddItem(cid, x.eq[e], 1) 
			end
			local bag = doPlayerAddItem(cid, 9774, 1)
			for c = 1, #x.container do
				doAddContainerItem(bag, x.container[c].id, x.container[c].count)
			end
		end 
	end
	return true
end
Btw, don't register login scripts.
 
Rewritten your script.
Tested on TFS 0.2.15 (Mystic Spirit).
LUA:
local vocitems = {
	[1] = {
		container = {{id = 2120, count = 1}, {id = 2554, count = 1}, {id = 2160, count = 5}},
		eq = {2525, 2190, 2463, 2457, 2647, 2643}
	},
	[2] = {
		container = {{id = 2120, count = 1}, {id = 2554, count = 1}, {id = 2160, count = 5}},
		eq = {2525, 2182, 2463, 2457, 2647, 2643}
	},
	[3] = {
		container = {{id = 2120, count = 1}, {id = 2554, count = 1}, {id = 2160, count = 5}},
		eq = {2389, 2525, 2457, 2463, 2647, 2643}
	},
	[4] = {
		container = {{id = 2120, count = 1}, {id = 2554, count = 1}, {id = 2160, count = 5}},
		eq = {2525, 8601, 2463, 2457, 2647, 2643}
	}
}

function onLogin(cid)

	if(getPlayerGroupId(cid) == 1 and getPlayerLastLoginSaved(cid) == 0) then 
		local x = vocitems[getPlayerVocation(cid)]
		if x then
			for e = 1, #x.eq do
				doPlayerAddItem(cid, x.eq[e], 1) 
			end
			local bag = doPlayerAddItem(cid, 9774, 1)
			for c = 1, #x.container do
				doAddContainerItem(bag, x.container[c].id, x.container[c].count)
			end
		end 
	end
	return true
end
Btw, don't register login scripts.

Two questions:

1.) Are the "x"'s in the second part of the script supposed to be replaced by a value or ID?

2.) When you say "don't register login scripts." do you mean the ones on login.lua or onLogin.lua? Or both? If so, do I delete everything inside them?
 
1. No, it's already working like this. I used the same items as in your script, but if you want to change them or add more you can do this in the local vocitems.
The numbers stand for voc id, so 1 is sorcerer, 2 druid, 3 paladin and 4 knight.
2. I mean scripts with type login, so in the lua script with function onLogin, you don't have to register those, only the others.
 
Yes, and the creaturescripts.xml line should look like this.
XML:
<event type="login" name="FirstItems" script="firstitems.lua"/>
So without event and value.
 
Got it, I'll test it out in a bit and bring feedback.

EDIT: Nevermind, it works! Thanks again for your help I highly appreciate it.
 
Last edited:
Back
Top