TO
pedido

3 Pedidos De Script // Creio Que Seje Facil .

Por tonynamoral, 12 de out. de 2012 em Scripts

resolvido
script
14
1.4k
tonynamoralT
12 de outubro de 2012 às 22:12

Olá galera , eu gostaria de um npc , ou só a funçao que devo usar , para um npc que adicionasse um item ao player randomicamente

 

--- Vou Explicar .

 

 

 

Exemplo , eu to lá , com "X Items" , vou no npc e falo

 

Eu = Hi

NPC = Olá jovem jogador , eu trabalho com {maker wings}, o que voce gostaria de falar a respeito comigo?

Eu = maker wings

NPC = Eu posso lhe criar 3 tipos diferentes de asa . {angelical wings} , {diabolic wings} , {fairy wings} , qual asa voce deseja criar?

Eu = angelical wings

NPC = Bom... para voce criar uma angelical wings , voce precisa de "x items" , "y items" e "z items" . Se voce já tiver e deseja criar , é so confimar que tem.

Eu = confirm

NPC = Entao . voce terá 50% de chance de sucesso e 50% de chance de falha . mesmo assim voce deseja criar ?

Eu = Yes .

 

Ai Demora 5 Segundos , para o NPC dá a noticia de sucesso ou falha. e adicionar ao player o item .

 

------------------------------------------------------------------------------------------------------------------------------------------------------------------------E Tambem , eu gostaria uma funçaozinha assim , exemplo

 

 

Eu falo para o NPC ,

 

Eu = Information Angelical Wings

NPC = Ok , vou te mostrar as informaçoes da angelical wings.

 

E abre uma doShowTextDialog .

 

No lugar do item , aparece o item da asinha , e aonde escreve em baixo , escrito assim

 

####--> Information <--####

Name: Angelical Wings

Vocation : Mage

Level : 40

Price NPC: $40.000,00

Weighs: 40.00 oz

####--> END <--#####

 

 

Pronto , esse é o script do NPC.

 

 

Agora eu vou falar outro script que eu quero , que é para terminar o sistema da asa .

O Negocio é o seguinte , quando o player coloca a asa no lugar da backpack ,

a outfit dele muda .

 

Porém , ele so pode colocar lá , se ele for level X , e Vocaçao X. se nao , nao é possivel ele por lá .

 

Pronto , esse é o script da asa.

 

Agora eu vou falar de um script , mt facil . até eu sei criar , eu so nao sei a config certa para adicionar .

 

é assim , eu quero um item , que quando clique nele . almente " 1 " Certinho em fist fighters , e remova 1 Magic Level.

 

Pronto .... Finish ....

 

 

Sao 1 REP+ Por cada script , agradesço desde já.

fokus090F
12 de outubro de 2012 às 22:20

Referente ao NPC de 50% de chance lá, você pode simplesmente colocar a tag random no NPC:

 

local rand = math.random(1,100)

if rand > 50 then

doPlayerAddItem(cid,NumeroDoItem,1)

 

 

O Outro eu vou no Chute msm:

 

local text = ""

text = "[ -- Angelical Wings -- ]\n\n" .. text

text = text .. "Name: Angelical Wings\n

Vocation : Mage\n

Level : 40\n

Price NPC: $40.000,00\n

Weighs: 40.00 oz\n

####--> END <--#####"\n\n

 

doShowTextDialog(cid, 8983, text)

end

return TRUE

end

 

Não faço idêia se irá funcionar!

 

 

Item que muda Outfit ao Equipar

 

Abraços !!

Editado Outubro 12 por Frenesy

tonynamoralT
12 de outubro de 2012 às 22:34

Beleza , Vou Testar . vou te dar REP+ por tentar ajudar , mais nao dá hoje , ´porque eu atingi meu limite . mais amanha concerteza :)

SlicerS
12 de outubro de 2012 às 23:21

soh achu q falto 'fechar' a string ali heim.. ;p

local text = "[ -- Angelical Wings -- ]\n\n"

text = text .. "Name: Angelical Wings\n

Vocation : Mage\n

Level : 40\n

Price NPC: $40.000,00\n

Weighs: 40.00 oz\n

####--> END <--#####\n\n"

Editado Outubro 12 por Slicer

tonynamoralT
12 de outubro de 2012 às 23:59

Galera , estou tentando criar o NPC , mais sempre está dando error >> tai o Script e logo abaixo vou postar o error .

 

Script

 

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

local time = 5

 

 

-- Conversa Jogador/NPC

if(msgcontains(msg, 'maker wings')) then

selfSay('Eu posso lhe criar 3 tipos diferentes de asa . {angelical wings} , {diabolic wings} , {fairy wings} , qual asa voce deseja criar?.', cid)

elseif(msgcontains(msg, 'angelical wings')) then

selfSay(' Bom... para voce criar uma angelical wings , voce precisa de 1kk , e voce terá 50% de chance de sucesso . ainda deseja criar sua asa?', cid)

talkState[talkUser] = 1

elseif(msgcontains(msg, 'Vip Armor')) then

selfSay('Voc\ê quer comprar Vip Armor por 100 moedas de ouro?', cid)

talkState[talkUser] = 2

-- Confirmação da Compra

elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then

if(doPlayerRemoveItem(cid,2160,100) == true) then

if math.random(1,100) <= 50 then

function angelical(cid)

doPlayerAddItem(cid,2160,1)

end

addEvent(function() angelical(cid) end,time*1000)

return addEvent(doPlayerSendTextMessage, time*1000, cid, 27, "Success -> You created an angelic wings.")

else

addEvent(doPlayerSendTextMessage, time*1000, cid, 27, "Failed -> Trying to create your angelic wings failed.")

end

---------------------------------------------------------------------------------------------------------------------

elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2) then

if(doPlayerRemoveItem(cid, 2157, 100) == true) then

selfSay('Obrigado por comprar!', cid)

doPlayerAddItem(cid, 8885, 1)

talkState[talkUser] = 0

else

selfSay('Voc\ê n\ão tem 100 moedas de ouro', cid)

talkState[talkUser] = 0

end

end

return true

end

 

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

 

 

 

 

 

Error :

 

[12/10/2012 23:58:24] [Error - Npc interface]

[12/10/2012 23:58:24] (Unknown script file)

[12/10/2012 23:58:24] Description:

[12/10/2012 23:58:24] attempt to call a nil value

[12/10/2012 23:58:24] stack traceback:

 

 

 

Me ajudem por favoor *-*

SlicerS
13 de outubro de 2012 às 13:30

tente usar esse...

 

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

local time = 5

local msg = string.lower(msg)

 

local function Sucesso(cid, id)

if isCreature(cid) then

doPlayerAddItem(cid, id, 1)

doPlayerSendTextMessage(cid, 27, "Success -> You created an ".. getItemNameById(id)..".")

end

end

 

local function Falha(cid, id)

if isCreature(cid) then

doPlayerSendTextMessage(cid, 27, "Failed -> Trying to create your ".. getItemNameById(id).." failed.")

end

end

 

-- Conversa Jogador/NPC

if (msgcontains(msg, 'maker wings')) then

selfSay('Eu posso lhe criar 3 tipos diferentes de asa . {angelical wings} , {diabolic wings} , {fairy wings} , qual asa voce deseja criar?.', cid)

elseif (msgcontains(msg, 'angelical wings')) then

selfSay(' Bom... para voce criar uma angelical wings , voce precisa de 1kk , e voce terá 50% de chance de sucesso. ainda deseja criar sua asa?', cid)

talkState[talkUser] = 1

elseif(msgcontains(msg, 'vip armor')) then

selfSay('Voc\ê quer comprar Vip Armor por 100 moedas de ouro?', cid)

talkState[talkUser] = 2

 

elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then

if (doPlayerRemoveItem(cid,2160,100) == true) then

if math.random(1,100) <= 50 then

addEvent(Sucesso, time*1000, cid, 2160)

talkState[talkUser] = 0

return true

else

addEvent(Falha, time*1000, cid, 2160)

talkState[talkUser] = 0

return true

end

else

selfSay("Você não tem dinheiro suficiente!", cid)

talkState[talkUser] = 0

return true

end

---------------------------------------------------------------------------------------------------------------------

elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2) then

if (doPlayerRemoveItem(cid, 2157, 100) == true) then

selfSay('Obrigado por comprar!', cid)

doPlayerAddItem(cid, 8885, 1)

talkState[talkUser] = 0

return true

else

selfSay('Voc\ê n\ão tem 100 moedas de ouro', cid)

talkState[talkUser] = 0

return true

end

end

return true

end

 

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

 

tonynamoralT
13 de outubro de 2012 às 14:29

BUG !

 

 

[13/10/2012 14:32:57] [Error - LuaScriptInterface::loadFile] data/npc/scripts/npc5.lua:1: '=' expected near 'keywordHandler'

[13/10/2012 14:32:57] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/npc5.lua

[13/10/2012 14:32:57] data/npc/scripts/npc5.lua:1: '=' expected near 'keywordHandler'

Editado Outubro 13 por tonynamoral

Yan OliveiraY
13 de outubro de 2012 às 15:08

Tente assim:

 

 

local keywordHandler = KeywordHandler:new()

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

 

npcHandler:addModule(FocusModule:new())

 

local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

local time = 5

local msg = string.lower(msg)

 

local function Sucesso(cid, id)

if isCreature(cid) then

doPlayerAddItem(cid, id, 1)

doPlayerSendTextMessage(cid, 27, "Success -> You created an ".. getItemNameById(id)..".")

end

end

 

local function Falha(cid, id)

if isCreature(cid) then

doPlayerSendTextMessage(cid, 27, "Failed -> Trying to create your ".. getItemNameById(id).." failed.")

end

end

 

-- Conversa Jogador/NPC

if (msgcontains(msg, 'maker wings')) then

selfSay('Eu posso lhe criar 3 tipos diferentes de asa . {angelical wings} , {diabolic wings} , {fairy wings} , qual asa voce deseja criar?.', cid)

elseif (msgcontains(msg, 'angelical wings')) then

selfSay(' Bom... para voce criar uma angelical wings , voce precisa de 1kk , e voce terá 50% de chance de sucesso. ainda deseja criar sua asa?', cid)

talkState[talkUser] = 1

elseif(msgcontains(msg, 'vip armor')) then

selfSay('Voc\ê quer comprar Vip Armor por 100 moedas de ouro?', cid)

talkState[talkUser] = 2

 

 

elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then

if (doPlayerRemoveItem(cid,2160,100) == true) then

if math.random(1,100) <= 50 then

addEvent(Sucesso, time*1000, cid, 2160)

talkState[talkUser] = 0

return true

else

addEvent(Falha, time*1000, cid, 2160)

talkState[talkUser] = 0

return true

end

else

selfSay("Você não tem dinheiro suficiente!", cid)

talkState[talkUser] = 0

return true

end

 

elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2) then

if (doPlayerRemoveItem(cid, 2157, 100) == true) then

selfSay('Obrigado por comprar!', cid)

doPlayerAddItem(cid, 8885, 1)

talkState[talkUser] = 0

return true

else

selfSay('Você não tem 100 moedas de ouro', cid)

talkState[talkUser] = 0

return true

end

end

return true

end

 

end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

 

 

Editado Outubro 13 por Yan18

tonynamoralT
13 de outubro de 2012 às 16:13

Error :

 

 

 

[13/10/2012 16:13:34] [Error - LuaScriptInterface::loadFile] data/npc/scripts/npc5.lua:71: '<eof>' expected near 'end'

[13/10/2012 16:13:34] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/npc5.lua

[13/10/2012 16:13:34] data/npc/scripts/npc5.lua:71: '<eof>' expected near 'end'

fokus090F
13 de outubro de 2012 às 16:52
local keywordHandler = KeywordHandler:new()
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

npcHandler:addModule(FocusModule:new())

local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local time = 5
local msg = string.lower(msg)

local function Sucesso(cid, id)
   if isCreature(cid) then
   doPlayerAddItem(cid, id, 1)
   doPlayerSendTextMessage(cid, 27, "Success -> You created an ".. getItemNameById(id)..".")
   end
end

local function Falha(cid, id)
   if isCreature(cid) then
   doPlayerSendTextMessage(cid, 27, "Failed -> Trying to create your ".. getItemNameById(id).." failed.")
   end
end

-- Conversa Jogador/NPC

   if (msgcontains(msg, 'maker wings')) then
   selfSay('Eu posso lhe criar 3 tipos diferentes de asa . {angelical wings} , {diabolic wings} , {fairy wings} , qual asa voce deseja criar?.', cid)

   elseif (msgcontains(msg, 'angelical wings')) then
   selfSay(' Bom... para voce criar uma angelical wings , voce precisa de 1kk , e voce terá 50% de chance de sucesso. ainda deseja criar sua asa?', cid)
   talkState[talkUser] = 1

   elseif(msgcontains(msg, 'vip armor')) then
   selfSay('Voc\ê quer comprar Vip Armor por 100 moedas de ouro?', cid)
   talkState[talkUser] = 2


   elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
   if (doPlayerRemoveItem(cid,2160,100) == true) then
   if math.random(1,100) <= 50 then
   addEvent(Sucesso, time*1000, cid, 2160)
   talkState[talkUser] = 0
   return true
   else
   addEvent(Falha, time*1000, cid, 2160)
   talkState[talkUser] = 0
return true
end
else
selfSay("Você não tem dinheiro suficiente!", cid)
talkState[talkUser] = 0
return true
end

elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2) then
if (doPlayerRemoveItem(cid, 2157, 100) == true) then
selfSay('Obrigado por comprar!', cid)
doPlayerAddItem(cid, 8885, 1)
talkState[talkUser] = 0
return true
else
selfSay('Você não tem 100 moedas de ouro', cid)
talkState[talkUser] = 0
return true

return true
end

end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

tonynamoralT
13 de outubro de 2012 às 17:06

Okay Slincer , vou testar.

 

@Edit :

 

 

[13/10/2012 17:08:40] [Error - Npc interface]

[13/10/2012 17:08:40] data/npc/scripts/npc5.lua

[13/10/2012 17:08:40] Description:

[13/10/2012 17:08:40] data/npc/scripts/npc5.lua:14: bad argument #1 to 'lower' (string expected, got nil)

[13/10/2012 17:08:40] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/npc5.lua

 

 

Erro dnovo ;"(

Editado Outubro 13 por tonynamoral

Yan OliveiraY
13 de outubro de 2012 às 19:24

Tente assim:

 

 

local keywordHandler = KeywordHandler:new()

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

 

npcHandler:addModule(FocusModule:new())

 

local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

local time = 5

local msg = string.lower(msg)

 

local function Sucesso(cid, id)

if isCreature(cid) then

doPlayerAddItem(cid, id, 1)

doPlayerSendTextMessage(cid, 27, "Success -> You created an ".. getItemNameById(id).."")

end

end

 

local function Falha(cid, id)

if isCreature(cid) then

doPlayerSendTextMessage(cid, 27, "Failed -> Trying to create your ".. getItemNameById(id).." failed.")

end

end

 

-- Conversa Jogador/NPC

 

if (msgcontains(msg, 'maker wings')) then

selfSay('Eu posso lhe criar 3 tipos diferentes de asa . {angelical wings} , {diabolic wings} , {fairy wings} , qual asa voce deseja criar?.', cid)

 

elseif (msgcontains(msg, 'angelical wings')) then

selfSay(' Bom... para voce criar uma angelical wings , voce precisa de 1kk , e voce terá 50% de chance de sucesso. ainda deseja criar sua asa?', cid)

talkState[talkUser] = 1

 

elseif(msgcontains(msg, 'vip armor')) then

selfSay('Voc\ê quer comprar Vip Armor por 100 moedas de ouro?', cid)

talkState[talkUser] = 2

 

 

elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then

if (doPlayerRemoveItem(cid,2160,100) == true) then

if math.random(1,100) <= 50 then

addEvent(Sucesso, time*1000, cid, 2160)

talkState[talkUser] = 0

return true

else

addEvent(Falha, time*1000, cid, 2160)

talkState[talkUser] = 0

return true

end

else

selfSay("Você não tem dinheiro suficiente!", cid)

talkState[talkUser] = 0

return true

end

 

elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2) then

if (doPlayerRemoveItem(cid, 2157, 100) == true) then

selfSay('Obrigado por comprar!', cid)

doPlayerAddItem(cid, 8885, 1)

talkState[talkUser] = 0

return true

else

selfSay('Você não tem 100 moedas de ouro', cid)

talkState[talkUser] = 0

return true

 

return true

end

 

end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

 

 

Editado Outubro 13 por Yan18

tonynamoralT
13 de outubro de 2012 às 20:14

@Yan18 , nao funcionou .

 

@off , eu peguei outro npc como base , e consegui . obrigado a voces , eu usei umas funçoes qe voces criaram ;)

 

Duvida Sanada.

Reportado para que feche

caoticC
14 de outubro de 2012 às 11:17

Tópico Movido para pedidos e duvidas de scripts resolvidos