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

Amiroslo

Excellent OT User
Joined
Jul 28, 2009
Messages
6,768
Solutions
5
Reaction score
769
I want a npc that takes from u XITEM, COUNT and gives u 2 premium points to ur account
im using 0.3.6pl1 8.54
rep++
 
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
 
local t = {}
 
local item = 2160 -- item id
local count = 20 -- count of itemID
local points = 20 -- 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, 'change') 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())
 
You must spread some Reputation around before giving it to ahmed30 again.
ty <3, can u add the npc file 2?
should it be
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="name" script="name.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 XITEM for 2 premium points?!"/>
		<parameter key="message_farewell" value="Cya later!"/>
	</parameters>
</npc>
 
Back
Top