Ir para conteúdo

Featured Replies

Postado
11 horas atrás, Yamborghini disse:

 

 

eu consegui fazer esse funcionar, porém, a vida e a mana não voltam e da alguns erros no console.... se você puder testar , estou no Celular

 

https://mega.nz/#!BkZ12CZa!PoW5-Vy0k-MiVs9CHX5o7j_Zo6VoAVdPjwIfMwNwiAE

 

OBS: 8.6 TFS0.4

 

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

local c = {
price = 50000,
vocations = {5,6,7,8},
newlevel = 8, -- novo level.
pos = {x=723, y=599, z=7}, -- Pos do templo
tmp = 3 -- apos esses segundos ele desloga automaticamente.
}

local xp = 8400 -- exp para do lvl 8
local hp = 185
local mp = 35

function creatureSayCallback(cid, type, msg) 
if(not npcHandler:isFocused(cid)) then 
return false 
end 
local playerid = getPlayerGUID(cid)
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid 

if(msgcontains(msg, 'valan') or msgcontains(msg, 'semi deus')) then 
selfSay('Você quer virar valan por '..c.price..' gps? {yes} ', cid) 
talkState[talkUser] = 1 
elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
if isInArray(c.vocations, getPlayerVocation(cid)) then  
if doPlayerRemoveMoney(cid,c.price) == TRUE then 
db.query("UPDATE `players` SET `level` = "..c.newlevel..",`experience` = "..xp..",`mana` = "..mp..",`manamax` = "..mp..", `health` = "..hp..", `healthmax` = "..hp.." WHERE `players`.`id` = ".. playerid)
doPlayerSetPromotionLevel(cid, 2)
doTeleportThing(cid, c.pos)
doRemoveCreature(cid)
 else
  selfSay('You do not have the required vocation', cid)
  end
 else
 selfSay('You have already been promoted or doesnt have the necessary experience', cid)
 end
return true
end
end 
 

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

 

Fiz alterações do query da db, forçando as alterações por ela. Veja se da algum erro ^^

  • Respostas 12
  • Visualizações 602
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} function onCreatureAppear(cid) npcHandler:onCre

  • Criando um npc para cada promote.

  • voce pode fazer dessa forma:   local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} functio

Postado
  • Autor
1 hora atrás, SoulSarti disse:

 


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

local c = {
price = 50000,
vocations = {5,6,7,8},
newlevel = 8, -- novo level.
pos = {x=723, y=599, z=7}, -- Pos do templo
tmp = 3 -- apos esses segundos ele desloga automaticamente.
}

local xp = 8400 -- exp para do lvl 8
local hp = 185
local mp = 35

function creatureSayCallback(cid, type, msg) 
if(not npcHandler:isFocused(cid)) then 
return false 
end 
local playerid = getPlayerGUID(cid)
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid 

if(msgcontains(msg, 'valan') or msgcontains(msg, 'semi deus')) then 
selfSay('Você quer virar valan por '..c.price..' gps? {yes} ', cid) 
talkState[talkUser] = 1 
elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
if isInArray(c.vocations, getPlayerVocation(cid)) then  
if doPlayerRemoveMoney(cid,c.price) == TRUE then 
db.query("UPDATE `players` SET `level` = "..c.newlevel..",`experience` = "..xp..",`mana` = "..mp..",`manamax` = "..mp..", `health` = "..hp..", `healthmax` = "..hp.." WHERE `players`.`id` = ".. playerid)
doPlayerSetPromotionLevel(cid, 2)
doTeleportThing(cid, c.pos)
doRemoveCreature(cid)
 else
  selfSay('You do not have the required vocation', cid)
  end
 else
 selfSay('You have already been promoted or doesnt have the necessary experience', cid)
 end
return true
end
end 
 

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

 

Fiz alterações do query da db, forçando as alterações por ela. Veja se da algum erro ^^

 

mesma coisa :( só que agora ele não voltou para o level 8 e nem a vida voltou 

Postado
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

local c = {
price = 50000,
vocations = {5,6,7,8},
pos = {x=723, y=599, z=7}, -- Pos do templo
tmp = 3 -- apos esses segundos ele desloga automaticamente.
}

local xp = 4200 -- exp para do lvl 8
local hp = 185
local mp = 35

function creatureSayCallback(cid, type, msg) 
if(not npcHandler:isFocused(cid)) then 
return false 
end 
local playerid = getPlayerGUID(cid)
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid 

if(msgcontains(msg, 'valan') or msgcontains(msg, 'semi deus')) then 
    selfSay('Você quer virar valan por '..c.price..' gps? {yes} ', cid) 
    talkState[talkUser] = 1 
elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
       if isInArray(c.vocations, getPlayerVocation(cid)) then  
          if doPlayerRemoveMoney(cid,c.price) == TRUE then 
             doPlayerSetPromotionLevel(cid, 2)
             local CheckExp = getPlayerExperience(cid)
          
             doPlayerAddExperience(cid, -CheckExp)
             doPlayerAddExp(cid, xp)
             setCreatureMaxHealth(cid, hp)
             setCreatureMaxMana(cid, mp)
             doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
             doPlayerAddMana(cid, mp)
             doPlayerSave(cid, true)          
             addEvent(doRemoveCreature, 3000, cid)
             doTeleportThing(cid, c.pos)
          else
             selfSay('Voce nao tem o dinheiro necessario', cid)
          end
       else
           selfSay('Voce ja foi promovido ou nao tem a vocação necessaria.', cid)
       end
elseif msgcontains(msg, 'no') and talkState[talkUser] == 1 then
selfSay('Que assim seja.', cid) 
talkState[talkUser] = 0
end
return true
end 
 

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

Tente agora. Acho que nao vai mais dar erro algum

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.

Conteúdo Similar

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo