FabianoBN
l|¬¬"|l
I'm here to put an NPC that many who have the Global Map Server and does not move much with the script for the NPC trading Sandra Vial for Ticket through that one ticket can ganahr winning ticket system.
Version: 8.54 TFS 0.3.6
So here we go:
data/npc/ Create a file. xml with the name Sandra.
And put it:
Now in data/npc/scripts/ put it:
Talk to NPC:
Credits:
To Me!!
And Frankfarmer the base of the vial npc!!
That's it. Sorry my english ^^.
Please Rep++
Version: 8.54 TFS 0.3.6
So here we go:
data/npc/ Create a file. xml with the name Sandra.
And put it:
PHP:
<?xml version="1.0"?>
<npc name="Sandra" script="data/npc/scripts/sandra.lua" walkinterval="2000">
<health now="200" max="200" />
<look type="137" head="115" body="120" legs="121" feet="19" addons="0"/>
<parameters>
<parameter key="message_greet" value="Hello |PLAYERNAME|" />
<parameter key="shop_buyable" value="great spirit potion,8472,120;great mana potion,7590,120;great health potion,7591,190;strong health potion,7588,100;strong mana potion,7589,80;health potion,7618,45;mana potion,7620,50;ultimate health potion,8473,310" />
<parameter key="shop_sellable" value="empty potion flask,7634,5;empty potion flask,7635,5;empty potion flask,7636,5;vial,2006,5;" />
</parameters>
</npc>
Now in data/npc/scripts/ put it:
PHP:
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 onThink() npcHandler:onThink() end
-- OTServ event handling functions end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
function creatureSayCallback(cid, type, msg)
-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
if (not npcHandler:isFocused(cid)) then
return false
end
if msgcontains(msg, 'vial') then
npcHandler:say('We have a special offer right now for depositing vials. Are you interested in hearing it?', cid)
talk_state = 1
elseif msgcontains(msg, 'yes') and talk_state == 1 then
npcHandler:say('Great! I\'ve signed you up for our bonus for lottery {ticket}. From now on, you will have the chance to win the potion belt addon!', cid)
talk_state = 0
elseif msgcontains(msg, 'ticket') then
npcHandler:say('Would you like to get a lottery ticket instead of the {deposit} for your vials.', cid)
talk_state = 1
elseif msgcontains(msg, 'deposit') and talk_state == 1 then
if getPlayerItemCount(cid, 7636) >= 100 or getPlayerItemCount(cid, 7635) >= 100 or getPlayerItemCount(cid, 7634) >= 100 then
npcHandler:say('Congratulations! Here, from now on you can wear our lovely potion belt as accessory.', cid)
if doPlayerRemoveItem(cid, 7636,100) or doPlayerRemoveItem(cid, 7635,100) or doPlayerRemoveItem(cid, 7634,100) then
doPlayerAddItem(cid, 5957, 1)
talk_state = 0
else
npcHandler:say('Sorry you need 100 empty vials to you from the lottery ticket', cid)
talkState[talkUser] = 0
end
elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 3) then
npcHandler:say('Ok thanks.', cid)
talk_state = 0
end
return TRUE
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Talk to NPC:
Code:
hi
vial
yes
ticket
deposit
Credits:
To Me!!
And Frankfarmer the base of the vial npc!!
That's it. Sorry my english ^^.
Please Rep++
Attachments
-
npc.rar1.6 KB · Views: 51 · VirusTotal
Last edited: