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

Lua Premium can not buy promotion error

chupaescadatri

Banned User
Joined
Jul 5, 2014
Messages
338
Reaction score
49
NPC does not recognize who is premium,
even with premium he says that the player needs to premium and does not sell promotion.
and the boats did not recognize the premium and sells ticket to any city even for free accounts.
how to fix?

Config.lua:
Code:
    -- Premium account
    freePremium = false
    premiumForPromotion = true
    removePremiumOnInit = true
NPC/Scripts/Promotion.lua:

Code:
-- This is an example NPC script that can be used on Jiddo's NPC system

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
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
-- OTServ event handling functions end

local node1 = keywordHandler:addKeyword({'promotion'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to be promoted in your vocation for 20000 gold?'})
    node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, promotion = 1, cost = 20000,  premium = false, level = 20, text = 'Congratulations! You are now promoted.'})
    node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Allright then. Come back when you are ready.', reset = true})

npcHandler:addModule(FocusModule:new())
Modules.lua:
Code:
    --Usage:
        -- local node1 = keywordHandler:addKeyword({'promot'}, StdModule.say, {npcHandler = npcHandler, 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}, text = 'Congratulations! You are now promoted.')
        --         node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, text = 'Allright then. Come back when you are ready.'}, reset = true)
    function StdModule.promotePlayer(cid, message, keywords, parameters, node)
        local npcHandler = parameters.npcHandler
        if(npcHandler == nil) then
            error('StdModule.promotePlayer called without any npcHandler instance.')
        end
        if(cid ~= npcHandler.focus) then
            return false
        end

        if(isPremium(cid) or isPlayerPremiumCallback == nil or isPlayerPremiumCallback(cid) == true or parameters.premium == false) then
            local oldVoc = getPlayerVocation(cid)
            if(parameters.promotions[oldVoc] == oldVoc or parameters.promotions[oldVoc] == nil) then
                npcHandler:say('You are already promoted!')
            elseif(getPlayerLevel(cid) < parameters.level) then
                npcHandler:say('I am sorry, but I can only promote you once you have reached level ' .. parameters.level .. '.')
            elseif(doPlayerRemoveMoney(cid, parameters.cost) ~= TRUE) then
                npcHandler:say('You do not have enough money!')
            else
                doPlayerSetVocation(cid, parameters.promotions[oldVoc])
                npcHandler:say(parameters.text)
            end
        else
            npcHandler:say('Sorry, only premium characters are allowed to be promoted.')
        end
       
        npcHandler:resetNpc()
        return true
       
    end
 
Ok datapack is tfs 0.3 I guess, but tibia 7.6?
It's avesta or edited TFS? If it's edited TFS, then what version of TFS it is? 1.0? 1.1? 0.3.x? 0.2.x?

#EDIT

Any console errors?

#EDIT2
Replace:
Code:
if(isPremium(cid) or isPlayerPremiumCallback == nil or isPlayerPremiumCallback(cid) == true or parameters.premium == false) then

with:
Code:
if isPremium(cid) then
 
Last edited:
Ok datapack is tfs 0.3 I guess, but tibia 7.6?
It's avesta or edited TFS? If it's edited TFS, then what version of TFS it is? 1.0? 1.1? 0.3.x? 0.2.x?

#EDIT

Any console errors?

#EDIT2
Replace:
Code:
if(isPremium(cid) or isPlayerPremiumCallback == nil or isPlayerPremiumCallback(cid) == true or parameters.premium == false) then

with:
Code:
if isPremium(cid) then
did not work he does not recognize the same premium, he says that needs to be premium, and if I change to false he sells premium for everyone even for free account.
the Tfs 0.3.0 is for tibia 7.6 it is own. is not avesta is tibia 7.6 tfs 0.3.0,
http://sourceforge.net/p/otos/code/HEAD/tree/TheForgottenServer/
 
Put:
Code:
print('isPremium: ' .. type(isPremium) .. ', isPlayerPremiumCallback: ' .. type(isPlayerPremiumCallback) ..', parameters.premium: ' .. type(parameters.premium))

Before:
Code:
if(isPremium(cid) or isPlayerPremiumCallback == nil or isPlayerPremiumCallback(cid) == true or parameters.premium == false) then

And put in response console message.
 
Put:
Code:
print('isPremium: ' .. type(isPremium) .. ', isPlayerPremiumCallback: ' .. type(isPlayerPremiumCallback) ..', parameters.premium: ' .. type(parameters.premium))

Before:
Code:
if(isPremium(cid) or isPlayerPremiumCallback == nil or isPlayerPremiumCallback(cid) == true or parameters.premium == false) then

And put in response console message.
does not work, It was the same thing,
is there a script that reads the database the premdays?
because if there would give easier,
because that would put that 1 or more in premdays in mysql, give the npc sell.
or another alternative that works?
 
does not work, It was the same thing,
is there a script that reads the database the premdays?
because if there would give easier,
because that would put that 1 or more in premdays in mysql, give the npc sell.
or another alternative that works?

I said add this AND SHOW CONSOLE OUTPUT...
I know that it don't change any logic in script...

This change only print in console information if functions / variables exists
 
I said add this AND SHOW CONSOLE OUTPUT...
I know that it don't change any logic in script...

This change only print in console information if functions / variables exists
console, you say the message that appears on tfs, after sending the right command?
went blank, did not give any error but not sold to promotion
 
This is scripted for 0.3.7.
If there are any error's.. you may need to find and use functions related to 0.3.0
but.. the basic script is there, and should not be an issue.

Connect the NPC.xml to this lua file

data/npc/scripts/simple_promotion.lua

Code:
--[[
__.....__.._______...__....__.._______...___.....__..._______..
\.\..././.|__...__|.|..|.././.|__...__|.|...\...|..|.|__...__|.
.\.\././.....|.|....|..|././.....|.|....|....\..|..|....|.|....
..\.../......|.|....|..|/./......|.|....|..|\.\.|..|....|.|....
../...\......|.|....|.....\......|.|....|..|.\.\|..|....|.|....
././.\.\...__|.|....|..|\..\...__|.|....|..|..\....|..__|.|....
/_/...\_\.|_______|.|__| \__\.|_______|.|__|...\___|.|_______|.

https://otland.net/threads/premium-can-not-buy-promotion-error.237090/#post-2292188

]]--

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {} -- allows 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 greet(cid)     talkState[cid] = 0     return true   end -- removes any previous talkactions from players
function getNpcName()     return getCreatureName(getNpcId())   end -- allows you to get the NPC name.
   
function creatureSayCallback(cid, type, msg)
  if(not npcHandler:isFocused(cid)) then
  return false
  end
   
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

   -- find how much money player has on them
   local player_gold  = getPlayerItemCount(cid,2148)
  local player_plat  = getPlayerItemCount(cid,2152)*100
  local player_crys  = getPlayerItemCount(cid,2160)*10000
  local player_money  = player_gold + player_plat + player_crys

   -- generic greetings
   if msgcontains(msg, "job") then
     selfSay("My job is to promote players.", cid)
   elseif msgcontains(msg, "name") then
     selfSay("My name is " .. getNpcName() .. ".", cid)

   -- isPremium(cid) -- Lua made function
   -- getPlayerPremiumDays(cid) -- in the source
   -- I will use the one in the source.
   
   -- if already promoted, do nothing
   elseif msgcontains(msg, "promotion") and getPlayerPromotionLevel(cid) >= 1 then
     selfSay("You are already promoted.", cid)
     talkState[talkUser] = 0
   -- check if premium
   elseif msgcontains(msg, "promotion") and getPlayerPremiumDays(cid) < 1 then
     selfSay("I can only promote premium players.", cid)
     talkState[talkUser] = 0
     
   -- If not promoted allow for player to be promoted
   elseif msgcontains(msg, "promotion")then
     selfSay("You would like to be promoted for 20,000 gold coins?", cid)
     talkState[talkUser] = 1
   elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
     if player_money >= 20000 then
       doPlayerRemoveMoney(cid, 20000)
       doPlayerSetPromotionLevel(cid, getPlayerPromotionLevel(cid) + 1)
       selfSay("Wonderful! You have been promoted to ".. getPlayerVocationName(cid) .."! Congratulations on your promotion.", cid)
       talkState[talkUser] = 0
       npcHandler:releaseFocus(cid) -- Once they are promoted will lose focus on player.. you can remove if you want.
     else
       selfSay("You don't have enough money.", cid)
       talkState[talkUser] = 0
     end
    -- if they say anything other then yes, will cancel out
   elseif msgcontains(msg, "") and talkState[talkUser] == 1 then
     selfSay("Ah.. well no then.", cid)
     talkState[talkUser] = 0
   
   -- end if statement
   end
   -- return and end function creatureSayCallback
   return true   
end

npcHandler:setCallback(CALLBACK_GREET, greet)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Hey @chupaescadatri how about responding to this thread? let us know if @Xikini efforts worked out.. don't just not respond once you get the solution.. at least click the like link of the person who provided the solution and mark the thread as solved!
Code:
chupaescadatri was last seen:
Viewing thread Premium can not buy promotion error, 52 minutes ago
 
Hey @chupaescadatri how about responding to this thread? let us know if @Xikini efforts worked out.. don't just not respond once you get the solution.. at least click the like link of the person who provided the solution and mark the thread as solved!
Code:
chupaescadatri was last seen:
Viewing thread Premium can not buy promotion error, 52 minutes ago
I will test this script and tell if it worked, I will test coming home.
 
Well that's not useful information.
What error's are you receiving?
gave error in multiple lines of script, it's probably the fact that in 7.6 the NPC spoke in default.

also I tested another script that went wrong, but he did not recognize the premium.

has some way from script to a query on the table to see if it's premium? for the "account manager" in the script it uses database query code, example:
Code:
local query = db.getResult("select password from accounts where name = " .. db.escapeString(account.name[cid]) .. ";")
if query:getID() ~= -1 then
this is a piece of script account manager


there is a way to use the default script even posted it on top, but the npc sell only see that the query in premdays table has one or more days?
 
Back
Top