• 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 Remove sendTrade msg when storage < 1 (TFS 0.3.6 pl1)

Mummrik

Hey!
Joined
Oct 22, 2007
Messages
707
Solutions
28
Reaction score
126
Location
Sweden
I do have a problem whit one of my npc's.
I got it working so it wont show the shopwindow if you dont have the storage needed to shop, but it still show the trade msg.
Is there any way to set the <parameter key="module_shop" value="1"/> from value 0 to 1 in the lua script?


blackbert.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Black Bert" script="data/npc/scripts/thais/blackbert.lua" walkinterval="2000" floorchange="0" access="5" level="1" maglevel="1">
   <health now="150" max="150"/>
   <look type="151" head="0" body="38" legs="19" feet="76" addons="0" />
     <parameters>
     <parameter key="module_shop" value="1"/>
     <parameter key="shop_buyable" value="
     bale of white cloth,7500,6000;
     bill,2329,8000;
     blood crystal,9141,50000;
     cigar,7499,2000;cookbook,2347,1000;
     damaged logbook,6124,40000;
     spellbook of dragha,6120,16000;
     empty beer bottle,7495,600;
     exploding cookie,8111,100;
     family brooch,2318,1000;
     signet ring,7697,15000;
     goldfish bowl,8764,7000;
     funeral urn,4858,6000;
     gemmed lamp-talk to npc-,2375,5000;
     ghost charm,9737,20000;
     ghost's tear,9662,50000;
     giant ape's hair,4843,24000;
     Julius' Map,9117,25000;
     letter to Markwin,2333,8000;
     letterbag,2330,8000;
     memory crystal,7242,500;
     memory stone,4852,3000;
     monk's diary,2325,3000;
     helmet,9735,8000;
     present,2331,16000;
     sheet of tracing paper,4853,500;
     sheet of tracing paper,4854,500;
     snake destroyer,4846,8000;
     special flask,7478,5000;
     spectral dress,4847,15000;
     spy report,2345,3000;
     strange powder,4849,5000;
     striker's favourite pillow,6105,16000;
     tear of daraman,2346,16000;
     technomancer beard,7699,5000;
     alchemists' formulas,9733,8000;
     dust of Arthei,9633,40000;
     dust of Boreth,9634,20000;
     dust of Lersatio,9635,25000;
     dust of Marziel,9636,30000;
     ring of the count,8752,10000;
     witches' grimoire,8702,25000;
     toy mouse,7487,16000;
     whisper moss,4838,18000;
     wrinkled parchment,4857,4000;"/>
     <parameter key="shop_sellable" value=""/>
   </parameters>
</npc>

blackbert.lua
Code:
-- TODO: make  the sendtrade msg disapear if you got < 1 storage
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)

   if(msgcontains(msg, 'name')) and npcHandler:isFocused(cid) then
     selfSay('Hey, I\'m Black Bert.', cid)   
   elseif(msgcontains(msg, 'trade')) or (msgcontains(msg, 'offer')) and npcHandler:isFocused(cid) and getPlayerStorageValue(cid, 21000) < 1 then
     closeShopWindow(cid)
     
   end

end
function onThink()         npcHandler:onThink()           end


npcHandler:setMessage(MESSAGE_GREET, "Hi there, |PLAYERNAME|! You look like you are eager to {trade}!")
npcHandler:setMessage(MESSAGE_FAREWELL, "Bye, |PLAYERNAME|!")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Bye!")
npcHandler:setMessage(MESSAGE_SENDTRADE, "Here, but pssst. And remember, no guarantee that you\'re able to use it. YOU have to know what you\'re buying there.")


npcHandler:addModule(FocusModule:new())
 
Top