SE
pedido

PEDIDO : NPC PROMOTION

Por sergionilo, 20 de fev. de 2013 em Scripts

resolvido
tibia
script
otserv
40
3.6k
LumusL
08 de março de 2013 às 17:30

 

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 price = 80000000

 

if msgcontains(msg, 'hi') then

selfSay("You want to be promoted? Say 'promotion' or 'vip promotion'?", cid)

elseif msgcontains(msg, 'promotion') or msgcontains(msg, 'vip promotion') then

selfSay('You want to be promoted vip for 80000000 gold coins?', cid)

talkState[talkUser] = 1

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

if getPlayerLevel(cid) >= 750 then

if getPlayerPromotionLevel(cid) == 1 then

setPlayerPromotionLevel(cid, 2)

doPlayerRemoveMoney(cid, price)

selfSay('Congratulations! You were promoted vip! good bye!', cid)

else

setPlayerPromotionLevel(cid, 2)

doPlayerRemoveMoney(cid, price)

selfSay('Sorry, You dont have the member promotion, or you dont have 80000000 gold coins to be promoted vip, good bye...', cid)

end

else

selfSay("You are already promoted vip, or not have level 750 to be promoted vip, good bye...", cid)

end

talkState[talkUser] = 0

elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then

talkState[talkUser] = 0

selfSay('Good bye.', cid)

end

 

return true

end

 

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

 

 

Cuidado com o DoublePost.

sergioniloS
10 de março de 2013 às 19:36

Ninguem ai sabe como arrumar este erro? só ta faltando isso D: ele ta dando a promotion de graça sendo que tem q ter os requisitos...

 

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 price = 80000000

 

if msgcontains(msg, 'hi') then

selfSay("You want to be promoted? Say 'promotion' or 'vip promotion'?", cid)

elseif msgcontains(msg, 'promotion') or msgcontains(msg, 'vip promotion') then

selfSay('You want to be promoted vip for 80000000 gold coins?', cid)

talkState[talkUser] = 1

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

if getPlayerLevel(cid) >= 750 then

if getPlayerPromotionLevel(cid) == 1 then

setPlayerPromotionLevel(cid, 2)

doPlayerRemoveMoney(cid, price)

selfSay('Congratulations! You were promoted vip! good bye!', cid)

else

setPlayerPromotionLevel(cid, 2)

doPlayerRemoveMoney(cid, price)

selfSay('Sorry, You dont have the member promotion, or you dont have 80000000 gold coins to be promoted vip, good bye...', cid)

end

else

selfSay("You are already promoted vip, or not have level 750 to be promoted vip, good bye...", cid)

end

talkState[talkUser] = 0

elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then

talkState[talkUser] = 0

selfSay('Good bye.', cid)

end

 

return true

end

 

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

Editado Março 10 por sergionilo

GearsG
10 de março de 2013 às 20:01

Wouldaa

 

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 price = 80000000

if msgcontains(msg, 'hi') then
selfSay("You want to be promoted? Say 'promotion' or 'vip promotion'?", cid)
elseif msgcontains(msg, 'promotion') or msgcontains(msg, 'vip promotion') then
selfSay('You want to be promoted vip for 80000000 gold coins?', cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if getPlayerLevel(cid) >= 750 then
if getPlayerPromotionLevel(cid) == 1 and getPlayerMoney(cid, price) == TRUE then
setPlayerPromotionLevel(cid, 2)
selfSay('Congratulations! You were promoted vip! good bye!', cid)
else
if getPlayerMoney(cid, price) == FALSE then
selfSay('Sorry, You dont have the member promotion, or you dont have 80000000 gold coins to be promoted vip, good bye...', cid)
end
else
selfSay("You are already promoted vip, or not have level 750 to be promoted vip, good bye...", cid)
end
talkState[talkUser] = 0
elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
talkState[talkUser] = 0
selfSay('Good bye.', cid)
end

return true
end

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

Editado Março 10 por Gears

sergioniloS
10 de março de 2013 às 20:28

agora ele ta dando a promotion, mas ele da e fala Sorry, You dont have the member promotion, or you dont have 80000000 gold coins to be promoted vip, good bye... :X

 

acho que as falas tao todas embaralhadas :( sera q tem como ageitar?

GearsG
10 de março de 2013 às 20:31

Editei meu post vê lá, flw

 

@edit

Editei outra coisa lá tmb

Editado Março 10 por Gears

SlicerS
10 de março de 2013 às 20:33

@gears

vai da pra comprar a promotion ms n tendo o money... ;x

sergioniloS
10 de março de 2013 às 20:42

deu esse erro ao tentar sumonar o npc :

 

 

[10/03/2013 20:44:03] [Error - LuaScriptInterface::loadFile] data/npc/scripts/Vip Promotion Seller.lua:34: 'end' expected (to close 'if' at line 27) near 'else'

[10/03/2013 20:44:04] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/Vip Promotion Seller.lua

[10/03/2013 20:44:04] data/npc/scripts/Vip Promotion Seller.lua:34: 'end' expected (to close 'if' at line 27) near 'else'

Editado Março 10 por sergionilo

SlicerS
10 de março de 2013 às 20:48

@topic

tenta assim...

 

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 price = 80000000

if msgcontains(msg, 'hi') then
  selfSay("You want to be promoted? Say 'promotion' or 'vip promotion'?", cid)
elseif msgcontains(msg, 'promotion') or msgcontains(msg, 'vip promotion') then
  selfSay('You want to be promoted vip for '..price..' gold coins?', cid)
  talkState[talkUser] = 1
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
  if getPlayerLevel(cid) >= 750 then
  if getPlayerPromotionLevel(cid) == 1 and doPlayerRemoveMoney(cid, price) then
	 setPlayerPromotionLevel(cid, 2)
	 selfSay('Congratulations! You were promoted vip! good bye!', cid)
  else
	 selfSay('Sorry, You dont have the member promotion, or you dont have '..price..' gold coins to be promoted vip, good bye...', cid)
  end
  else
  selfSay("You are already promoted vip, or not have level 750 to be promoted vip, good bye...", cid)
  end
  talkState[talkUser] = 0
elseif msgcontains(msg, 'no') and talkState[talkUser] > 0 then
  talkState[talkUser] = 0
  selfSay('Good bye.', cid)
end

return true
end

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

 

sergioniloS
10 de março de 2013 às 21:16

Cara te amo Slicer shaushuashuashu nossa vlw msmo, e um obrigado a todos os outros q também ajudaram, roksas, gear, fawz !

slicer vo da rep amanha pq hoje não posso mais, mas dps de amanha vou dar outra por causa disso ^^ vlw mesmo abração ae a todos !

 

e quem quiser o vip promotion seller.lua ta ai :

 

 

 

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 price = 80000000

 

if msgcontains(msg, 'hi') then

selfSay("You want to be promoted? Say 'promotion' or 'vip promotion'?", cid)

elseif msgcontains(msg, 'promotion') or msgcontains(msg, 'vip promotion') then

selfSay('You want to be promoted vip for '..price..' gold coins?', cid)

talkState[talkUser] = 1

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

if getPlayerLevel(cid) >= 750 then

if getPlayerPromotionLevel(cid) == 1 and doPlayerRemoveMoney(cid, price) then

setPlayerPromotionLevel(cid, 2)

selfSay('Congratulations! You were promoted vip! good bye!', cid)

else

selfSay('Sorry, You are already promoted vip, or You dont have the member promotion, or you dont have '..price..' gold coins to be promoted vip, good bye...', cid)

end

else

selfSay("Sorry, you do not have level 750 to be promoted vip, good bye...", cid)

end

talkState[talkUser] = 0

elseif msgcontains(msg, 'no') and talkState[talkUser] > 0 then

talkState[talkUser] = 0

selfSay('Good bye.', cid)

end

 

return true

end

 

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

 

 

Editado Março 10 por sergionilo

12 de março de 2013 às 18:11

Tópico movido para a seção de dúvidas e pedidos resolvidos.