Npc que Troca Dinheiro, Tem alguns bugs mas ja ajuda
Ta ai o Npc q troca dinheiro, vc fala change gold dai ele troca 100gps por 1 platinum
fala change 1k ele troca 1000gps por 10 platinum e fala change 10k que ele troca 10000gps por 100 platinum
BUGS
Assim q vc trocar o dinheiro e quiser trocar + vc tem q colocar dentro de uma bp ou guardar em outro lugar, pq se ñ o Npc vai trocar a platinum coin como se fosse gold.
Mais uma coisa o arquivo ".txt" é so salvar como ".lua" e colocar na pasta scripst
Configura ele assim no xml:
<?xml version="1.0" ?>- <npc name="Npc Arkin" script="data/npc/scripts/Npc Arkin.lua" access="3">
<health now="1" max="1" />
<look type="128" head="144" body="114" legs="10" feet="114" />
</npc>
Agora o txt:
-- sven, the bewitched bunny-- it's a sample script, i dont know lua well enough to
-- make some fancy code
-- the good thing is, that this scripts can easily be developed
-- seperately from the main programm
-- perhaps we should write some docu
-- the id of the creature we are attacking, following, etc.
target = 0
following = false
attacking = false
function onThingMove(creature, thing, oldpos, oldstackpos)
end
function onCreatureAppear(creature)
end
function onCreatureDisappear(id)
if id == target then
target = 0
attacking = false
selfAttackCreature(0)
following = false
end
end
function onCreatureTurn(creature)
end
function onCreatureSay(cid, type, msg)
msg = string.lower(msg)
if string.find(msg, '(%a*)hi(%a*)') then
selfSay('Hi, ' .. creatureGetName(cid) .. '! I Can change your gold and buy your loot, I sell axes, swords and shields say job for help.')
end
if string.find(msg, '(%a*)job(%a*)') then
selfSay('To change 100 gold coins say change gold, to change 1000 say change 1k, to change 10000, say change 10k.')
end
if string.find(msg, '(%a*)axe(%a*)') then
selfSay('I sell: Dragon Lance [75k] Fire Axe [37k].')
end
if string.find(msg, '(%a*)sword(%a*)') then
selfSay('I Sell: Bright Sword [37k] Giant Sword [50k].')
end
if string.find(msg, '(%a*)shield(%a*)') then
selfSay('I Sell: Vampire Shield [40k] Phoenix Shield [50k]')
end
if string.find(msg, '(%a*)change gold(%a*)') then
sell(cid,2148,100,2152,1)
end
if string.find(msg, '(%a*)dragon lance(%a*)') then
sell(cid,2148,75000,2414,5)
end
if string.find(msg, '(%a*)fire axe(%a*)') then
sell(cid,2148,37000,2432,1)
end
if string.find(msg, '(%a*)bright sword(%a*)') then
sell(cid,2148,37000,2407,1)
end
if string.find(msg, '(%a*)giant sword(%a*)') then
sell(cid,2148,50000,2393,1)
end
if string.find(msg, '(%a*)vampire shield(%a*)') then
sell(cid,2148,40000,2534,1)
end
if string.find(msg, '(%a*)change 1k(%a*)') then
sell(cid,2148,1000,2152,10)
end
if string.find(msg, '(%a*)phoenix shield(%a*)') then
sell(cid,2148,50000,2539,1)
end
if string.find(msg, '(%a*)change 10k(%a*)') then
sell(cid,2148,10000,2152,100)
end
if string.find(msg, '(%a*)sell sword(%a*)') then
sell(cid,2376,1,2376,25)
end
if string.find(msg, '(%a*)sell hatchet(%a*)') then
sell(cid,2388,1,2388,20)
end
if string.find(msg, '(%a*)sell battle hammer(%a*)') then
sell(cid,2417,1,2148,60)
end
if string.find(msg, '(%a*)bye(%a*)') then
selfSay('Good bye, ' .. creatureGetName(cid) .. '!')
selfSay('And remember, when need change your gold or can sell me items visit me again.')
end
-- It is for npc sell anything.
--if string.find(msg, '(%a*)buy fishing rod(%a*)') then
-- sell(cid,2148,50,2580,1)
--end
end
function onCreatureChangeOutfit(creature)
end
function onThink()
--nothing special has happened
--but perhaps we want to do an action?
if following == true then
moveToCreature(target)
return
end
if attacking == true then
dist = getDistanceToCreature(target)
if dist == nil then
selfGotoIdle()
return
end
if dist <= 1 then
selfAttackCreature(target)
else
moveToCreature(target)
end
end
end