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

Npc request...

Allu

Member
Joined
Sep 19, 2008
Messages
30
Reaction score
0
Location
Mexico
Hello there.
I am currently looking for help to create one NPC,
this is very important to fullfill my server and no mather how I try, it wont work.

NPC:
This NPC will sell you premium account if you give him an item,
lets say the Vampire Lord Token
Vampire_Lord_Token.gif
as example.
He will only accept the token, if you want to buy premium account.
So the token, not money.
 
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local config = {
	days = 30, itemToRem = vamptokenitemid, itemCount = 5
	}

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, "premium") then
		selfSay("Do you want to buy "..config.days.." of premium account for "..config.itemCount.."x "..getItemNameById(config.itemToRem).."?", cid)
		talkState[talkUser] = 1
	end
	if msgcontains(msg, "yes") and talkState[talkUser] == 1 then
		if doPlayerRemoveItem(cid, config.itemToRem, config.itemCount) == TRUE then
			selfSay(config.days.." of premium have been added to your account.", cid)
			doPlayerAddPremiumDays(cid, config.days)
		else
			selfSay("You do not have enough "..getItemNameById(config.itemToRem)..".", cid)
		end
		talkState[talkUser] = 0
	end
	return true
end

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

for 0.2 change getItemNameById to getItemName.
 
Back
Top