Ir para conteúdo

Featured Replies

Postado
1 hora atrás, One Punch Man disse:

Eu queria apenas um script que um jogador falasse com o seguinte npc e ele desse uma looktype aleatória para o jogador..


Tente aí:

local outfits = {123, 456, 789} -- lookType numbers
local keywordHandler = KeywordHandler:new() 
local npcHandler = NpcHandler:new(keywordHandler) 
NpcSystem.parseParameters(npcHandler) 

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
npcHandler:setMessage(MESSAGE_GREET, 'Hello |PLAYERNAME|. Say halloween.')

function halloweenNPC(cid)
	doSetCreatureOutfit(cid, {lookType = outfits[math.random(1, #outfits)]}, -1)
	doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
	selfSay('Surprise! Happy Halloween!', cid)
    return npcHandler:releaseFocus(cid)
end

keywordHandler:addKeyword({'halloween'}, halloweenNPC, {}) 
npcHandler:addModule(FocusModule:new())

 

Editado por Wise (veja o histórico de edições)

The corrupt fear us.

The honest support us.

The heroic join us.

  • Respostas 27
  • Visualizações 1k
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

Postado
Spoiler

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
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

npcHandler:setMessage(MESSAGE_GREET, "Hello |PLAYERNAME|. Say {halloween}.")

local outfits = {857,853,852,851,843,837,833,785,720,659,597,549,544,523,510,878,877,890}

local condition = createConditionObject(CONDITION_OUTFIT, (3 * 24 * 3600 * 1000))
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_GREEN)

function onTargetCreature(cid, target)
	if(isPlayer(target)) then
		addOutfitCondition(condition, {lookType = math.random(#outfits)})
		doAddCondition(target, condition)
	end
end
setCombatCallback(combat, CALLBACK_PARAM_TARGETCREATURE, "onTargetCreature")

setCombatArea(combat, createCombatArea({
	{1,1,1,1,1},
	{1,1,1,1,1},
	{1,1,3,1,1},
	{1,1,1,1,1},
	{1,1,1,1,1}
}))

function creatureSayCallback(cid, type, msg)
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	if(not npcHandler:isFocused(cid)) then
		return false
	end
	
	if(msg:lower() == "halloween") then
		doCombat(getNpcId(), combat, numberToVariant(getNpcId()))
		npcHandler:say('You are Dead, Suprise!', 0)
	end
	return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

 

Se o de área não funcionar, tente esse:

Spoiler

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
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
npcHandler:setMessage(MESSAGE_GREET, "Hello |PLAYERNAME|. Say {halloween}.")

local outfits = {857,853,852,851,843,837,833,785,720,659,597,549,544,523,510,878,877,890}
local condition = createConditionObject(CONDITION_OUTFIT, (3 * 24 * 3600 * 1000))

function creatureSayCallback(cid, type, msg)
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	if(not npcHandler:isFocused(cid)) then
		return false
	end
	
	if(msg:lower() == "halloween") then
		addOutfitCondition(condition, {lookType = math.random(#outfits)})
		doAddCondition(cid, condition)
		doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
		npcHandler:say('You are Dead, Suprise!', 0)
	end
	return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

 

Postado
  • Autor
2 minutos atrás, Wise disse:


Tente aí:
 


local outfit, time, key = 123, 3, 54321 -- lookType number, tempo do outfit em dias, storage key
local keywordHandler = KeywordHandler:new() 
local npcHandler = NpcHandler:new(keywordHandler) 
NpcSystem.parseParameters(npcHandler) 

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
npcHandler:setMessage(MESSAGE_GREET, 'Hello |PLAYERNAME|. Say halloween.')

function halloweenNPC(cid)
	if getCreatureStorage(cid, key) > 0 then return npcHandler:releaseFocus(cid) end
	
	doCreatureSetStorage(cid, key, 1)
	doSetCreatureOutfit(cid, {lookType = outfit}, time * 24 * 3600 * 1000)
	selfSay('Surprise! Happy Halloween!', cid)
    return npcHandler:releaseFocus(cid)
end

keywordHandler:addKeyword({'halloween'}, halloweenNPC, {}) 
npcHandler:addModule(FocusModule:new())

 

 

Wise funcionou, como que eu coloco mais de uma outfit?

x1fCxnI.png

Postado
  • Autor
13 minutos atrás, MaTTch disse:
  Mostrar conteúdo oculto



local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
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

npcHandler:setMessage(MESSAGE_GREET, "Hello |PLAYERNAME|. Say {halloween}.")

local outfits = {857,853,852,851,843,837,833,785,720,659,597,549,544,523,510,878,877,890}

local condition = createConditionObject(CONDITION_OUTFIT, (3 * 24 * 3600 * 1000))
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_GREEN)

function onTargetCreature(cid, target)
	if(isPlayer(target)) then
		addOutfitCondition(condition, {lookType = math.random(#outfits)})
		doAddCondition(target, condition)
	end
end
setCombatCallback(combat, CALLBACK_PARAM_TARGETCREATURE, "onTargetCreature")

setCombatArea(combat, createCombatArea({
	{1,1,1,1,1},
	{1,1,1,1,1},
	{1,1,3,1,1},
	{1,1,1,1,1},
	{1,1,1,1,1}
}))

function creatureSayCallback(cid, type, msg)
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	if(not npcHandler:isFocused(cid)) then
		return false
	end
	
	if(msg:lower() == "halloween") then
		doCombat(getNpcId(), combat, numberToVariant(getNpcId()))
		npcHandler:say('You are Dead, Suprise!', 0)
	end
	return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

 

Se o de área não funcionar, tente esse:

  Mostrar conteúdo oculto


local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
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
npcHandler:setMessage(MESSAGE_GREET, "Hello |PLAYERNAME|. Say {halloween}.")

local outfits = {857,853,852,851,843,837,833,785,720,659,597,549,544,523,510,878,877,890}
local condition = createConditionObject(CONDITION_OUTFIT, (3 * 24 * 3600 * 1000))

function creatureSayCallback(cid, type, msg)
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	if(not npcHandler:isFocused(cid)) then
		return false
	end
	
	if(msg:lower() == "halloween") then
		addOutfitCondition(condition, {lookType = math.random(#outfits)})
		doAddCondition(cid, condition)
		doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
		npcHandler:say('You are Dead, Suprise!', 0)
	end
	return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

 

 

 O de área não funcionou, o debaixo funcionou mais da debug até o char deslogar e voltar pra outfit normal..

x1fCxnI.png

Postado
  • Autor

@Wise

Ele funciona somente uma vez, tem como tirar o storage? porque funcionando só uma vez quando o jogador reloga a outfit some..

 

@Edit 

Já arrumei obrigado aos dois!

Editado por One Punch Man (veja o histórico de edições)

x1fCxnI.png

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.6k

Informação Importante

Confirmação de Termo