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

Lua Kosheei the ancient amulet

Glidarn

Member
Joined
May 9, 2009
Messages
970
Reaction score
16
Location
Åkersberga, Sweden
So it works to hand them in but according to this script i'm suppose to get the amulet right away, correct? The thing is i'm not getting anything.

LUA:
function amulet(cid, message, keywords, parameters, node)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
        if getPlayerItemCount(cid,8262) >= 1 and getPlayerItemCount(cid,8263) >= 1 and getPlayerItemCount(cid,2160) >= 1 and getPlayerItemCount(cid,8264) >= 1 and  getPlayerItemCount(cid,8265) >= 1 then
        if doPlayerRemoveItem(cid,8262,1) and doPlayerRemoveItem(cid,8263,1) and doPlayerRemoveItem(cid,8264,1) and  doPlayerRemoveItem(cid,8265,1) and doPlayerRemoveItem(cid,2152,50) then
            npcHandler:say('Here is your item!', cid)
            doPlayerAddItem(cid,8266,1)
        end
        else
            npcHandler:say('You don\'t have these items!', cid)
    end
end

and if its suppose to take 24 hours i would like to change that to wait time at all
 
Last edited:
bro i quicky did this for you, didnt test it
if you get erros, it smalls one

how work,

hi, amulet, yes

*after 24 hours*

hi, amulet, bye

LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

local s2config = {
	storages = {
		quest = 12345,
		time = 123456,
		done = 1234567
	},
	pieces = {8262, 8263, 2160, 8264, 8265},
	hours = 24	
}


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 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, 'amulet')) then
		if(getPlayerStorageValue(cid, s2config.storages.done) == 1) then
			npcHandler:say('You already recieve your amulet!', cid)
		elseif(getPlayerStorageValue(cid, s2config.storages.quest) == -1) or (getPlayerStorageValue(cid, s2config.storages.done) == -1) then
			selfSay('You want trade your pieces for a amulet?', cid)
			talkState[talkUser] = 1
			setPlayerStorageValue(cid, s2config.storages.quest, 1)
		elseif(getPlayerStorageValue(cid, s2config.storages.time) > os.time() and getPlayerStorageValue(cid, s2config.storages.quest) == 1) then
			doPlayerAddItem(cid, 8266, 1)
			npcHandler:say('Here is your item!', cid)
			setPlayerStorageValue(cid, s2config.storages.done, 1)
		else
			npcHandler:say('talk to me after ' .. hours .. ' hours.', cid)
		end
	elseif(msgcontains(msg, 'yes')) and (talkState[talkUser] == 1) then
		local keep = 0
		for i = 1, #pieces do 
			if getPlayerItemCount(cid, s2config.pieces[i]) >= 1 then
				doPlayerRemoveItem(cid, s2config.pieces[i], 1)
				keep = 1
			end
		end
		if(keep == 1)then
			selfSay('Ok! now you have to wait ' .. s2config.hours .. ' before recieve your amulet.', cid)
			setPlayerStorageValue(cid, s2config.storages.time, os.time() s2config.hours * 3600)
			setPlayerStorageValue(cid, s2config.storages.quest, 1)
		else
			selfSay('You dont got the pieces that I need!', cid)
		end
		talkState[talkUser] = 0
	elseif(msgcontains(msg, 'no') and (talkState[talkUser] == 1)) then
		selfSay('Ok then.', cid)
		talkState[talkUser] = 0
	end
	return true
end

function onThink()
	npcHandler:onThink()
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
you dont need help, you need learn respect.

i already said,
on ur console, these errors doesnt even show the script name, line there! how the fuck u want me to help you?

anyway, hope you get alot of errors in it ;*

Stop being a rep noob, /reload npc is enough

its not enough.
 
Last edited:
you dont need help, you need learn respect.

i already said,
on ur console, these errors doesnt even show the script name, line there! how the fuck u want me to help you?

anyway, hope you get alot of errors in it ;*



its not enough.

It does show the error-

And /reload npc is enough since i have been using it alot. Stop repying now since arent helping.
 
ok, but the showing errors does not have anything to do with my code, thats what im trying to say to you!

and, /reload npc, it works, but it also bug sometimes.

did you even tried to close/open ur server?
if you need help, PM me, ill help you. just to prove ur wrong bro S:
 
Enough of this nonesense.

Ray Boh Dash.xml
XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Ray Boh Dash" script="kosheisancientamulet.lua" walkinterval="2000" floorchange="0">
	<health now="100" max="100"/>
	<look type="128" head="17" body="54" legs="114" feet="0" addons="2"/>
	<parameters>
		<parameter key="message_greet" value="Hello |PLAYERNAME|, I can craft you an amulet if you bring me the {broken pieces} of one."/>
	</parameters>
</npc>
kosheisancientamulet.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 onPlayerEndTrade(cid)				npcHandler:onPlayerEndTrade(cid)			end
function onPlayerCloseChannel(cid)			npcHandler:onPlayerCloseChannel(cid)		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
	local config = {
		realWait = {
			enabled = true,
			storage = 5431,
			time = 24 * 60 * 60
		},
		requiredItems = {8262, 8263, 8264, 8265},
		item = {8266}
	}

	if(msgcontains(msg, 'amulet') or msgcontains(msg, 'koshei')) then
		local talk = 1
		if(config.realWait.enabled and (getCreatureStorage(cid, config.realWait.storage) > 0)) then
			if(getCreatureStorage(cid, config.realWait.storage) =< os.time()) then
				doPlayerAddItem(cid, config.item, 1, true)
				selfSay('There. I\'ve finished your amulet. It was a lot of work but it really looks good and valuable. Take care of it.', cid)
			else
				selfSay('You\'ll have to give me some time to finish your amulet. Come back later.', cid)
			end

			talk = 0
		end

		if(talk = 1) then
			selfSay('Do you want me to craft all your {pieces of broken amulet}?', cid)
		end

		talkState[talkUser] = talk
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
		local pieces = 0
		for _, id in ipairs(config.requiredItems) do
			if(getPlayerItemCount(cid, id) >= 1) then
				pieces = pieces + 1
				if(pieces == table.maxn(config.requiredItems) then
					for _, id in ipairs(config.requiredItems) do
						doPlayerRemoveItem(cid, id, 1)
					end
					
					if(config.realWait.enabled) then
						doCreatureSetStorage(cid, config.realWait.storage, os.time() + config.realWait.time)
						selfSay('Good. I\'ll starting crafting your amulet right now. Come back later to retrieve it.', cid)
					else
						doPlayerAddItem(cid, config.item, 1)
					end
				else
					selfSay('Sorry, you don\'t have all the required items.', cid)
				end
			end
		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())

EDIT: Quick fix.
EDIT 2: Another quick fix.
EDIT 3: Meh...fix.
 
Last edited:
Back
Top