luccagomes
New Member
- Joined
- Jul 30, 2015
- Messages
- 153
- Reaction score
- 1
I can buy, he give me, all is ok in game, but if i relog, i lose my promtion
Any know fix?
Any know fix?
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="The King" script="data/npc/scripts/promote.lua" walkinterval="2000" floorchange="0">
<mana now="800" max="800"/>
<health now="200" max="200"/>
<look type="332" head="21" body="87" legs="107" feet="95"/>
</npc>
Code:
local config = {
promote1 = 20000, -- preço da primeira promotion
promote2 = 10000000, -- preço da segunda promotion
rookPromote1 = {13, 10000}, -- {id da vocação, preço}
rookPromote2 = {14, 5000000} -- {id da vocação, preço}
}
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 creatureSayCallback(cid, type, msg)
msg = string.lower(msg)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if not npcHandler:isFocused(cid) then
return false
end
local price
if (getPlayerVocation(cid) >= 1 and getPlayerVocation(cid) <= 4) then
price = 20000
elseif (getPlayerVocation(cid) >= 5 and getPlayerVocation(cid) <= 8) then
price = 10000000
elseif (getPlayerVocation(cid) == 0) then
price = 10000
elseif (getPlayerVocation(cid) == 13) then
price = 5000000
end
if msgcontains(msg, 'hi') then
selfSay('Hello ' .. getPlayerName(cid) .. '! I sell promotions.')
elseif msgcontains(msg, 'promotion') or msgcontains(msg, 'promote') then
if (getPlayerLevel(cid) < 20 ) then
npcHandler:say("You need level 20 to be promoted!", cid)
return true
end
if getPlayerVocation(cid) == 0 or getPlayerVocation(cid) == config.rookPromote1[1] then
npcHandler:say('Do you want to buy promotion for ' .. price .. ' gold coins?', cid)
talkState[talkUser] = 2
elseif getPlayerVocation(cid) > 8 and getPlayerVocation(cid) < config.rookPromote1[1] then
selfSay('Sorry, you are already promoted.')
talkState[talkUser] = 0
elseif not isPremium(cid) and ((getPlayerVocation(cid) > 4 and getPlayerVocation(cid) < config.rookPromote1[1]) or getPlayerVocation(cid) == config.rookPromote1[1]) then
selfSay('Sorry, you must be premium to buy promotion.')
talkState[talkUser] = 0
else
selfSay('Do you want to buy promotion for ' .. price .. ' gold coins?')
talkState[talkUser] = 1
end
elseif talkState[talkUser] == 1 then
if msgcontains(msg, 'yes') then
if doPlayerRemoveMoney(cid, price) then
doPlayerSetVocation(cid, getPlayerVocation(cid) + 4)
selfSay('You are now promoted!')
else
selfSay('Sorry, you do not have enough money.')
end
end
talkState[talkUser] = 0
elseif talkState[talkUser] == 2 then
if getPlayerVocation(cid) == 0 then
if doPlayerRemoveMoney(cid, config.rookPromote1[2]) then
doPlayerSetVocation(cid, config.rookPromote1[1])
selfSay('You are now promoted!')
else
selfSay('Sorry, you do not have enough money.')
end
elseif getPlayerVocation(cid) == config.rookPromote1[1] then
if doPlayerRemoveMoney(cid, config.rookPromote2[2]) then
doPlayerSetVocation(cid, config.rookPromote2[1])
selfSay('You are now promoted!')
else
selfSay('Sorry, you do not have enough money.')
end
end
talkState[talkUser] = 0
elseif msgcontains(msg, 'bye') then
selfSay('Good bye, ' .. getPlayerName(cid) .. '!')
talkState[talkUser] = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())