Ir para conteúdo
Banner com Efeitos

Featured Replies

Postado
  • Solução

Tem como tirar a storage old então? colocar uma apenas para ele ganhar quando trocar a vocação para não conseguir trocar novamente?


Bom, nesse caso nem precisaria usar storages..
local tab = {
	voc = {5}, -- newVocationID
	dctime = 5, -- segundos para desconectar o player
	stats = {1, 150, 5} -- {newLevel, newHealth, newMana} novo level/hp/mana ao trocar a voc
}

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
	
	function changeVoc(cid)
		local playerid, mh, mm = getPlayerGUID(cid), getCreatureMaxHealth(cid), getCreatureMaxMana(cid)
		if(npcHandler:isFocused(cid)) then
			npcHandler:releaseFocus(cid)
		end
		
		setCreatureMaxHealth(cid, tab.stats[2])
		doCreatureAddHealth(cid, -(tab.stats[2] - mh))
		setCreatureMaxMana(cid, tab.stats[3])
		doCreatureAddMana(cid, -(tab.stats[3] - mm))
		doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
		doRemoveCreature(cid)
		db.executeQuery("UPDATE `players` SET `level`="..tab.stats[1]..",`experience`= 0 WHERE `players`.`id`= "..playerid.."")
		return true
	end

	if (msgcontains(msg, 'change')) then
		if not (tab.voc[getPlayerVocation(cid)]) then
			talkState[talkUser] = 1
			selfSay('If you choose to change your vocation, your level, health and mana will return as a level '..tab.stats[1]..'..', cid)
			selfSay('Are you sure you want this?', cid)
		else
			talkState[talkUser] = 0
			npcHandler:releaseFocus(cid)
			selfSay('I can not change your vocation.', cid)
		end
	elseif (msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
		doPlayerSetVocation(cid, tab.voc[1])
		doSendMagicEffect(getThingPos(cid), CONST_ME_STUN)
		addEvent(function()
			if isPlayer(cid) then
				changeVoc(cid)
			end
		end, tab.dctime * 1000)
		talkState[talkUser] = 0
		npcHandler:releaseFocus(cid)
		selfSay('Okay, now you will pass out and I will send you to the temple of your town in '..tab.dctime..' seconds.', cid)
	elseif (msgcontains(msg, 'no') and talkState[talkUser] == 1) then
		talkState[talkUser] = 0
		npcHandler:releaseFocus(cid)
		selfSay('Sure, goodbye!', cid)
	end
	
	return true
end

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

The corrupt fear us.

The honest support us.

The heroic join us.

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

Top Posters In This Topic

Most Popular Posts

  • Bom, nesse caso nem precisaria usar storages.. local tab = { voc = {5}, -- newVocationID dctime = 5, -- segundos para desconectar o player stats = {1, 150, 5} -- {newLevel, newHealth, newMana} nov

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.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.7k

Informação Importante

Confirmação de Termo