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

Solved Is this possible?

tlundin

Almighty push all the noobs.
Joined
Jul 28, 2009
Messages
95
Reaction score
1
Hello! I got an idea for my OT but i have no clue if it's do-able. The thing is that i want people to be able to get donate items without donating. I was thinking about having a purchase coin that will be dropped very rarely from the harder monsters.

So what im wondering is. Is it possible to make a donate-coin that you can use with a NPC to trade for donation items? :w00t:
 
Last edited:
Yes it is.

Make a npc script like this:

Name of NPC.xml

XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="name of NPC here" script="donorseller.lua" walkinterval="2000" floorchange="0">
	<health now="100" max="100"/>
	<look typeex=""/>
	<parameters>
			<parameter key="message_greet" value="Hello |PLAYERNAME|, I'm trading your donor coins for donor items, Do you want to {trade}?"/>
	</parameters>
</npc>


donorseller.lua

Lua:
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

function creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
		return false
	end

	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

	if(msgcontains(msg, 'change') or msgcontains(msg, 'How many items they should give')) then
		selfSay('Do you want to give me <count here> donor coins for a donor sword?', cid)
		talkState[talkUser] = 1
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
		if(getPlayerItemCount(cid, item id here) >= item count here) then
			if(doPlayerRemoveItem(cid, item id here, item count here)) then
				doPlayerAddItem(cid, item id gift here, 1)
				selfSay('Here you are.', cid)
			else
				selfSay('Sorry, you don\'t have enough eyes.', cid)
			end
		else
			selfSay('Sorry, you don\'t have donor coins.', cid)
		end
		talkState[talkUser] = 0
	elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser])) then
		talkState[talkUser] = 0
		selfSay('Ok then.', cid)
	end

	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

IM guessing you know how to change items names in items.xml, if not, im more then happy to help you out.
 
Last edited:
Back
Top Bottom