Hermes
dziwki kola gramy w lola
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
/data/npc/scripts/recycler.lua
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
/data/movements/scripts/recycler.lua
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? ).
NPC will act as an infoNPC.
Regards,
Hermes
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>
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())
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" />
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? ).
NPC will act as an infoNPC.
Regards,
Hermes
Last edited: