MA

Npc que pinta pokebola

Por Marshmello, 23 de jul. de 2018 em Tutoriais de Scripting

11
3.3k
MarshmelloM
23 de julho de 2018 às 16:06

Salve gaz, já vi esse tipo de script em alguns foruns , porem não tão funcional, então decidir refazer , e acabou funfando. então vou compartilhar com vocês

 

Primeiro vai em Npc crie um arquivo xml e cole isso dentro

Spoiler

<?xml version="1.0" encoding="UTF-8"?> 
<npc name="Diana" script="ball.lua" walkinterval="0" floorchange="0"> 
<health now="100" max="100"/> 
<look type="1030" head="116" body="54" legs="114" feet="0" addons="2"/> 
          <parameters> 
          <parameter key="message_greet" value="Bem-vindo à minha loja de pintura |PLAYERNAME| Se quizer pintar sua ball fale {paint}!"/>
         </parameters> 
</npc>

 

Depois vai em npc/scripts e cria um arquivo .lua chamado ball.lua e cole isso dentro

Spoiler
--[[
::: Script refeita por marshmello :::
::: Não remova os creditos Plase  :::
]]

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 playerHaveItems(cid, itemid)
local items = type(itemid) == "table" and itemid or {itemid}
for i = 1, #items do
if getPlayerItemCount(cid, items) <= 0 then
return false
end
end
return true
end
 
function doPlayerRemoveItems(cid, itemid, count)
local items = type(itemid) == "table" and itemid or {itemid}
for i = 1, #items do
doPlayerRemoveItem(cid, items, count ~= nil and count or 1)
end
return nil
end
 
function creatureSayCallback(cid, type, msg)
 
if(not npcHandler:isFocused(cid)) then
return false
end
 
if(msgcontains(msg, 'paint')) then
selfSay('Você quer pintar a sua ball?', cid) 
return true 
end

local pokesalive = {'11826', '11832', '11835', '11829', '554', '11452', '12596', '12599', '11826', '11829', '11835', '11832', '12575'} 

if(msgcontains(msg, 'quero')) then
selfSay('Olá, você pode escolher: Pokeball, Greatball, Superball, Ultraball, Safariball.', cid) 
return true 
end
-- normalball

if((msgcontains(msg, 'Pokeball') or msgcontains(msg, 'Poke ball') or msgcontains(msg, 'pokeball') or msgcontains(msg, 'poke ball'))) then
if isInArray(pokesalive, getPlayerSlotItem(cid,8).itemid) then 
if doPlayerRemoveMoney(cid,80000) == true then
selfSay('Boa escolha, a partir de agora um, ele vai olhar como uma Pokeball! Há qualquer outra coisa que eu possa ajudá-lo?', cid) 
doTransformItem(getPlayerSlotItem(cid, 8).uid, 11826) 
else 
selfSay('Sorry '.. getCreatureName(cid) ..', mas você não tem dinheiro suficiente.', cid) 
end
else
selfSay('mantenha seu poke dentro da pokebola',cid)
end 
end
--- great
if((msgcontains(msg, 'Greatball') or msgcontains(msg, 'Great ball') or msgcontains(msg, 'greatball') or msgcontains(msg, 'great ball'))) then  
if isInArray(pokesalive, getPlayerSlotItem(cid,8).itemid) then 
selfSay('Boa escolha, a partir de agora um, ele vai olhar como uma Greatball! Há qualquer outra coisa que eu possa ajudá-lo?', cid) 
if doPlayerRemoveMoney(cid,30000) == true then 
doTransformItem(getPlayerSlotItem(cid, 8).uid, 11832) 
else 
selfSay('Sorry '.. getCreatureName(cid) ..', mas você não tem dinheiro suficiente.', cid) 
end
else
selfSay('mantenha seu poke dentro da pokebola',cid)
end 
end
--- superball
if((msgcontains(msg, 'Superball') or msgcontains(msg, 'Super ball') or msgcontains(msg, 'super ball') or msgcontains(msg, 'superball'))) then
if isInArray(pokesalive, getPlayerSlotItem(cid,8).itemid) then 
if doPlayerRemoveMoney(cid,70000) == true then 
selfSay('Boa escolha, a partir de agora um, ele vai olhar como uma Superball! Há qualquer outra coisa que eu possa ajudá-lo?', cid) 
doTransformItem(getPlayerSlotItem(cid, 8).uid, 11835) 
else 
selfSay('Sorry '.. getCreatureName(cid) ..', mas você não tem dinheiro suficiente.', cid) 
end
else
selfSay('mantenha seu poke dentro da pokebola',cid)
end 
end

-- ultraball
if((msgcontains(msg, 'Ultra ball') or msgcontains(msg, 'Ultraball') or msgcontains(msg, 'ultra ball') or msgcontains(msg, 'ultraball'))) then
if isInArray(pokesalive, getPlayerSlotItem(cid,8).itemid) then 
selfSay('Boa escolha, a partir de agora um, ele vai olhar como uma Ultraball! Há qualquer outra coisa que eu possa ajudá-lo?', cid) 
if doPlayerRemoveMoney(cid,50000) == true then 
doTransformItem(getPlayerSlotItem(cid, 8).uid, 11829) 
else 
selfSay('Sorry '.. getCreatureName(cid) ..', mas você não tem dinheiro suficiente.', cid) 
end
else
selfSay('mantenha seu poke dentro da pokebola',cid)
end 
end


------- saffari ball
if ((msgcontains(msg, 'Saffari ball') or msgcontains(msg, 'Saffariball') or msgcontains(msg, 'saffari ball') or msgcontains(msg, 'saffariball'))) then
selfSay('Boa escolha, a partir de agora ele vai olhar como uma saffariball! , Há qualuqer outra coisa que eu possa ajudá-lo ?', cid)
if doPlayerRemoveMoney(cid, 60000) == true then
doTransformItem(getPlayerSlotItem(cid, 8).uid, 10975)
else
selfSay('Sorry '.. getCreatureName(cid) ..', mas você não tem dinheiro suficiente.', cid) 
end
end
 return true

end


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

Obrigada a @DarkWore Por identar o codigo pois n lembrava o site

Gostou ? deixe seu Rep+

Editado Julho 28 por Marshmello

DuhisbackD
23 de julho de 2018 às 17:00

Não tem como testar mas se funcionar é top esse script, teria como mudar a forma de cobrança para diamond?

MarshmelloM
23 de julho de 2018 às 17:20
15 minutos atrás, Duhisback disse:

Não tem como testar mas se funcionar é top esse script, teria como mudar a forma de cobrança para diamond?

@Duhisback

Spoiler

--[[
::: Script refeita por marshmello :::
::: Não remova os creditos Plase  :::
]]

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 playerHaveItems(cid, itemid)
local items = type(itemid) == "table" and itemid or {itemid}
for i = 1, #items do
if getPlayerItemCount(cid, items) <= 0 then
return false
end
end
return true
end
 
function doPlayerRemoveItems(cid, itemid, count)
local items = type(itemid) == "table" and itemid or {itemid}
for i = 1, #items do
doPlayerRemoveItem(cid, items, count ~= nil and count or 1)
end
return nil
end
 
function creatureSayCallback(cid, type, msg)
 
if(not npcHandler:isFocused(cid)) then
return false
end
 
if(msgcontains(msg, 'paint')) then
selfSay('Você quer pintar a sua ball?', cid) 
return true 
end


if(msgcontains(msg, 'quero')) then
selfSay('Olá, você pode escolher: Pokeball, Greatball, Superball, Ultraball.', cid) 
return true 
end

local diamond = 2145 --- Id dos Diamonds

if((msgcontains(msg, 'Pokeball') or msgcontains(msg, 'Poke ball') or msgcontains(msg, 'pokeball') or msgcontains(msg, 'poke ball'))) then
if getPlayerItemCount(cid,diamond) >= 15 true then
doPlayerRemoveItems(cid, diamond,15) 
selfSay('Boa escolha, a partir de agora um, ele vai olhar como uma Pokeball! Há qualquer outra coisa que eu possa ajudá-lo?', cid) 
doTransformItem(getPlayerSlotItem(cid, 8).uid, 11826) 
else 
selfSay('Sorry '.. getCreatureName(cid) ..', mas você não tem dinheiro suficiente.', cid) 
end

end 

if((msgcontains(msg, 'Greatball') or msgcontains(msg, 'Great ball') or msgcontains(msg, 'greatball') or msgcontains(msg, 'great ball'))) then  
selfSay('Boa escolha, a partir de agora um, ele vai olhar como uma Greatball! Há qualquer outra coisa que eu possa ajudá-lo?', cid) 
if getPlayerItemCount(cid,diamond) >= 15 true then 
doPlayerRemoveItems(cid, diamond,15)
doTransformItem(getPlayerSlotItem(cid, 8).uid, 11832) 
else
selfSay('Sorry '.. getCreatureName(cid) ..', mas você não tem dinheiro suficiente.', cid) 
end
end 

if((msgcontains(msg, 'Superball') or msgcontains(msg, 'Super ball') or msgcontains(msg, 'super ball') or msgcontains(msg, 'superball'))) then
if getPlayerItemCount(cid,diamond) >= 15 true then 
doPlayerRemoveItems(cid, diamond,15)
selfSay('Boa escolha, a partir de agora um, ele vai olhar como uma Superball! Há qualquer outra coisa que eu possa ajudá-lo?', cid) 
doTransformItem(getPlayerSlotItem(cid, 8).uid, 11835) 
else 
selfSay('Sorry '.. getCreatureName(cid) ..', mas você não tem dinheiro suficiente.', cid) 
end
end

if((msgcontains(msg, 'Ultra ball') or msgcontains(msg, 'Ultraball') or msgcontains(msg, 'ultra ball') or msgcontains(msg, 'ultraball'))) then
selfSay('Boa escolha, a partir de agora um, ele vai olhar como uma Ultraball! Há qualquer outra coisa que eu possa ajudá-lo?', cid) 
if getPlayerItemCount(cid,diamond) >= 15 true then 
doPlayerRemoveItems(cid, diamond,15)
doTransformItem(getPlayerSlotItem(cid, 8).uid, 11829) 
else
selfSay('Sorry '.. getCreatureName(cid) ..', mas você não tem dinheiro suficiente.', cid) 
end
end
 
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

DuhisbackD
23 de julho de 2018 às 23:20

Boa dei REP +

MarshmelloM
24 de julho de 2018 às 02:41
3 horas atrás, Duhisback disse:

Boa dei REP +

Tmj men

XkillerWX
26 de julho de 2018 às 22:43

Opa brendo blz, como faco para nao dar para pintar a ball com o pokemon para fora, so dentro do slot? 

MarshmelloM
27 de julho de 2018 às 00:10
Spoiler

if getCreatureSummons(cid) == 1 then
selfsay('retorne seu pokemon')
return true
end

 

Coloque isso no codigo@XkillerW

XkillerWX
27 de julho de 2018 às 07:56

Nao funfou mano, quando escolhe o type da ball com o pokemon pra fora, a type muda no slot fechada, porem o  meta q tava pra fora fica ainda pra fora, e quando clico na ball do slot o meta duplica.

 

MarshmelloM
27 de julho de 2018 às 12:09

Vou refazer o codigo , e atualizo o topico

XkillerWX
27 de julho de 2018 às 19:10

Quando refazer avisa pf

MarshmelloM
28 de julho de 2018 às 23:32

@XkillerW Código atualizado