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())