Ir para conteúdo
  • Cadastre-se

(Resolvido)NPC REBORN


Ir para solução Resolvido por Vodkart,

Posts Recomendados

Pessoal meu código deu problema novamente. O que esta acontecendo é o seguinte. Quando o NPC reborna, o player fica com a vida total igual a (LVL*HP por Level) + Uma vida fake. Essa vida fake é a que aparece na configuração do código (nesse caso 185). Então um personagem que ganha 15 de hp por lvl e fizer o reborn para level 8, ele vai ficar com 105(15x7)+185 = 290 de hp, porém o 185 é fake. Se o player se curar, ou tomar dano ele perde esses 185 pra sempre, e fica com 105 de hp definitivo.

 

Minha dúvida no script é como fazer o HP rebornado ser fixo. Eu quero que quando rebornado ele seja lvl 8 com exatos 185/40 hp/mana e que de para healar, tomar dano, e morrer sem que de bug na vida.

obs: lembrando que tudo inclui a mana também.




CÓDIGO:

 

local config = {
    
    item = 2150, -- ID do item necessario para rebornar
    count = 0, -- Count do item a cima
    
    life = 185, -- Life ao rebornar
    mana = 40, -- Mana ao rebornar
    level = 8, -- Level ao rebornar
    voc = 15, -- Voc ao rebornar
    storage = 30023
}

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, 'Inquisitor')) or (msgcontains(msg, "yes")) then
	selfSay('Are you sure you want to be {reborn} as a Inquisitor?!', cid)
	return TRUE
	end
    
    if (msgcontains(msg, 'reborn')) then
		setCreatureMaxHealth(cid, config.life)    
    if getCreatureHealth(cid) > config.life then
        doCreatureAddHealth(cid, -(getCreatureHealth(cid) - config.life))
      else
        doCreatureAddHealth(cid, config.life)
      end
		setCreatureMaxMana(cid, config.mana)    
    if getCreatureMana(cid) > config.mana then
        doCreatureAddMana(cid, -(getCreatureMana(cid) - config.mana))
      else
        doCreatureAddMana(cid, config.mana)
      end	  
        doPlayerSetVocation(cid, config.voc)
        doCreatureSetStorage(cid, config.storage, -1)
		setPlayerStorageValue(cid, 10037,1)
		doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_BLUE)
		doPlayerSendTextMessage(cid,25,"Inquisitor outfit unlocked.")
		doPlayerAddLevel(cid, (-getPlayerLevel(cid)), 1)
		doPlayerAddLevel(cid, 1, 1)
        selfSay('Congratulations, you are now a Inquisitor!', cid)
		broadcastMessage("The player "..getCreatureName(cid).." became a Inquisitor")
            return TRUE
        else
            selfSay("Oh! Então traga para mim {".. config.count .." ".. getItemInfo(config.item).name .."}", cid) 
            return TRUE
        end
    end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Link para o post
Compartilhar em outros sites
6 horas atrás, Vodkart disse:

faz direto no banco de dados então, mas tem que kikar o player.

hmmmm! Interessante sugestão! Cara eu não entendo muito, mas como que faria isso? Sem problemas em kickar o player.

Link para o post
Compartilhar em outros sites

@Vorkhon tenta usar assim para testar

 

local config = {
    life = 185, -- Life ao rebornar
    mana = 40, -- Mana ao rebornar
    level = 8, -- Level ao rebornar
    exp = 4200, -- exp que fica
    voc = 15, -- Voc ao rebornar
    storage = 30023
}
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, player_id = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid, getPlayerGUID(cid)
	if (msgcontains(msg, 'Inquisitor')) or (msgcontains(msg, "yes")) then
		selfSay('Are you sure you want to be {reborn} as a Inquisitor?!', cid)
		return true
	end
    if msgcontains(msg, 'reborn') then	  
         doCreatureSetStorage(cid, config.storage, -1)
		setPlayerStorageValue(cid, 10037, 1)
		doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_BLUE)
		doPlayerSendTextMessage(cid,25,"Inquisitor outfit unlocked.")
		broadcastMessage("The player "..getCreatureName(cid).." became a Inquisitor")
        doRemoveCreature(cid)
	    db.executeQuery("UPDATE `players` SET `vocation` = "..config.voc..", `level` = "..config.level..", `experience` = "..config.exp..", `health` = "..config.life..", `healthmax` = "..config.life..", `mana` = "..config.mana..", `manamax` = "..config.mana.." WHERE `id` = "..player_id)
   end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

Editado por Vodkart
arrumar a coluna SQL (veja o histórico de edições)

vodkart_logo.png

[*Ninguém será digno do sucesso se não usar suas derrotas para conquistá-lo.*]

 

DISCORDvodkart#6090

 

Link para o post
Compartilhar em outros sites
1 hora atrás, Vodkart disse:

@Vorkhon tenta usar assim para testar

 


local config = {
    life = 185, -- Life ao rebornar
    mana = 40, -- Mana ao rebornar
    level = 8, -- Level ao rebornar
    exp = 4200, -- exp que fica
    voc = 15, -- Voc ao rebornar
    storage = 30023
}
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, player_id = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid, getPlayerGUID(cid)
	if (msgcontains(msg, 'Inquisitor')) or (msgcontains(msg, "yes")) then
		selfSay('Are you sure you want to be {reborn} as a Inquisitor?!', cid)
		return true
	end
    if msgcontains(msg, 'reborn') then	  
         doCreatureSetStorage(cid, config.storage, -1)
		setPlayerStorageValue(cid, 10037, 1)
		doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_BLUE)
		doPlayerSendTextMessage(cid,25,"Inquisitor outfit unlocked.")
		broadcastMessage("The player "..getCreatureName(cid).." became a Inquisitor")
        doRemoveCreature(cid)
	    db.executeQuery("UPDATE `players` SET `vocation` = "..config.voc..", `level` = "..config.level..", `exp` = "..config.exp..", `health` = "..config.life..", `healthmax` = "..config.life..", `mana` = "..config.mana..", `manamax` = "..config.mana.." WHERE `id` = "..player_id)
   end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

Deu um erro na distro:

[8/10/2020 11:24:25] sqlite3_prepare_v2(): SQLITE ERROR: no such column: exp (UPDATE "players" SET "vocation" = 15, "level" = 8, "exp" = 4200, "health" = 185, "healthmax" = 185, "mana" = 40, "manamax" = 40 WHERE "id" = 28)

Link para o post
Compartilhar em outros sites
  • Solução

@Vorkhon erro meu!!! usa assim essa linha:

 

db.executeQuery("UPDATE `players` SET `vocation` = "..config.voc..", `level` = "..config.level..", `experience` = "..config.exp..", `health` = "..config.life..", `healthmax` = "..config.life..", `mana` = "..config.mana..", `manamax` = "..config.mana.." WHERE `id` = "..player_id)

 

vodkart_logo.png

[*Ninguém será digno do sucesso se não usar suas derrotas para conquistá-lo.*]

 

DISCORDvodkart#6090

 

Link para o post
Compartilhar em outros sites
11 minutos atrás, Vodkart disse:

@Vorkhon erro meu!!! usa assim essa linha:

 


db.executeQuery("UPDATE `players` SET `vocation` = "..config.voc..", `level` = "..config.level..", `experience` = "..config.exp..", `health` = "..config.life..", `healthmax` = "..config.life..", `mana` = "..config.mana..", `manamax` = "..config.mana.." WHERE `id` = "..player_id)

 

Pefeito Vodkart! Muito grato pela ajuda funcionou direitinho! 

obs: Caramba cara eu botei uma linha embaixo da outra e não achei onde tava o erro! Onde vc tinha errado?

Editado por Vorkhon (veja o histórico de edições)
Link para o post
Compartilhar em outros sites

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

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo