• 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 [Ecological Release] Cedrik the Recycler, with moveEvent backpack recycling script!

Hermes

dziwki kola gramy w lola
Joined
Nov 17, 2007
Messages
1,867
Reaction score
14
Location
Poland
Hi there!

I had really great idea for script, and I had dilemma release it or not.

The main purpose of this script is to teach you to protect our natural environment.

So.

/data/npc/Cedrik the Recycler.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Cedrik the Recycler" script="recycler.lua" walkinterval="0" floorchange="0">
	<health now="150" max="150"/>
	<look type="130" head="84" body="119" legs="114" feet="114" corpse="2212"/>
    <parameters>
	<parameter key="message_greet" value="Hello |PLAYERNAME|. I am {recycler}. My work is to inform you that our {natural environment} is in {danger}."/>
    </parameters>
</npc>
/data/npc/scripts/recycler.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 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, 'recycler') then
		npcHandler:say("It's very nice job. I am promoting {natural lifestyle}. Ofcourse you can {help} me, and whole world.", cid)
	elseif msgcontains(msg, 'natural environment') then
		npcHandler:say("Now environment is being {polluted} mainly by cars and factories.", cid)
	elseif msgcontains(msg, 'danger') then
		npcHandler:say("Yes, in danger. We are destroying our world.", cid)
	elseif msgcontains(msg, 'natural lifestyle') then
		npcHandler:say("Right. You can, for example, recycle your old backpacks. Just throw them on basin near me. Just think how many animals you can save!", cid)
	elseif msgcontains(msg, 'pollut') then
		npcHandler:say("Pollution contains all those weird streaks, which are really harmful for natural environment.", cid)
	elseif msgcontains(msg, 'help') then
		npcHandler:say("It's really important to teach young people about {global warming}, about recycling, about that what will be if we won't do anything!", cid)
	elseif msgcontains(msg, 'global warming') then
		npcHandler:say("Global warming is caused by pollution. Temperature over the world is increasing rapidly. It has terrible effect on biosphere.", cid)
	end
	return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
We have NPC now. Let's make backpack recycling script!

Make on map NPC spawn. Near NPC make coal basin (non moveable). Remember position of basin and set it's actionid to any free.

/data/movements/movements.xml
as backpackpos you have to set position of coal basin
as ACTION_ID write actionid you have set in basin
Code:
<movevent type="AddItem" tileitem="1" actionid="ACTION_ID" event="script" value="recycler.lua" />
/data/movements/scripts/recycler.lua
Lua:
function onAddItem(moveitem, tileitem, pos, cid)
	local backpacks = {1988, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 3940, 5926, 5949, 7342, 9774}
	-- 2365 backpack of holding
	local backpackPosition = {x=1000, y=1000, z=7, stackpos=STACKPOS_TOP_ITEM}
	local getbackpack = getThingFromPos(backpackPosition)
	if isInArray(backpacks, moveitem.itemid) then
		doRemoveItem(getbackpack.uid, 1)
		doPlayerAddMoney(cid, 10)
		doSendMagicEffect(backpackPosition, CONST_ME_MAGIC_RED)
	end
	return true
end

Now we are set! Throw any empty backpack on coal basin, it will be recycled and you will get 10gp for saving animals (backpacks are made of leather right? :D).
NPC will act as an infoNPC.

Regards,
Hermes
 
Last edited:
I see that you all like my eco scripting. Now I am thinking about next release (eco ofc)

Regards&throw empty cans to special containers 4 alluminium plx?
Hermes
 
Heres the NPC file with some fixed grammar / spelling :p


Code:
  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 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, 'recycler') then
                npcHandler:say("Its a  very nice job. I am promoting a {natural lifestyle}. Of course you can {help} me, and whole world.", cid)
        elseif msgcontains(msg, 'natural environment') then
                npcHandler:say("Now the environment is being {polluted}, mainly by cars and factories.", cid)
        elseif msgcontains(msg, 'danger') then
                npcHandler:say("Yes, we are in danger. We are destroying our world.", cid)
        elseif msgcontains(msg, 'natural lifestyle') then
                npcHandler:say("Right. You can, for example, recycle your old backpacks. Just throw them on the coal basin near me. Just think how many animals you can save!", cid)
        elseif msgcontains(msg, 'pollute') then
                npcHandler:say("Pollution contains all those weird chemicals, which are really harmful for natural environment.", cid)
        elseif msgcontains(msg, 'help') then
                npcHandler:say("It's really important to teach young people about {global warming}, about recycling, about that what will be if we won't do anything!", cid)
        elseif msgcontains(msg, 'global warming') then
                npcHandler:say("Global warming is caused by pollution. Temperature over the world is increasing rapidly. It has terrible effect on biosphere.", cid)
        end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())



Thanks a lot for releasing it, I will use it on my server!
 
Back
Top