Hello. I wanna remove premium check from NPC on TFS 9.31, this is the original script (data\npc\lib\npcsystem\modules.lua):
In the first line i change:
[/COLOR]
And it works, (you are an elder druid without premmy acc), 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"?
This is the npc (data\npc\The Forgotten King.lua)
And promotion.lua (data\npc\scripts\promotion.lua)
Thanks & Regards
PS: If somebody don't understand my english, please alert me. I speak spanish :B
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
In the first line i change:
Code:
if(isPlayerPremiumCallback == [COLOR=#000000]nil or isPlayerPremiumCallback(cid) == [/COLOR][COLOR=#b22222]false[/COLOR][COLOR=#000000] or parameters.premium == false) then
And it works, (you are an elder druid without premmy acc), 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"?
This is the npc (data\npc\The Forgotten King.lua)
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="The Forgotten King" script="data/npc/scripts/promotion.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="133" head="20" body="39" legs="45" feet="7" addons="0"/>
</npc>
And promotion.lua (data\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())
Thanks & Regards
PS: If somebody don't understand my english, please alert me. I speak spanish :B