• 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 [NPC] Need help simple script - storage sqm & ticket/pass

Adi69

Active Member
Joined
Mar 14, 2008
Messages
161
Reaction score
35
Location
Poland
I'm Looking for a script, where if a player wants to go over the bridge must buy a ticket in NPC. The ticket or npc gives a storagevalue to player (ofcourse after pay - +/- 500gp)
If you can help me - please do it :)

Sorry for my english :)

exemplary screen:

 
Npc to sell ticket.

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local Topic = {}
[COLOR="red"][B]local ticket_id = XXXX
local ticket = 1000[/B][/COLOR]

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

function thinkCallback(cid)
	if math.random(500) == 1 then
		npcHandler:say("Buy your ticket's here!")
	end
	return true
end

function creatureSayCallback(cid, type, msg)
	if (msgcontains(msg, "hello") or msgcontains(msg, "hi")) and (not npcHandler:isFocused(cid)) then
		local v = getPlayerMoney(cid)
		if v < ticket then
			npcHandler:say(getPlayerSex(cid) == 0 and "Sorry ma'am, you need " .. ticket .. " gold." or "Sorry sir, you need " .. ticket .. " gold.", cid)
			Topic[cid] = 0
		else
			npcHandler:say("How can I help you?", cid)
			Topic[cid] = 1
		end
		npcHandler:addFocus(cid)
	elseif(not npcHandler:isFocused(cid)) then
		return false
	elseif msgcontains(msg, "no") then
		npcHandler:say("Then not.", cid, TRUE)
		Topic[cid] = 0
	elseif msgcontains(msg, "ticket") and Topic[cid] == 1 then
		npcHandler:say("Would you like to purchase a ticket for " .. ticket .. " gold coins?", cid)
		Topic[cid] = 2
	elseif Topic[cid] == 2 then
		if msgcontains(msg, "yes") then
			if doPlayerRemoveMoney(cid, ticket) then
				npcHandler:say("Here you are.", cid)
				doPlayerAddItem(cid, ticket_id, 1)
				Topic[cid] = 0
			else
				npcHandler:say("Sorry, you don't have enough money.", cid)
				Topic[cid] = 1
			end
		elseif msgcontains(msg, "no") then
			npcHandler:say("Okay then.", cid)
			Topic[cid] = 0
		end
	elseif msgcontains(msg, "bye") or msgcontains(msg, "farewell") then
		npcHandler:say("Good bye.", cid, TRUE)
		Topic[cid] = nil
		npcHandler:releaseFocus(cid)
	end
	
	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:setMessage(MESSAGE_WALKAWAY, "How rude!")
npcHandler:setCallback(CALLBACK_ONTHINK, thinkCallback)
 
Last edited:
Hmm, script moveevent works good! So the script of npc working bad.
I have error like this:



If i say hi and i have 500gold than:
09:02 GOD Adi: hi
09:02 Roney Smithson: How can I help you?

And nothing happens after that.

If i say hi and i don;t have 500gp than:
09:03 GOD Adi: hi
09:03 Roney Smithson: Sorry ma'am, you need 500 gold.

And nothing happens after that.


the script of npc looks that:

<?xml version="1.0" encoding="UTF-8"?>
<npc name="Roney Smithson" script="przejscie.lua" walkinterval="2000" floorchange="0">
<health now="150" max="150"/>
<look type="268" head="38" body="33" legs="38" feet="132" addons="0" corpse="2212"/>
<parameters>
<parameter key="module_shop" value="1"/>
<parameter key="message_greet" value="Welcome on Atlantyda my friend!"/>
<parameter key="shop_sellable" value="ticket,7722,500;"/>
</parameters>
</npc>



And JDB or someone other, if you can, can do so that after passing the ticket disappear/ticket has ben destroyed?
 
Updated the post ABOVE!

Remove this..

<parameters>
<parameter key="module_shop" value="1"/>
<parameter key="message_greet" value="Welcome on Atlantyda my friend!"/>
<parameter key="shop_sellable" value="ticket,7722,500;"/>
</parameters>

You don't need anything in the NPC.xml, I made it all in the file.
 
I send this msg to JDB so he don't answer me :(

So someone can help mi with one thing?
When player go over the bridge, the ticket id change from 7722 to 7733
Otherwise you can use the ticket many times... so it stopped it


Thanks in advance :)
 
Back
Top