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

Dual Promotion Npc Problem

rawrcore

New Member
Joined
Jul 4, 2011
Messages
12
Reaction score
0
The Forgotten Server, version 0.3.6 (Crying Damson)
8.6~~

Hello, i asked my scripter to make me a dual-promo npc, since i have made 2 new promotions for each voc. For example EK - Harbinger/juggernaught. Anyway to the problem. He made me this promoscript and sent it to me and now he has gone on a 3 week vacation. and it doesn't work. and i'm hopeless when it comes to this scripting stuff (a) so if someone could help me with it i would be really happy :D

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
function onCreatureAppear(cid)				npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) 			npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) 	npcHandler:onCreatureSay(cid, type, msg) end
function onThink() 						npcHandler:onThink() end
 
local Topic = {}
function creatureSayCallback(cid, type, msg)
	if msgcontains(msg,'promotion') then
		local v = getPlayerStorageValue(cid,100)
			if v = 8 then
				npcHandler:say('Is promotion really what you seek?',cid)
				Topic[cid] = 1
			elseif v > 8 then
				npcHandler:say('You are already promoted a second time.',cid)
				Topic[cid] = 0
			end
	elseif Topic[cid] == 1 then
		if isElite Knight(cid) then
			npcHandler:say('You have two paths to choose, you can be either {Juggernaught} or {Harbinger}, choose one.',cid)
			Topic[cid] = 2
		end
	elseif Topic[cid] == 2 then
		if isElite Knight(cid) then
			if msgcontains(msg,'juggernaught') then
				npcHandler:say('Are you sure about this?\nYour choice is irreversible!?',cid)
				Topic[cid] = 3
			elseif msgcontains(msg,'harbinger') then
				npcHandler:say('Are you sure about this?\nYour choice is irreversible!?',cid)
				Topic[cid] = 4
			end
		end
	elseif Topic[cid] == 3 then
		if isElite Knight(cid) then
			if msgcontains(msg,'yes') then
				doPlayerSetVocation(cid,12)
				setPlayerStorageValue(cid,v,1)
				npcHandler:say('You are now a {Juggernaught!}',cid)
				Topic[cid] = 0
			else
				npcHandler:say('Then not.',cid)
				Topic[cid] = 0
			end
		end
	elseif Topic[cid] == 4 then
		if isElite Knight(cid) then
			if msgcontains(msg,'yes') then
				doPlayerSetVocation(cid,16)
				setPlayerStorageValue(cid,v,1)
				npcHandler:say('You are now an {Harbinger}!',cid)
				Topic[cid] = 0
			else
				npcHandler:say('Then not.',cid)
				Topic[cid] = 0
			end
		end
	end
end
npcHandler:setMessage(MESSAGE_WALKAWAY, "Argh, goodbye..")
npcHandler:setMessage(MESSAGE_FAREWELL, "Goodbye..")
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

And the servererror i get is

Code:
[Error - LuaScriptInterface::loadFile] data/npc/scripts/knightpromo.lua:13: 'then' expected near '='
[Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/knightpromo.lua
data/npc/scripts/knightpromo.lua:13: 'then' expected near '='
[Error - LuaScriptInterface::loadFile] data/npc/scripts/knightpromo.lua:13: 'then' expected near '='
[Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/knightpromo.lua
data/npc/scripts/knightpromo.lua:13: 'then' expected near '='


well i kinda figured that it's a "then" somewhere that is off. But maaan, there are like 10+ "thens" in the Script ): and as i mentioned earlier, my knowledge about these languages are 0 :D and if this won't work a script for a promoter from Vocid=8 to 12 Would be great to :D then i can just make 8 of them and modify them. Thanks in advance~~ :)

p.s sorry if my english is pretty rusty.
 
Thanks a bunch, got rid of that error, but now i get another error


Code:
[Error - LuaScriptInterface::loadFile] data/npc/scripts/knightpromo.lua:21: 'then' expected near 'Knight'
[Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/knightpromo.lua
data/npc/scripts/knightpromo.lua:21: 'then' expected near 'Knight'

i assume that i'll have to replace the "knight" with something along the lines with Vocid/v = 4/8 or something :eek: ?
 
Lua:
isElite Knight(cid)

I don't think that condition even exists, though I may be wrong.
Try using getPlayerVocation(cid)


EDIT:

Okay it does exist, but it has a different name.
Replace all
Lua:
isElite Knight(cid)
with
Lua:
isKnight(cid)

If you want it to just check for Elite knight, then go to \data\lib\###-vocations.lua:
Just add a new function:

Lua:
function isEliteKnight(cid)
	return isInArray(8, getPlayerVocation(cid))
end

Then you can replace it all with
Lua:
isEliteKnight(cid)
 
Last edited:
i tried doing the lib part, it failed. But then i just changed everything to "isKnight(cid)" and it worked just fine. but the weird thing is that when i spawn him to try him out now.. he doesn't talk to me :eek: he says that he has been expecting me, but after that it doesn't matter what i write, tried promotion,promo everything. no clue why it doesn't work :eek: tried with elite knights/knights, GOD etc.

Code:
04:50 Eternal Toblerone [298]: hi
04:50 Warchief Auron: Welcome, Eternal Toblerone! I have been expecting you.
04:50 Eternal Toblerone [298]: promotion
04:50 Eternal Toblerone [298]: Promotion
04:50 Eternal Toblerone [298]: help
04:50 Eternal Toblerone [298]: advancement
04:50 Eternal Toblerone [298]: advance

but Thanks alot :D atleast he spawns now x) Rep!
 
Ahh.. Well as i mentioned.. i don't know my way around lua or any of these languages actually, Haha. So.. can i just remove the storage needed :eek: ?

like in..

local v = getPlayerStorageValue(cid,100)
if v = 8 then

remove the "local v = getPlayerStorageValue(cid,100)"

and just keep the "if v =8 then" or would that fuq up the script :eek: ?
 
Ahh.. Well as i mentioned.. i don't know my way around lua or any of these languages actually, Haha. So.. can i just remove the storage needed :eek: ?

like in..

local v = getPlayerStorageValue(cid,100)
if v = 8 then

remove the "local v = getPlayerStorageValue(cid,100)"

and just keep the "if v =8 then" or would that fuq up the script :eek: ?

My advice is to try things and see before asking, LUA is incredibly straight forward.

What you're asking will break the script. The v == 8 is a check to make sure that the player is able to receive a promotion. For example, when a player becomes an elite knight, you should set v, which is also that players storage value 100, to 8. You could also make the player complete a quest where the reward sets that storage to 8, or you could even make that npc give the player a storage of 8 by using setPlayerStorageValue(cid,100,8). Putting this line before the v == 8 check will make the script work but also allow a player with no vocation to immediately jump to the vocation you have listed.
 
Back
Top