• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

NPC Rashid - with TradeRequest and anti spam! ;) ver.1

andypsylon

be be
Joined
Jan 13, 2009
Messages
772
Reaction score
65
Location
de/pl
Rashid - with TradeRequest and anti spam! ;) ver.2

test on tfs v.0.4
real tibia Rashid!! - Rashid - TibiaWiki - Quests, Items, Spells, and more
and antispam :)

xml file - yourot/data/npc/Rashid.xml
XML:
-- ver.2, 2011-11-08
-- andypsylon (otland.net)

<?xml version="1.0" encoding="UTF-8"?>
<npc name="Rashid" script="rashid.lua" walkinterval="5000">
	<look type="146" head="119" body="118" legs="119" feet="132" addons="3" />
	<parameters>
		<parameter key="message_greet" value="Ah, a customer! Be greeted, |PLAYERNAME|!" />
		<parameter key="message_sendtrade" value="Take all the time you need to decide what you want!" />
		<parameter key="message_needmoremoney" value="You dont have not enough of gold." />
		<parameter key="message_decline" value="|TOTALCOST| is a very good price |PLAYERNAME|." />
		<parameter key="message_farewell" value="Farewell, |PLAYERNAME|, may the winds guide your way." />
		<parameter key="message_walkaway" value="Come back soon!" />
		<parameter key="message_idletimeout" value="Good bye, |PLAYERNAME|!" />

		<parameter key="module_keywords" value="1" />
		<parameter key="keywords" value="job;name;offers;ab\'dendriel;desert;karmia;cormaya;darashia;premy island;bibula;greenshore;moria;blood bay;northport;port hope;senja;svargrond;thalia;vega;venore;time;king" />
		<parameter key="keyword_reply1" value="I am a travelling trader. I don't buy everything, though. And not from everyone, for that matter." />
		<parameter key="keyword_reply2" value="I am Rashid, son of the desert." />
		<parameter key="keyword_reply3" value="Of course, old friend. You can also browse only armor, legs, shields, helmets, boots, weapons, enchanted weapons, jewelry or miscellaneous stuff." />
		<parameter key="keyword_reply4" value="Elves... I don't really trust them. All this talk about nature and flowers and treehugging... I'm sure there's some wicked scheme behind all this." />
		<parameter key="keyword_reply5" value="My beloved hometown! Ah, the sweet scent of the desert sands, the perfect shape of the pyramids... stunningly beautiful." />
		<parameter key="keyword_reply6" value="I have to go to Karmia once in a while, since the queen wishes to see my exclusive wares in regular intervals." />
		<parameter key="keyword_reply7" value="Cormaya? Not a good place to make business, it's way too far and small." />
		<parameter key="keyword_reply8" value="It's not the real thing, but almost as good. The merchants there claim ridiculous prices, which is fine for my own business." />
		<parameter key="keyword_reply9" value="Ah yes, Premy Island! Such a lovely and quiet island! I usually make some nice business there." />
		<parameter key="keyword_reply10" value="Too few customers there, it's not worth the trip." />
		<parameter key="keyword_reply11" value="Um... I don't think so." />
		<parameter key="keyword_reply12" value="I don't like being underground much. I also tend to get lost in these labyrinthine dwarven tunnels, so I rather avoid them." />
		<parameter key="keyword_reply13" value="When you avoid the slums, it's a really pretty city. Almost as pretty as the governor's daughter." />
		<parameter key="keyword_reply14" value="Um... I don't think so." />
		<parameter key="keyword_reply15" value="I like the settlement itself, but I don't set my foot into the jungle. Have you seen the size of these centipedes??" />
		<parameter key="keyword_reply16" value="Um... I don't think so." />
		<parameter key="keyword_reply17" value="I wish it was a little bit warmer there, but with a good mug of barbarian mead in your tummy everything gets a lot cosier." />
		<parameter key="keyword_reply18" value="I feel uncomfortable and rather unsafe in Thalia, so I don't really travel there." />
		<parameter key="keyword_reply19" value="Um... I don't think so." />
		<parameter key="keyword_reply20" value="Although it's the flourishing trade centre of Tibia, I don't like going there. Too much competition for my taste." />
		<parameter key="keyword_reply21" value="It's almost time to journey on." />
		<parameter key="keyword_reply22" value="Kings, queens, emperors and kaliphs... everyone claims to be different and unique, but actually it's the same thing everywhere." />

		<parameter key="module_shop" value="1" />
		<parameter key="shop_buyable" value="" />
		<parameter key="shop_sellable" value="
			abyss hammer,			7414, 20000;
			amber staff,			7426, 8000;
			ancient amulet,			2142, 200;
			assassin daggerf,		7404, 20000;
			bandana,				5917, 150;
			beastslayer axe,		3962, 1500;
			berserker,				7403, 40000;
			bone shield,			2541, 80;
			bonelord helmet,		3972, 7500;
			brutetamer's staff,		7379, 1500;
			castle shield,			2535, 5000;
			chain bolter,			8850, 40000;
			chaos mace,				7427, 9000;
			cobra crown,			12630, 50000;
			coconut shoes,			9931, 500;
			composite hornbow,		8855, 25000;
			cranial basher,			7415, 30000;
			crocodile boots,		3982, 1000;
			crystal mace,			2445, 12000;
			crystal necklace,		2125, 400;
			crystal ring,			2124, 250;
			crystal sword,			7449, 600;
			crystalline armor,		8878, 16000;
			daramanian mace,		2439, 110;
			daramanian waraxe,		2440, 1000;
			dark shield,			2521, 400;
			death ring,				6300, 1000;
			demon shield,			2520, 30000;
			demonbone amulet,		2136, 32000;
			demonrage sword,		7382, 36000;
			devil helmet,			2462, 1000;
			diamond sceptre,		7387, 3000;
			djinn blade,			2451, 15000;
			doll,					2110, 200;
			dragon scale mail,		2492, 40000;
			dragon slayer,			7402, 15000;
			dragonbone staff,		7430, 3000;
			dreaded cleaver,		7419, 10000;
			dwarven armor,			2503, 30000;
			earth cranial basher,	7866, 30000;
			earth dragon slayer,	7858, 15000;
			earth heroic axe,		7861, 30000;
			earth mystic blade,		7856, 30000;
			earth relic sword,		7855, 25000;
			earth war axe,			7863, 12000;
			emerald bangle,			2127, 800;
			energy cranial basher,	7881, 30000;
			energy dragon slayer,	7873, 15000;
			energy heroic axe,		7876, 30000;
			energy mystic blade,	7871, 30000;
			energy relic sword,		7870, 25000;
			energy war axe,			7878, 12000;
			epee,					2438, 8000;
			fiery cranial basher,	7756, 30000;
			fiery dragon slayer,	7748, 15000;
			fiery heroic axe,		7751, 30000;
			fiery mystic blade,		7746, 30000;
			fiery relic sword,		7745, 25000;
			fiery war axe,			7753, 12000;
			flower wreath,			9927, 500;
			fur boots,				7457, 2000;
			furry club,				7432, 1000;
			glacier amulet,			7888, 1500;
			glacier kilt,			7896, 11000;
			glacier mask,			7902, 2500;
			glacier robe,			7897, 11000;
			glacier shoes,			7892, 2500;
			gold ring,				2179, 8000;
			golden armor,			2466, 20000;
			golden legs,			2470, 30000;
			guardian halberd,		2427, 11000;
			hammer of wrath,		2444, 30000;
			heavy mace,				2452, 50000;
			heavy machete,			2442, 90;
			heroic axe,				7389, 30000;
			hibiscus dress,			8873, 3000;
			icy cranial basher,		7775, 30000;
			icy dragon slayer,		7767, 15000;
			icy heroic axe,			7770, 30000;
			icy mystic blade,		7765, 30000;
			icy relic sword,		7764, 25000;
			icy war axe,			7772, 12000;
			jade hammer,			7422, 25000;
			krimhorn helmet,		7461, 200;
			lavos armor,			8877, 16000;
			leaf legs,				9928, 500;
			leopard armor,			3968, 1000;
			light shovel,			5710, 300;
			lightning boots,		7893, 2500;
			lightning headband,		7901, 2500;
			lightning legs,			7895, 11000;
			lightning pendant,		7889, 1500;
			lightning robe,			7898, 11000;
			lunar staff,			7424, 5000;
			magic plate armor,		2472, 90000;
			magma amulet,			7890, 1500;
			magma boots,			7891, 2500;
			magma coat,				7899, 11000;
			magma legs,				7894, 11000;
			magma monocle,			7900, 2500;
			mammoth fur cape,		7463, 6000;
			mammoth fur shorts,		7464, 850;
			mammoth whopper,		7381, 300;
			mastermind shield,		2514, 50000;
			medusa shield,			2536, 9000;
			mercenary sword,		7386, 12000;
			mystic blade,			7384 ,30000;
			naginata,				2426, 2000;
			nightmare blade,		7418, 35000;
			noble axe,				7456, 10000;
			norse shield,			7460, 1500;
			paladin armor,			8891, 15000;
			patched boots,			2641, 2000;
			pharaoh sword,			2446, 23000;
			pirate boots,			5462, 3000;
			pirate hat,				6096, 1000;
			pirate knee breeches,	5918, 200;
			pirate shirt,			6095, 500;
			pirate voodoo doll,		5810, 500;
			platinum amulet,		2171, 2500;
			ragnir helmet,			7462, 400;
			relic sword,			7383, 25000;
			ring of the sky,		2123, 30000;
			ruby necklace,			2133, 2000;
			ruthless axe,			6553, 45000;
			sacred tree amulet,		10219, 3000;
			sapphire hammer,		7437, 7000;
			scarab amulet,			2135, 200;
			scarab shield,			2540, 2000;
			shockwave amulet,		10221, 3000;
			silver brooch,			2134, 150;
			silver dagger,			2402, 500;
			skull helmet,			5741, 40000;
			skullcracker armor,		8889, 18000;
			spiked squelcher,		7452, 5000;
			steel boots,			2645, 30000;
			swamplair armor,		8880, 16000;
			taurus mace,			7425, 500;
			tempest shield,			2542, 35000;
			terra amulet,			7887, 1500;
			terra boots,			7886, 2500;	
			terra hood,				7903, 2500;
			terra legs,				7885, 11000;
			terra mantle,			7884, 11000;
			tortoise shield,		6131, 150;
			vile axe,				7388, 30000;
			voodoo doll,			3955, 400;
			war axe,				2454, 12000;
			wyvern fang,			7408, 1500
		" />
	</parameters>
</npc>

lua script - yourots/data/npc/scripts/rashid.lua
Lua:
-- ver.2, 2011-11-08
-- andypsylon (otland.net)
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)	end
function onThink()						npcHandler:onThink()						end
function onPlayerEndTrade(cid)			npcHandler:onPlayerEndTrade(cid)			end
function onPlayerCloseChannel(cid)		npcHandler:onPlayerCloseChannel(cid)		end

local RASHID_STORAGE_KEY = 40000
local RASHID_STORAGE_TIME = 40001
local RASHID_TIME = 2*3600 		-- ?h*3600sek
local RASHID_STORAGE_SPAM = 40002
local RASHID_SPAM = 16			-- how many times can to spam
local SPAM_PRICE = 30000		-- gp

function mission(cid)
	if(not npcHandler:isFocused(cid)) then return false end

	local CZAS = getCreatureStorage(cid, RASHID_STORAGE_TIME)
	local KEY = getCreatureStorage(cid, RASHID_STORAGE_KEY)
	local SPAM = getCreatureStorage(cid, RASHID_STORAGE_SPAM)
	local poz_m = math.floor((RASHID_TIME - (os.time() - CZAS))/60)

	local rashid_miraia = 40004
	local getRashid_miraia = getCreatureStorage(cid, rashid_miraia)

	if ((os.time() - CZAS) <= RASHID_TIME) then
		selfSay("I told you. I don't have time now. Remember! Please come to me for " .. poz_m .. "min again!", cid)
		npcHandler:resetNpc()
		return false
	elseif SPAM >= RASHID_SPAM then
		doCreatureSetStorage(cid, RASHID_STORAGE_TIME, -1)
		selfSay("Spammer?! Aha! Now you have to pay " .. SPAM_PRICE .. "gold. Do you have enough?", cid)
	elseif KEY == 7 then
		selfSay("You have already completed my mission. Thank you for that!", cid)
	elseif KEY == -1 and os.date("%A") ~= "Monday" then
		selfSay("Komm am Montag zu mir, to pogadamy.", cid)

	elseif os.date("%A") == "Monday" then
		if KEY == -1 then
			selfSay("Well, you could attempt the mission to become a recognised trader, but it requires a lot of travelling. Are you willing to try?", cid)
		elseif KEY == 11 then
			selfSay("Have you managed to obtain a rare deer trophy for my customer?", cid)
		end
	elseif os.date("%A") == "Tuesday" then
		if KEY == 1 then
			selfSay("So, my friend, are you willing to proceed to the next mission to become a recognised trader?", cid)
		elseif KEY == 12 then
			selfSay("Did you bring me the package?", cid)
		end
	elseif os.date("%A") == "Wednesday" then
		if KEY == 2 then
			selfSay("So, my friend, are you willing to proceed to the next mission to become a recognised trader?", cid)
		elseif KEY == 13 then
			if getRashid_miraia == 1 then
				selfSay("Have you brought the cheese?", cid)
			elseif getRashid_miraia == 0 then
				selfSay("Cos mi tu smierdzi z tym serem... chyba nie przyszedles tu z buta.", cid)
				return false
			end
		end
	elseif os.date("%A") == "Thursday" then
		if KEY == 3 then
			selfSay("So, my friend, are you willing to proceed to the next mission to become a recognised trader?", cid)
		elseif KEY == 14 then
			selfSay("Have you brought the vase?", cid)
		end
	elseif os.date("%A") == "Friday" then
		if KEY == 4 then
			selfSay("So, my friend, are you willing to proceed to the next mission to become a recognised trader?", cid)
		elseif KEY == 15 then
			selfSay("Have you brought a cheap but good crimson sword?", cid)
		end
	elseif os.date("%A") == "Saturday" then
		if KEY == 5 then
			selfSay("So, my friend, are you willing to proceed to the next mission to become a recognised trader?", cid)
		elseif KEY == 16 then
			selfSay("Have you brought me a gold fish?", cid)
		end
	elseif os.date("%A") == "Sunday" then
		if KEY == 6 then
			selfSay("Ah, right. <ahem> I hereby declare you - one of my recognised traders! Feel free to offer me your wares!", cid)
			doCreatureSetStorage(cid, RASHID_STORAGE_KEY, 7) 
		end
	end
	return true
end

function acceptFirst(cid)
	if(not npcHandler:isFocused(cid)) then return false end

	local KEY = getCreatureStorage(cid, RASHID_STORAGE_KEY)
	local SPAM = getCreatureStorage(cid, RASHID_STORAGE_SPAM)

	if SPAM >= RASHID_SPAM then
		if doPlayerRemoveMoney(cid, SPAM_PRICE) then
			doCreatureSetStorage(cid, RASHID_STORAGE_SPAM, -1)
			selfSay("Ok. Now you can do {mission}.", cid)
		else
			selfSay("You do not have money!", cid)
		end
		return true
-- Monday
	elseif KEY == -1 then
		npcHandler:say("Very good! I need talented people who are able to handle my wares with care, find good offers and the like, so I'm going to test you. ...", cid)
		npcHandler:say("First, I'd like to see if you can dig up rare wares. Something like a ... {mastermind shield}! ...", cid, 4000)
		npcHandler:say("Haha, just kidding, fooled you there, didn't I? Always control your nerves, that's quite important during bargaining. ...", cid, 8000)
		npcHandler:say("Okay, all I want from you is one of these rare deer trophies. I have a customer here in Svargrond who ordered one, so I'd like you to deliver it tome while I'm in Svargrond. ...", cid, 12000)
		npcHandler:say("Everything clear and understood?", cid, 16000)
	elseif KEY == 11 then
		if doPlayerTakeItem(cid, 7397, 1) then
			doCreatureSetStorage(cid, RASHID_STORAGE_KEY, 1) -- teraz do Tuesday
			selfSay("Well done! I'll take that from you. <snags it> Come see me another day, I'll be busy for a while now.", cid)
		else
			selfSay("You do not have those items!", cid)
		end
		npcHandler:resetNpc()
-- Tuesday
	elseif KEY == 1 then
		npcHandler:say("Alright, that's good to hear. From you as my trader and deliveryman, I expect more than finding rare items. ...", cid)
		npcHandler:say("You also need to be able to transport heavy wares, weaklings won't get far here. I have ordered a special package from Premy Island. ...", cid, 4000)
		npcHandler:say("Pick it up from {Willard} and bring it back to me while I'm in {Blood Bay}. Everything clear and understood?", cid, 8000)
	elseif KEY == 12 then
		if doPlayerTakeItem(cid, 7503, 1) then 
			doCreatureSetStorage(cid, RASHID_STORAGE_KEY, 2) -- teraz do Wednesday
			selfSay("Great. Just place it over there - yes, thanks, that's it. Come see me another day, I'll be busy for a while now.", cid)
		else
			selfSay("You do not have those items!", cid)
		end
		npcHandler:resetNpc()
-- Wednesday
	elseif KEY == 2 then
		npcHandler:say("Well, that's good to hear. From you as my trader and deliveryman, I expect more than carrying heavy packages. ...", cid)
		npcHandler:say("You also need to be fast and deliver wares in time. I have ordered a very special cheese wheel made from Darashian milk. ...", cid, 4000)
		npcHandler:say("Unfortunately, the high temperature in the desert makes it rot really fast, so it must not stay in the sun for too long. ...", cid, 8000)
		npcHandler:say("I'm also afraid that you might not be able to use ships because of the smell of the cheese. ...", cid, 12000)
		npcHandler:say("Please get the cheese from Miraia and bring it to me while I'm in Tiquanda. Everything clear and understood?", cid, 16000)
	elseif KEY == 13 then
		if doPlayerTakeItem(cid, 8368, 1) then
			doCreatureSetStorage(cid, RASHID_STORAGE_KEY, 3) -- teraz do Thursday
			selfSay("Mmmhh, the lovely odeur of scarab cheese! I really can't understand why most people can't stand it. Thanks, well done!", cid)
		else
			selfSay("You do not have those items!", cid)
		end
		npcHandler:resetNpc()
-- Thursday
	elseif KEY == 3 then
		npcHandler:say("Well, that's good to hear. From you as my trader and deliveryman, I expect more than bringing stinky cheese. ...", cid)
		npcHandler:say("I wonder if you are able to deliver goods so fragile they almost break when looked at. ...", cid, 4000)
		npcHandler:say("I have ordered a special elven vase from Briasol in Ab'Dendriel. Get it from him and don't even touch it, just bring it to me while I'm in Desert. Everything clear and understood?", cid, 8000)
	elseif KEY == 14 then
		if doPlayerTakeItem(cid, 7582, 1) then
			doCreatureSetStorage(cid, RASHID_STORAGE_KEY, 4) -- teraz do Friday
			selfSay("I'm surprised that you managed to bring this vase without a single crack. That was what I needed to know, thank you.", cid)
		else
			selfSay("You do not have those items!", cid)
		end
		npcHandler:resetNpc()
-- Friday
	elseif KEY == 4 then
		npcHandler:say("Fine! There's one more skill that I need to test and which is cruicial for a successful trader. ...", cid)
		npcHandler:say("Of course you must be able to haggle, else you won't survive long in this business. To make things as hard as possible for you, I have the perfect trade partner for you. ...", cid, 3000)
		npcHandler:say("Dwarves are said to be the most stubborn of all traders. Travel to Moria and try to get the smith Uzgod to sell a crimson sword to you. ...", cid, 8000)
		npcHandler:say("Of course, it has to be cheap. Don't come back with anything more expensive than 400 gold. ...", cid, 12000)
		npcHandler:say("And the quality must not suffer, of course! Everything clear and understood?", cid, 16000)
	elseif KEY == 15 then
		if doPlayerTakeItem(cid,11395, 1) then
			doCreatureSetStorage(cid, RASHID_STORAGE_KEY, 5) -- teraz do Saturday
			selfSay("Ha! You are clever indeed, well done! I'll take this from you. Come see me tomorrow, I think we two might get into business after all.", cid)
		else
			selfSay("You do not have those items!", cid)
		end
		npcHandler:resetNpc()
-- Saturday
	elseif KEY == 5 then
		npcHandler:say("My friend, it seems you have already learnt a lot about the art of trading. I think you are more than worthy to become a recognised trader. ...", cid)
		npcHandler:say("There is just one little favour that I would ask from you... something personal, actually, forgive my boldness. ...", cid, 3000)
		npcHandler:say("I have always dreamed to have a small pet, one that I could take with me and which wouldn't cause problems. ...", cid, 8000)
		npcHandler:say("Could you - just maybe - bring me a small goldfish in a bowl? I know that you would be able to get one, wouldn't you?", cid, 12000)
	elseif KEY == 16 then
		if doPlayerTakeItem(cid, 8766, 1) then
			doCreatureSetStorage(cid, RASHID_STORAGE_KEY, 6) -- teraz do Sunday
			selfSay("Thank you!! Ah, this makes my day! I'll take the rest of the day off to get to know this little guy. Come see me tomorrow, if you like.", cid)
		else
			selfSay("You do not have those items!", cid)
		end
		npcHandler:resetNpc()
	end
	return true
end

function acceptSecond(cid)
	if(not npcHandler:isFocused(cid)) then return false end
	
	local KEY = getCreatureStorage(cid, RASHID_STORAGE_KEY)
-- Monday
	if KEY == -1 then
		selfSay("Fine. Then get a hold of that {deer trophy} and bring it to me while I'm in Svargrond. Just ask me about your mission.", cid)
		doCreatureSetStorage(cid, RASHID_STORAGE_KEY, 11)
-- Tuesday
	elseif KEY == 1 then
		selfSay("Fine. Then off you go, just ask {Willard} about the {package for Rashid}.", cid)
		doCreatureSetStorage(cid, RASHID_STORAGE_KEY, 12)
-- Wednesday
	elseif KEY == 2 then
		selfSay("Okay, then please find Miraia in Darashia  and ask her about the {scarab cheese}.", cid)
		doCreatureSetStorage(cid, RASHID_STORAGE_KEY, 13)
-- Thursday
	elseif KEY == 3 then
		selfSay("Okay, then please find Briasol in Ab'Dendriel  and ask for a {fine vase}.", cid)
		doCreatureSetStorage(cid, RASHID_STORAGE_KEY, 14)
-- Friday
	elseif KEY == 4 then
		selfSay("Okay, I'm curious how you will do with Uzgod. Good luck!", cid)
		doCreatureSetStorage(cid, RASHID_STORAGE_KEY, 15)
-- Saturday
	elseif KEY == 5 then
		selfSay("Thanks so much! I'll be waiting eagerly for your return then.", cid)
		doCreatureSetStorage(cid, RASHID_STORAGE_KEY, 16)
	end

	doCreatureSetStorage(cid, RASHID_STORAGE_SPAM, -1)
	npcHandler:resetNpc()
	return true
end

function decline(cid)
	if(not npcHandler:isFocused(cid)) then return false end
	selfSay("Oh well, maybe some other time then.", cid)
	npcHandler:resetNpc()
	return true
end

local mission = keywordHandler:addKeyword({'mission'}, mission)
local first = mission:addChildKeyword({'yes'}, acceptFirst)
	first:addChildKeyword({'yes'}, acceptSecond)
	first:addChildKeyword({'no'}, decline)
	mission:addChildKeyword({'no'}, decline)

function rashidSell(cid, itemid, subType, amount, ignoreCap, inBackpacks)
	local MISJA = getCreatureStorage(cid, RASHID_STORAGE_KEY)
	local CZAS = getCreatureStorage(cid, RASHID_STORAGE_TIME)
	local SPAM = getCreatureStorage(cid, RASHID_STORAGE_SPAM)
	local poz_m = math.floor((RASHID_TIME - (os.time() - CZAS))/60)

	if (MISJA ~= 7) then
		if CZAS >= os.time() then
			doCreatureSetStorage(cid, RASHID_STORAGE_TIME, os.time())
			selfSay("Sorry. I don't have time now. Please come to me for " .. poz_m .. "min again!", cid)
			return false
		elseif SPAM == (RASHID_SPAM - 3) then
			selfSay("Continue spamming. Then you lose all your missions!!! Repurchase is a very costly.", cid)
			doCreatureSetStorage(cid, RASHID_STORAGE_SPAM, SPAM + 1)
			return false
		elseif SPAM == (RASHID_SPAM - 1) then
			selfSay("OK exaggerated, All the missions you have to start over. And pay".. SPAM_PRICE .."GOLD!", cid)
			doCreatureSetStorage(cid, RASHID_STORAGE_SPAM, RASHID_SPAM)
			doCreatureSetStorage(cid, RASHID_STORAGE_KEY, -1)
			doCreatureSetStorage(cid, RASHID_STORAGE_TIME, -1)
			npcHandler:resetNpc()
			return false
		elseif (((os.time() - CZAS)) < RASHID_TIME) and (MISJA ~= 7) then
			if CZAS < (os.time() - 300) then
				doCreatureSetStorage(cid, RASHID_STORAGE_TIME, CZAS + 120)
			end
			doCreatureSetStorage(cid, RASHID_STORAGE_SPAM, SPAM + 1)
			selfSay("I told you. I don't have time now. Please come to me for " .. poz_m .. "min again! Remember it!", cid)
			npcHandler:resetNpc()
			return false
		else
			selfSay("Oh, no, no! You need to do {mission}!!!", cid)
			doCreatureSetStorage(cid, RASHID_STORAGE_SPAM, SPAM + 1)
			npcHandler:resetNpc()
		end
	else
		return true
	end
	return false
end

function onTradeRequest(cid)
	return getCreatureStorage(cid, RASHID_STORAGE_SPAM) <= RASHID_SPAM
end
npcHandler:setCallback(CALLBACK_ONTRADEREQUEST, onTradeRequest)
-- npcHandler:setCallback(CALLBACK_ONBUY, rashidBuy)
npcHandler:setCallback(CALLBACK_ONSELL, rashidSell)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
you need "onTradeRequest" in system
 
Last edited:
in globalevents.xml :
<globalevent name="rashid" interval="1800000" event="script" value="my/rashid.lua"/>

and rashid.lua
Lua:
local config = {
    ["Monday"]		= {pos = {x=820, y=155, z=7},	frompos = {x=810, y=145, z=7},	topos = {x=830, y=165, z=7}},
    ["Tuesday"]		= {pos = {x=375, y=406, z=7},	frompos = {x=365, y=396, z=7},	topos = {x=385, y=416, z=7}},
    ["Wednesday"]	= {pos = {x=1165, y=451, z=5},	frompos = {x=1155, y=441, z=5},	topos = {x=1175, y=461, z=5}},
    ["Thursday"]	= {pos = {x=1000, y=493, z=5},	frompos = {x=990, y=483, z=5},	topos = {x=1010, y=503, z=5}},
    ["Friday"]		= {pos = {x=746, y=523, z=6},	frompos = {x=741, y=520, z=6},	topos = {x=747, y=525, z=6}},
    ["Saturday"]	= {pos = {x=1110, y=692, z=7},	frompos = {x=1100, y=682, z=7},	topos = {x=1120, y=702, z=7}},
    ["Sunday"]		= {pos = {x=1088, y=497, z=7},	frompos = {x=1078, y=487, z=7},	topos = {x=1098, y=507, z=7}}
}

function onThink(interval)
	local dzienTygodnia = config[os.date("%A")]
	local npck = getCreatureByName("Rashid")

	if isNpc(npck) then
		if (isInRange(getThingPosition(npck), dzienTygodnia.frompos, dzienTygodnia.topos)) then
			return true
		else
			doCreatureSay(npck, "See you, now I'm going to the next city!", TALKTYPE_SAY)
			addEvent(doTeleportThing, 4000, npck, dzienTygodnia.pos)
		end
	else
		local effect = CONST_ME_MAGIC_RED
		errors(false)
		local ret = doCreateNpc("Rashid", dzienTygodnia.pos)
		errors(true)

		if(tonumber(ret) == nil) then
			effect = CONST_ME_POFF
		end

		doSendMagicEffect(dzienTygodnia.pos, effect)
	end

	return true
end
 
Last edited:
[Error - NpcScript Interface]
data/npc/scripts/rashid.lua
Description:
data/npc/lib/npcsystem/npchandler.lua:260: table index is nil
[Warning - NpcEvents: :NpcEvents] Cannot load script: data/npc/scripts/rashid,lua
;/
 
Revised, with all items (for Tibia ver.9.2)

@elf :)

@fady
now again with v.2 please
have you 04 or 036 tfs?
 
Last edited:
Revised, with all itemami (for Tibia ver.9.2)

@elf :)

@fady
now again with v.2 please
have you 04 or 036 tfs?

itemami; s

nice google translate.

btw i think u want to do it like rl tibia, so why don't u add option to choose which type of items player want to sell? Rashid ask us what we want; amulets, helmets, armors etc. and if we answer for example "armors" then he show us only armors on trade list

Hmm globalevent.. it's not better to have it on startup server? in rl tibia rashid change city after save server, no because they no have idea how to do that, but its better then time interval, use function onStartUpServer
 
btw i think u want to do it like rl tibia, so why don't u add option to choose which type of items player want to sell? Rashid ask us what we want; amulets, helmets, armors etc. and if we answer for example "armors" then he show us only armors on trade list
can do, but not now..
(have you the exact dialogue in English?)

Hmm globalevent.. it's not better to have it on startup server? in rl tibia rashid change city after save server, no because they no have idea how to do that, but its better then time interval, use function onStartUpServe
rl servers are stable, I think that's enough:)
 
I made the changes in modules and npchandler files instead of replace the whole file. But now the server crashes when requesting a trade with any NPC.
I got this errer when starting up the server:

terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_S_construct NULL not valid

Someone have a clue what that means?
 
does this work with TFS 9.6? if it does is there any way to modify it so rashid isnt wandering on differnt days? instead you can just place him like a normal NPC?
 
Back
Top