Exedion
Active Member
- Joined
- Jun 11, 2007
- Messages
- 628
- Reaction score
- 30
Here are the lotery npc script what need 200 vials for give you a lotery ticket!
(in global 100 xD) i made this script for my lotery ticket action! already release!!, well here we go again:
and for the npc:
(in global 100 xD) i made this script for my lotery ticket action! already release!!, well here we go again:
Code:
--------------------------------------------------------------------------------------------
------------------------------------ Advanced Addon NPC ------------------------------------
-------------------------------- Script made by teh_pwnage ---------------------------------
--------------- Special thanks to: mokerhamer, Xidaozu and Jiddo, deaths'life --------------
------------------------------- Thanks also to everyone else -------------------------------
------------------------------ NPC based on Evolutions V0.7.7 ------------------------------
--------------------------------------------------------------------------------------------
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
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(npcHandler.focus ~= cid) then
return false
end
addon_need_premium = 'Sorry, you need a premium account to buy lotery tickets.'
addon_have_already = 'Sorry, you already have win.'
addon_have_not_items = 'Sorry, you don\'t have these items.'
addon_give = 'Here you are.'
player_gold = getPlayerItemCount(cid,2148)
player_plat = getPlayerItemCount(cid,2152)*100
player_crys = getPlayerItemCount(cid,2160)*10000
player_money = player_gold + player_plat + player_crys
if msgcontains(msg, 'job') then
selfSay('I can give you a "lotery ticket" for 200 empty vials.')
elseif msgcontains(msg, 'help') then
selfSay('To buy the "lotery ticket", give me 200 vials.')
------------------------------------------------ addon ------------------------------------------------
elseif msgcontains(msg, 'lotery ticket') then
if isPremium(cid) then
if getPlayerItemCount(cid,2006) >= 200 then
selfSay('Did you bring me 200 vials for a lottery ticket?')
talk_state = 1
else
selfSay('I need 200 vials, to give you the lotery ticket. Come back when you have them.')
talk_state = 0
end
else
selfSay(addon_need_premium)
talk_state = 0
end
------------------------------------------------ confirm yes ------------------------------------------------
elseif msgcontains(msg, 'yes') and talk_state == 1 then
talk_state = 0
if getPlayerItemCount(cid,2006) >= 200 then
addon = getPlayerStorageValue(cid,40001)
if addon == -1 then
if doPlayerTakeItem(cid,2006,200) == 0 then
selfSay(addon_give)
doPlayerAddItem(cid,5957,1)
end
else
selfSay(addon_have_already)
end
else
selfSay(addon_have_not_items)
end
------------------------------------------------ confirm no ------------------------------------------------
elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 34) then
selfSay('Ok than.')
talk_state = 0
end
-- 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.
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
and for the npc:
Code:
<?xml version="1.0"?>
<npc name="Nancy" script="data/npc/scripts/lotery.lua" autowalk="1" floorchange="0">
<health now="100" max="100"/>
<look type="138" head="78" body="88" legs="0" feet="88" addons="3" />
</npc>