• 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 premium points exchange NPC Problem

killing

Member
Joined
Feb 23, 2012
Messages
815
Reaction score
11
Location
BIH
Can any1 fix this script for me?.
When i say to NPC:

Player say: Hi
NPC say: Hello player. Do you want to exchange 100 Premium Tokens for 1 premium points?!
Player say: Yes

And nothing Happens!!!

NPC.lua
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
 
local t = {}
 
local item = 9020 -- item id
local count = 100 -- count of itemID
local points = 1 -- 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())
 
Last edited:
No errors.
it just does not work.

- - - Updated - - -

If you can help me i woud be happy. :)
I try to fix it for 36 Minutes.
 
Test this:
Lua:
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

local item = 9020 -- item id
local count = 100 -- count of itemID
local points = 1 -- amount of premium points 

function creatureSayCallback(cid, type, msg)
	if not npcHandler:isFocused(cid) then
		return false
	end
	if msgcontains(msg, 'change') then
		if getPlayerItemCount(cid,item) >= count then
        selfSay('are you sure you want to change '.. count ..' of '.. getItemNameById(item) ..' for '.. points ..' premium points?', cid)
		talk_state = 1
		else
		selfSay('You don\'t have enough coins you need '.. count ..' of '.. getItemNameById(item) ..' to recieve '.. points ..' premium points!', cid)
		talk_state = 0
		end
	elseif msgcontains(msg, 'yes') and talk_state == 1 then
		if getPlayerItemCount(cid,item) >= count then
        doPlayerRemoveItem(cid, item, count)
		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
	return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)  --[[ ]]--
npcHandler:addModule(FocusModule:new())

hope it works! XD

--Update--
Update the script.
 
Last edited:
Its not working.

Script XML
Lua:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="PT Exchanger" script="pt.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 100 Premium Tokens for 1 premium points?!"/>
		<parameter key="message_farewell" value="Cya later!"/>
	</parameters>
</npc>
 
For Znote AAC:
Lua:
local p = "UPDATE `znote_accounts` SET `points` = `points` + "..points.." WHERE account_id = "..getPlayerAccountId(cid)
 
For Znote AAC:
Lua:
local p = "UPDATE `znote_accounts` SET `points` = `points` + "..points.." WHERE account_id = "..getPlayerAccountId(cid)

For what is that, i need help with premium points exchange NPC.

Lua
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
 
local t = {}
 
local item = 9020 -- item id
local count = 100 -- count of itemID
local points = 1 -- 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())


Xml
Lua:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="PT Exchanger" script="pt.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 100 Premium Tokens for 1 premium points?!"/>
		<parameter key="message_farewell" value="Cya later!"/>
	</parameters>
</npc>
 
Have error man?

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

local item = 9020 -- item id
local count = 100 -- count of itemID
local points = 1 -- amount of premium points 

function creatureSayCallback(cid, type, msg)
	if not npcHandler:isFocused(cid) then
		return false
	end
	if msgcontains(msg, 'change') then
		if getPlayerItemCount(cid,item) >= count then
        selfSay('are you sure you want to change '.. count ..' of '.. getItemNameById(item) ..' for '.. points ..' premium points?', cid)
		talk_state = 1
		else
		selfSay('You don\'t have enough coins you need '.. count ..' of '.. getItemNameById(item) ..' to recieve '.. points ..' premium points!', cid)
		talk_state = 0
		end
	elseif msgcontains(msg, 'yes') and talk_state == 1 then
		if getPlayerItemCount(cid,item) >= count then
        doPlayerRemoveItem(cid, item, count)
		local p = "UPDATE `znote_accounts` SET `points` = `points` + "..points.." WHERE account_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
	return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)  --[[ ]]--
npcHandler:addModule(FocusModule:new())
 
sWYXbIB.png


- - - Updated - - -

yes i have not workinggg
 
Back
Top