• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

NPC - Exchange item for Premium Points

SirRayor

New Member
Joined
Jan 1, 2009
Messages
17
Reaction score
2
Location
Poland
Hi, i looking for NPC who when i say "book" he add me 10 premium points to sms shop and take my book.

Book id - 12406
Client Server - 9.10
 
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
 
local t = {}
 
local item = 12406 -- item id
local count = 1 -- count of itemID
local points = 10 -- amount of premium points
 
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
	elseif msgcontains(msg, 'book') then
		selfSay('are you sure you want to change '.. count ..' of '.. getItemNameById(item) ..' for '.. points ..' premium points?', cid)
		t[cid] = 1
	elseif t[cid] == 1 then
		npcHandler:releaseFocus(cid)
		t[cid] = nil
		if msgcontains(msg, 'yes') then
			if doPlayerRemoveItem(cid, item, count) then
				local p = "UPDATE `accounts` SET `premium_points` = `premium_points` + "..points.." where id="..getPlayerAccountId(cid)
				db.executeQuery(p)
				selfSay('you have recieved '.. points ..' premium points', cid)
			else
				selfSay('you don\'t have enough coins you need '.. count ..' of '.. getItemNameById(item) ..' to recieve '.. points ..' premium points', cid)
				end
			end
		end
	return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
now the file of npc.xml
XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Changer" script="exhchanger.lua" walkinterval="2000" floorchange="0">
	<health now="100" max="100"/>
	<look type="138" head="57" body="59" legs="40" feet="76" addons="0"/>
	<parameters>
		<parameter key="message_greet" value="Hello |PLAYERNAME|. Do you want to exchange {book} for 10 premium points?!"/>
		<parameter key="message_farewell" value="Cya later!"/>
	</parameters>
</npc>
 
Last edited:
Back
Top