Ir para conteúdo

Featured Replies

Postado

Alguém consegue me ajudar? estou precisando mudar o script do npc RASHID, quero que ele compre os itens somente se o player tiver a storage 1039.

 

TFS 1.0

 

rashid.xml:

 

Spoiler
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Rashid" script="rashid.lua" walkinterval="0" access="3" lookdir="2">
<look type="128" head="114" body="101" legs="122" feet="115"/>
    <mana now="800" max="800"/>
    <health now="200" max="200"/>
   
<parameters>
 
    <parameter key="message_greet" value="Hello |PLAYERNAME|, I buy many items, you are abble to choise between armors, weapons, helmets, shields, boots, amulets and dolls, What do you offer me?" />
    <parameter key="message_farewell" value="Good bye |PLAYERNAME|!" />
    </parameters>
</npc>

 

 

rashid.lua:

 

Spoiler
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
 
local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
 
shopModule:addSellableItem({'ancient amulet'},2142, 200,'ancient amulet')
shopModule:addSellableItem({'amber staff'},8640, 8000,'amber staff')
shopModule:addSellableItem({'assassin dagger'},8642, 20000,'assassin dagger')
shopModule:addSellableItem({'bandana'},8643, 150,'bandana')
shopModule:addSellableItem({'beetle necklace'},8645, 1500,'beetle necklace')
shopModule:addSellableItem({'beastslayer axe'},3962, 1500,'beastslayer axe')
shopModule:addSellableItem({'brutetamer\'s staff'},8649, 1500,'brutetamer\'s staff')
shopModule:addSellableItem({'bone shield'}, 2541, 80,'bone shield')
shopModule:addSellableItem({'beholder helmet'},3972, 7500,'beholder helmet')
shopModule:addSellableItem({'chaos mace'},8652, 9000,'chaos mace')
shopModule:addSellableItem({'castle shield'},2535, 5000,'castle shield')
shopModule:addSellableItem({'crocodile boots'},3982, 1000,'crocodile boots')
shopModule:addSellableItem({'crystal mace'}, 2445, 12000,'crystal mace')
shopModule:addSellableItem({'crystal necklace'},2125, 400,'crystal necklace')
shopModule:addSellableItem({'crystal ring'}, 2124, 250,'crystal ring')
shopModule:addSellableItem({'crystal sword'}, 8661, 600,'crystal sword')
shopModule:addSellableItem({'composite hornbow'}, 8667, 25000,'composite hornbow')
shopModule:addSellableItem({'death ring'}, 8668, 1000, 'death ring')
shopModule:addSellableItem({'fur boots'}, 8670, 2000, 'fur boots')
shopModule:addSellableItem({'furry club'}, 8671, 1000, 'furry club')
shopModule:addSellableItem({'jade hammer'}, 8675, 25000, 'jade hammer')
shopModule:addSellableItem({'ragnir helmet'}, 8707, 400, 'ragnir helmet')
shopModule:addSellableItem({'krimhorn helmet'}, 8678, 200, 'krimhorn helmet')
shopModule:addSellableItem({'pirate boots'}, 8708, 3000, 'pirate boots')
shopModule:addSellableItem({'dragon slayer'}, 8717, 15000, 'dragon slayer')
shopModule:addSellableItem({'light shovel'}, 8679, 300, 'light shovel')
shopModule:addSellableItem({'norse shield'}, 8681, 1500, 'norse shield')
shopModule:addSellableItem({'noble axe'}, 8682, 10000, 'noble axe')
shopModule:addSellableItem({'nightmare blade'}, 8683, 35000, 'nightmare blade')
shopModule:addSellableItem({'mammoth whopper'}, 8686, 300, 'mammoth whopper')
shopModule:addSellableItem({'mammoth fur shorts'}, 8687, 850, 'mammoth fur shorts')
shopModule:addSellableItem({'mammoth fur cape'}, 8688, 6000, 'mammoth fur cape')
shopModule:addSellableItem({'dreaded cleaver'}, 8654, 10000, 'dreaded cleaver')
shopModule:addSellableItem({'diamond sceptre'}, 8658, 3000, 'diamond sceptre')
shopModule:addSellableItem({'daramian mace'},2439, 110,'daramian mace')
shopModule:addSellableItem({'vile axe'},8696, 30000,'vile axe')
shopModule:addSellableItem({'spiked squelcher'},8700, 5000,'spiked squelcher')
shopModule:addSellableItem({'skullcracker armor'},8701, 18000,'skullcracker armor')
shopModule:addSellableItem({'skull helmet'},8702, 40000,'skull helmet')
shopModule:addSellableItem({'sapphire hammer'},8704, 7000,'sapphire hammer')
shopModule:addSellableItem({'wyvern fang'},8695, 1500,'wyvern fang')
shopModule:addSellableItem({'daramian waraxe'},2440, 1000,'daramian waraxe')
shopModule:addSellableItem({'dark shield'}, 2521, 400,'dark shield')
shopModule:addSellableItem({'demon shield'}, 2520, 30000,'demon shield')
shopModule:addSellableItem({'demonbone amulet'},2136, 32000,'demonbone amulet')
shopModule:addSellableItem({'devil helmet'}, 2462, 1000,'devil helmet')
shopModule:addSellableItem({'djinn blade'}, 2451, 15000,'djinn blade')
shopModule:addSellableItem({'doll'}, 2110, 200,'doll')
shopModule:addSellableItem({'dragon scale mail'},2492, 40000,'dragon scale mail')
shopModule:addSellableItem({'dwarven armor'},2503,'dwarven armor')
shopModule:addSellableItem({'emerald bangle'},2127, 800,'emerald bangle')
shopModule:addSellableItem({'epee'}, 2438, 8000,'epee')
shopModule:addSellableItem({'gold ring'}, 2179, 8000,'gold ring')
shopModule:addSellableItem({'golden armor'}, 2466, 20000,'golden armor')
shopModule:addSellableItem({'golden legs'}, 2470, 30000,'golden legs')
shopModule:addSellableItem({'guardian halberd'},2427, 11000,'guardian halberd')
shopModule:addSellableItem({'hammer of wrath'},2444, 30000,'hammer of wrath')
shopModule:addSellableItem({'heavy mace'}, 2452, 50000,'heavy mace')
shopModule:addSellableItem({'heavy machete'},2442, 90,'heavy machete')
shopModule:addSellableItem({'leopard armor'},3968, 1000,'leopard armor')
shopModule:addSellableItem({'mastermind shield'},2514, 50000,'mastermind shield')
shopModule:addSellableItem({'magic plate armor'},2472, 90000,'magic plate armor')
shopModule:addSellableItem({'medusa shield'},2536, 9000,'medusa shield')
shopModule:addSellableItem({'naginata'}, 2426, 2000,'naginata')
shopModule:addSellableItem({'patched boots'},2641, 2000,'patched boots')
shopModule:addSellableItem({'rharaoh sword'},2446, 23000,'pharaoh sword')
shopModule:addSellableItem({'rlatinum amulet'},2171, 2500,'platinum amulet')
shopModule:addSellableItem({'ring of the sky'},2123, 30000,'ring of the sky')
shopModule:addSellableItem({'ruby necklace'},2133, 2000,'ruby necklace')
shopModule:addSellableItem({'scarab amulet'},2135, 200,'scarab amulet')
shopModule:addSellableItem({'scarab shield'},2540, 2000,'scarab shield')
shopModule:addSellableItem({'silver brooch'},2134, 150,'silver brooch')
shopModule:addSellableItem({'silver dagger'},2402, 500,'silver dagger')
shopModule:addSellableItem({'steel boots'}, 2645, 30000,'steel boots')
shopModule:addSellableItem({'tempest shield'},2542, 35000,'tempest shield')
shopModule:addSellableItem({'voodoo doll'}, 2322, 400,'boodoo doll')
shopModule:addSellableItem({'war axe'}, 2454, 12000,'war axe')
shopModule:addSellableItem({'war horn'}, 2079, 8000,'war horn')
npcHandler:addModule(FocusModule:new())

 

Editado por yuriowns (veja o histórico de edições)

Postado

Com certeza tem outros jeitos mais inteligentes para se fazer isso, ver se isso ajuda:

 

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
 
local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
 
-- Função que verificar a storage do jogador
local function checkStorage(cid, storage)
    return getPlayerStorageValue(cid, storage) == 1039
end
 
-- Verifica a storage antes de permitir que o NPC compre os itens
shopModule:addSellableItem({'ancient amulet'},2142, 200,'ancient amulet', function(player) return checkStorage(player:getId(), 1039) end)
shopModule:addSellableItem({'beastslayer axe'},3962, 1500,'beastslayer axe', function(player) return checkStorage(player:getId(), 1039) end)
shopModule:addSellableItem({'bone shield'}, 2541, 80,'bone shield', function(player) return checkStorage(player:getId(), 1039) end)
-- faz igual com o resto dos items
 
npcHandler:addModule(FocusModule:new())

 

Postado
  • Autor
13 horas atrás, drigobo disse:

Com certeza tem outros jeitos mais inteligentes para se fazer isso, ver se isso ajuda:

 



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
 
local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
 
-- Função que verificar a storage do jogador
local function checkStorage(cid, storage)
    return getPlayerStorageValue(cid, storage) == 1039
end
 
-- Verifica a storage antes de permitir que o NPC compre os itens
shopModule:addSellableItem({'ancient amulet'},2142, 200,'ancient amulet', function(player) return checkStorage(player:getId(), 1039) end)
shopModule:addSellableItem({'beastslayer axe'},3962, 1500,'beastslayer axe', function(player) return checkStorage(player:getId(), 1039) end)
shopModule:addSellableItem({'bone shield'}, 2541, 80,'bone shield', function(player) return checkStorage(player:getId(), 1039) end)
-- faz igual com o resto dos items
 
npcHandler:addModule(FocusModule:new())

 

não mudou nada, ele continua vendendo normal com ou sem storage

Editado por yuriowns (veja o histórico de edições)

Postado

Eu consigo te ajudar, mas preciso que faça um teste.

Use esse script e venda o ancient amulet pro NPC.

Fica de olho no console do teu servidor e me diz se vai retornar o nome do teu persaongem:

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 shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

shopModule:addSellableItem({ 'ancient amulet' }, 2142, 200, 'ancient amulet', function()
    print(player:getName())
end)

npcHandler:addModule(FocusModule:new())

Se retornar o nome do teu personagem, já consigo resolver

Postado
  • Autor
19 minutos atrás, Anderson Sacani disse:

Eu consigo te ajudar, mas preciso que faça um teste.

Use esse script e venda o ancient amulet pro NPC.

Fica de olho no console do teu servidor e me diz se vai retornar o nome do teu persaongem:


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 shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

shopModule:addSellableItem({ 'ancient amulet' }, 2142, 200, 'ancient amulet', function()
    print(player:getName())
end)

npcHandler:addModule(FocusModule:new())

Se retornar o nome do teu personagem, já consigo resolver

deu o seguinte erro:
image.thumb.png.5605a53333e6f2a281d7fc1fc3ff4f82.png
 

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 520.1k

Informação Importante

Confirmação de Termo