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

Promotion npc problem

Zuxus

Learning C++ and Lua
Joined
Jul 2, 2007
Messages
108
Reaction score
0
Location
Norway
When I buy a promotion I become for example master sorcerer, but when I relog I am sorcerer again. Help pls. Here is the script:

Code:
 local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local premium = { days = 7, cost = 20000, effect = CONST_ME_MAGIC_GREEN }
local promotion = { cost = 20000, effect = CONST_ME_MAGIC_GREEN }

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

function creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
		return false
	end

	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	
	if msgcontains(msg, "Nop") or msgcontains(msg, "Nop") then
		selfSay("Do you want to buy "..premium.days.." days of premium account for "..premium.cost.." gold?", cid)
		talkState[talkUser] = 1
	elseif msgcontains(msg, "promotion") or msgcontains(msg, "advance") then
		if getPlayerStorageValue(cid, 30018) ~= TRUE then
			selfSay("I can promote you for "..promotion.cost.." gold. Should I do it?", cid)
			talkState[talkUser] = 2
		else
			selfSay("You are already promoted!", cid)
		end
	elseif msgcontains(msg, "yes") then
		if talkState[talkUser] == 1 then
			if doPlayerRemoveMoney(cid, premium.cost) == TRUE then
				selfSay(premium.days.." days has been added to your account.", cid)
				doSendMagicEffect(getCreaturePosition(cid), premium.effect)
				doPlayerAddPremiumDays(cid, 7)
				talkState[talkUser] = 0
			else
				selfSay("You do not have enough money.", cid)
				talkState[talkUser] = 0
			end
		elseif talkState[talkUser] == 2 then
			if doPlayerRemoveMoney(cid, promotion.cost) == TRUE then
				setPlayerStorageValue(cid, 30018, TRUE)
				selfSay("Enjoy your promotion!", cid)
				doPlayerSetVocation(cid, getPlayerVocation(cid) + 4)
				doSendMagicEffect(getCreaturePosition(cid), promotion.effect)
				talkState[talkUser] = 0
			else
				selfSay("You do not have enough money.", cid)
				talkState[talkUser] = 0
			end
		end
	end
	return TRUE
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
try this script:
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 node1 = keywordHandler:addKeyword({'promot', 'promotion'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can see that you are ready to get promoted, I will take a fee of 20.000 gold coins aswell, are you absolutely sure?'})
	node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 20000, level = 20, text = 'Auhmm... Auhmm... Auhmm... Ahh... You are now ready.'})
	node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back when you are ready.', reset = true})

npcHandler:addModule(FocusModule:new())
 
Didn't work but maybe there is a problem in the npc file:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="King Tibianus" script="data/npc/scripts/promotion.lua" walkinterval="1000" floorchange="0">
    <health now="100" max="100"/>
    <look type="130" head="21" body="87" legs="107" feet="95" addons="0"/>
    <parameters>
        <parameter key="message_greet" value="Hi there, how's it hanging, |PLAYERNAME|!"/>
        <parameter key="message_farewell" value="Good bye, |PLAYERNAME|!"/>
        <parameter key="module_keywords" value="1" />
        <parameter key="keywords" value="hail king;job;promotion;" />
        <parameter key="keyword_reply1" value="I greet thee, my loyal subject |PLAYERNAME|." />
        <parameter key="keyword_reply2" value="I am your sovereign, King Tibianus III, and it's my duty to provide justice and guidance for my subjects." />
        <parameter key="keyword_reply3" value="Do you want to be promoted in your vocation for 20000 gold?" />

        <parameter key="module_shop" value="1"/>
        <parameter key="shop_sellable" value="" />
        <parameter key="shop_buyable" value="" />
    </parameters>
</npc>
 
Back
Top