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

Removing premium check

Xapuur

New Member
Joined
Sep 15, 2009
Messages
157
Reaction score
0
Location
Chile
Hello. I wanna remove premium check from NPC, this is the original script:

Code:
		[B]if(isPlayerPremiumCallback == nil or isPlayerPremiumCallback(cid) == true or parameters.premium == false) then[/B]
			local promotedVoc = getPromotedVocation(getPlayerVocation(cid))
			if(getPlayerStorageValue(cid, 30018) == TRUE) then
				npcHandler:say("You are already promoted!", cid)
			elseif(getPlayerLevel(cid) < parameters.level) then
				npcHandler:say("I am sorry, but I can only promote you once you have reached level " .. parameters.level .. ".", cid)
			elseif(doPlayerRemoveMoney(cid, parameters.cost) ~= TRUE) then
				npcHandler:say("You do not have enough money!", cid)
			else
				doPlayerSetVocation(cid, promotedVoc)
				npcHandler:say(parameters.text, cid)
			end
		else
			npcHandler:say("You need a premium account in order to get promoted.", cid)
		end
		npcHandler:resetNpc()
		return true
	end

I change:
Code:
if(isPlayerPremiumCallback == nil or isPlayerPremiumCallback(cid) == [COLOR="#B22222"]false[/COLOR]

And it works, (you are an elder druid), but the problem is when i buy again, he don't says me "you already promoted!", he sell me the promote again (removing money), and the worst is the "elder druid" change to "you have no vocation" :S Then, why the npc not check the promote if i only put false in check premmy?

Somebody can explain me, what is a nil value and "parameters.premium"?

Thanks & Regards
 
Last edited:
It isn't all the script.

The server is TFS 9.31:

npc\lib\npcsystem\modules.lua
Code:
	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(not npcHandler:isFocused(cid)) then
			return false
		end

		if(isPlayerPremiumCallback == nil or isPlayerPremiumCallback(cid) == true or parameters.premium == false) then
			local promotedVoc = getPromotedVocation(getPlayerVocation(cid))
			if(getPlayerStorageValue(cid, 30018) == TRUE) then
				npcHandler:say("You are already promoted!", cid)
			elseif(getPlayerLevel(cid) < parameters.level) then
				npcHandler:say("I am sorry, but I can only promote you once you have reached level " .. parameters.level .. ".", cid)
			elseif(doPlayerRemoveMoney(cid, parameters.cost) ~= TRUE) then
				npcHandler:say("You do not have enough money!", cid)
			else
				doPlayerSetVocation(cid, promotedVoc)
				npcHandler:say(parameters.text, cid)
			end
		else
			npcHandler:say("You need a premium account in order to get promoted.", cid)
		end
		npcHandler:resetNpc()
		return true
	end

npc/scripts/promotion.lua
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'}, 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, 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})

npcHandler:addModule(FocusModule:new())
 
Try:

PHP:
    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(not npcHandler:isFocused(cid)) then
            return false
        end
            local promotedVoc = getPromotedVocation(getPlayerVocation(cid))
            if(getPlayerStorageValue(cid, 30018) == TRUE) then
                npcHandler:say("You are already promoted!", cid)
            elseif(getPlayerLevel(cid) < parameters.level) then
                npcHandler:say("I am sorry, but I can only promote you once you have reached level " .. parameters.level .. ".", cid)
            elseif(doPlayerRemoveMoney(cid, parameters.cost) ~= TRUE) then
                npcHandler:say("You do not have enough money!", cid)
            else
                doPlayerSetVocation(cid, promotedVoc)
                npcHandler:say(parameters.text, cid)
            end
        npcHandler:resetNpc()
        return true
    end
 
Doesn't works :/. Is the same error, it not says me "you are already promoted!", it give me other promote and "you have no vocation"
 
Hm...

PHP:
    function StdModule.promotePlayer(cid, message, keywords, parameters, node)
        local npcHandler = parameters.npcHandler
        if(npcHandler == nil) then
            print('[Warning - ' .. getCreatureName(getNpcId()) .. '] NpcSystem:', 'StdModule.promotePlayer - Call without any npcHandler instance.')
            return false
        end

        if(not npcHandler:isFocused(cid)) then
            return false
        end

            if(getPlayerPromotionLevel(cid) >= parameters.promotion) then
                npcHandler:say('You are already promoted!', cid)
            elseif(getPlayerLevel(cid) < parameters.level) then
                npcHandler:say('I am sorry, but I can only promote you once you have reached level ' .. parameters.level .. '.', cid)
            elseif(not doPlayerRemoveMoney(cid, parameters.cost)) then
                npcHandler:say('You do not have enough money!', cid)
            else
                setPlayerPromotionLevel(cid, parameters.promotion)
                npcHandler:say(parameters.text, cid)
            end

        npcHandler:resetNpc()
        return true
    end
 
@esfomeado:
Code:
[01/01/2012 12:33:10] Lua Script Error: [Npc interface] 
[01/01/2012 12:33:11] data/npc/scripts/promotion.lua:onCreatureSay
[01/01/2012 12:33:11] data/npc/lib/npcsystem/modules.lua:78: attempt to call global 'getPlayerPromotionLevel' (a nil value)
[01/01/2012 12:33:11] stack traceback:
[01/01/2012 12:33:11] 	[C]: in function 'getPlayerPromotionLevel'
[01/01/2012 12:33:11] 	data/npc/lib/npcsystem/modules.lua:78: in function 'callback'
[01/01/2012 12:33:11] 	data/npc/lib/npcsystem/keywordhandler.lua:27: in function 'processMessage'
[01/01/2012 12:33:11] 	data/npc/lib/npcsystem/keywordhandler.lua:135: in function 'processNodeMessage'
[01/01/2012 12:33:11] 	data/npc/lib/npcsystem/keywordhandler.lua:110: in function 'processMessage'
[01/01/2012 12:33:11] 	data/npc/lib/npcsystem/npchandler.lua:387: in function 'onCreatureSay'
[01/01/2012 12:33:11] 	data/npc/scripts/promotion.lua:7: in function <data/npc/scripts/promotion.lua:7>
 
Rather than making this all dizzy, you could've just changed the storage check to a more simple vocation check.
LUA:
local promotedVoc = getPromotedVocation(getPlayerVocation(cid))
	if(getPlayerVocation(cid) == promotedVoc then
		npcHandler:say("You are already promoted!", cid)
	elseif(getPlayerLevel(cid) < parameters.level) then
		npcHandler:say("I am sorry, but I can only promote you once you have reached level " .. parameters.level .. ".", cid)
	elseif(doPlayerRemoveMoney(cid, parameters.cost) ~= TRUE) then
		npcHandler:say("You do not have enough money!", cid)
	else
		doPlayerSetVocation(cid, promotedVoc)
		npcHandler:say(parameters.text, cid)
	end
		npcHandler:resetNpc()
	return true
end
 
@Korrex:
Code:
[01/01/2012 15:19:24] Lua Script Error: [Npc interface] 
[01/01/2012 15:19:24] data/npc/scripts/promotion.lua
[01/01/2012 15:19:24] data/npc/scripts/promotion.lua:3: attempt to index global 'NpcSystem' (a nil value)
[01/01/2012 15:19:24] stack traceback:
[01/01/2012 15:19:24] 	[C]: in function '__index'
[01/01/2012 15:19:24] 	data/npc/scripts/promotion.lua:3: in main chunk
[01/01/2012 15:19:24] [Warning - NpcScript::NpcScript] Can not load script: data/npc/scripts/promotion.lua

And i not change anything of promotion.lua, i change only in modules.lua

And guys, i think that i have to change something in the first line, because there is the premium check, but what is? I don't know:
Code:
 if(isPlayerPremiumCallback == nil or isPlayerPremiumCallback(cid) == true or parameters.premium == false) then

If only somebody can explain me what is a "nil value"or "parameters.premium"..
 
Back
Top