• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

NPC Life Crystal for Life Ring

Kungenn

Veteran OT User
Joined
Jun 10, 2007
Messages
1,623
Reaction score
282
Location
USA California
Hello fellas, I update our server to the latest CryingDamsonpl2 or w/e the name is.

Thing is some of our NPCs stopped working.

However here is the old script we used for people to change life crystal for a life ring.


Not good or anything but it worked as we wanted it to before.

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
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
-- OTServ event handling functions end

function creatureSayCallback(cid, type, msg)
	-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
	if(npcHandler.focus ~= cid) then
		return false
	end

		addon_need_premium = 'You need an premium account to get addons!'
		addon_have_already = 'Cant u remember? U already have this addon!'
		addon_have_not_items = 'I am sorry, But u have wrong items!'
		addon_give = 'Congrationlations, You just received your addon!'
	
		if msgcontains(msg, 'life crystal') then
			selfSay('You really got one? I need them to stay alive. If you want to trade one for a life ring say trade.')
---------------------------------------------------------Begin addons shit--------------------------------------------------
		elseif msgcontains(msg, 'trade') then
           if getPlayerPremiumDays(cid) > 0 then
				if getPlayerItemCount(cid,2177) >= 1 then
					selfSay('Do u want to trade your life crystal for a life ring??')
					talk_state = 1
				else
					selfSay('Your life crystal for my life ring')
					talk_state = 0
				end
			else
				selfSay(addon_need_premium)
				talk_state = 0
			end
------------------------------------------------ confirm yes ------------------------------------------------
		elseif msgcontains(msg, 'yes') and talk_state == 1 then
		          if getPlayerItemCount(cid,2177) >= 1 then
					if doPlayerTakeItem(cid,2177,1) == 0 then
                       doPlayerAddItem(cid,2205,1)
					end
			else
				selfSay(addon_have_not_items)
			end
------------------------------------------------ confirm no ------------------------------------------------
		elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 3) then
			selfSay('Ok then.')
			talk_state = 0
		end
	-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
	return true
end

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

If someone could edit it for me so it works again, I'd be more than greatful..

Thanks in advance! :)
 
It doesn't work Swimmi :p That's why Im wondering if someone could edit it for me so it works with CryingDamson[pl2]
 
PHP:
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 itemgive    = 'Here you go.'
local noitems        = 'You do not have the item I need!'

npcHandler:setMessage(MESSAGE_GREET, "Greetings, |PLAYERNAME|.")

function lifecrystalTrade(cid, message, keywords, parameters, node)

    if(not npcHandler:isFocused(cid)) then
        return false
    end

        if getPlayerItemCount(cid,2177) >= 1 then
        if doPlayerRemoveItem(cid,2177,1) then
            npcHandler:say(itemgive)
            doPlayerAddItem(cid,2205,1)
        end
        else
            npcHandler:say(noitems)
        end
    end

keywordHandler:addKeyword({'life crystal'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "You really got one? I need them to stay alive. If you want to trade one for a life ring say trade."})

local node1 = keywordHandler:addKeyword({'trade'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do u want to trade your life crystal for a life ring?'})
    node1:addChildKeyword({'yes'}, lifecrystalTrade, {npcHandler = npcHandler, onlyFocus = true, reset = true})
    node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ok then.', reset = true})

npcHandler:addModule(FocusModule:new())

Rep++ plz ;)

Also, does anyone know what's the name of Yalahar walls? (IDs 9370 - 9386)
 
Thank you, rep added.

Please check out my post in support & request about paladin attacks, perhaps u could help me out there aswell! :)

Thanks!
 
Then again I guess I was a bit to hastey there, got errors.


Everything worked fine until I said yes.

It took the crystal but never gave anything back..
 
that script might work for life crystal against life ring

but some1 knows how to make something like you need to give 2 items and you recieve 1 ?

im rly bad at scripting :p
 
Back
Top