Va em data/npc e crie um npc com o nome que quiser, aqui estarei usando o nome troca, bom então vamos la...
Cole isto:
<?xml version="1.0" encoding="ISO-8859-1" ?><npc name="Troca" script="data/npc/scripts/troca.lua" floorchange="0" access="5" level="1" maglevel="1">
<health now="150" max="150"/>
<look type="128" head="94" body="94" legs="94" feet="76" addons="3" corpse="2212"/>
<parameters>
<parameter key="module_shop" value="1" />
<parameter key="message_greet" value="Olá |PLAYERNAME|. Eu troco armas de kina por armas de sorc" />
<parameter key="module_keywords" value="1" />
</parameters>
</npc>
Agora vá em scripts e crie um script .lua chamado troca, e cole isto:
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, 'arma de kina') or msgcontains(msg, 'arma de kina')) then
selfSay('Voce quer trocar sua arma de kina por uma de sorc?', cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if(getPlayerItemCount(cid, 2431) >= 1) then
if(doPlayerRemoveItem(cid, 2431, 1) == TRUE) then
doPlayerAddItem(cid, 2190)
selfSay('Here you are.', cid)
else
selfSay('Desculpe, voce nao tem o item.', cid)
end
else
selfSay('Desculpe, voce nao tem o item.', cid)
end
talkState[talkUser] = 0
elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
talkState[talkUser] = 0
selfSay('Ok then.', cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
LEGENDA:
AZUL: MENSSAGENS DO PLAYER
VERMELHO: MENSSAGENS DO NPC
LARANJA: O ID DA ARMA DO KINGHT (A ARMA QUE O PLAYER VAI DAR PRO NPC)
ROSA: ID DA ARMA DO SORC (A ARMA QUE O NPC VAI DAR PRO PLAYER)
BOM, É ISTO
ESPERO TER AJUDADO


info
Grupo: Campones
Registrado: 30/11/06
Posts: 7
Reputação: 0
Bom , a minha ideia é de um npc que troque itens porque eu tenho um server com itens vips ai eu queria exemplo eu tenho arma vip de kina qro trocar por uma arma vip de mage .
exemplo :
npc
que voce deseja trocar ?
player: arma de kina
npc : arma de kina pelo o que ?
player : arma de mage ?
npc : voce deseja trocar arma vip de kina por arma vip de mage ?
player : yes
npc : seu item foi trocado !
era mais ou menos assim