Hello!
I wonder if there is any npc that promotes the player for the second time if the player get the first promotion. I am using this promotion at the moment:
↑ that script is working fine, it dont downgrades or anything... But I want that if, the player has promote himself once then promote him...
But before i used this:
The script i had before is not working... It gives the promotion but then when the player logsout, the server downgrades back the vocation once... And in localhost/phpmyadmin it says that the player is vocation 4, - knight for example...
I hope you understand what i mean.
Thx
Rep++
I wonder if there is any npc that promotes the player for the second time if the player get the first promotion. I am using this promotion at the moment:
LUA:
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'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can promote you for 20000 gold coins. Do you want me to promote you?'})
node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 20000, level = 20, promotion = 1, text = 'Congratulations! You are now promoted.'})
node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then, come back when you are ready.', reset = true})
local node2 = keywordHandler:addKeyword({'again'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can promote you for the second time for 200000 gold coins. Do you want me to promote you?'})
node2:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 200000, level = 120, promotion = 2, text = 'Congratulations! You are now Promoted.'})
node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then, come back when you are ready.', reset = true})
npcHandler:addModule(FocusModule:new())
But before i used this:
LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
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
local cfg = {vocs = { 5, 6, 7, 8 }}
local strv = 33300011
if(msgcontains(msg, 'promotion') or msgcontains(msg, 'promote')) then
selfSay('Do you want to promote you?', cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if getPlayerStorageValue(cid, strv) == -1 then
if getPlayerLevel(cid) >= 170 then
if isInArray(cfg.vocs, getPlayerVocation(cid)) == true then
if(doPlayerRemoveMoney(cid, 1000)) then
setPlayerPromotionLevel(cid, getPlayerPromotionLevel(cid) + 1)
setPlayerStorageValue(cid, strv, 1)
selfSay('Here you are.', cid)
else
selfSay('Sorry, you don\'t have enough gold.', cid)
end
else
selfSay('Sorry, you need to be promoted once before I can promote you.', cid)
end
else
selfSay('Sorry, you need level 220 to promote you.', cid)
end
else
selfSay('Sorry, you\'ve already been promoted.', cid)
end
talkState[talkUser] = 0
elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser])) then
talkState[talkUser] = 0
selfSay('Ok then.', cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
I hope you understand what i mean.
Thx
Rep++