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

[release] Lotery Npc Script!

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:

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>
 
Looks like a very complicated npc to sell a single item, and its make from an addon npc...
 
Mate, you cant release it like this! i wanted to release my ticket seller an long time ago but with some problems.

Example.
An sorcerer has olwais mana fluids in his back and empty vials!

The bug is the npc will acsept everything! even vials with water>blood>Mana>urine it will acsept it because it is thinking it is an "empty" vial..

Try somting like this
getPlayerItemCount(cid,2006, 6) >= 200 then ---THis wont work

or Maby this wil work

removePlayerItemsWithCharges(cid, 2006, 6) >=200 then ---It should work since it is an vial code from jiddo
 
Back
Top