Ir para conteúdo

Featured Replies

Postado

Nome: Present

Tipo de arquivo: Npc

Versão: 8.6x

Bem pessoal, estava demorando para postar esse npc maravilhoso de uma ídeia genial que eu tive e será; maravilhosamente útil para vocês (creio eu).

Oque ele faz?

  • O player pode falar com o npc e pegar 1 presente por dia
  • Não adianta burlar, o player só poderá; pegar 1 presente por dia
  • O NPC Zera todos os dias às 00:00 (criando novas Storagevalue)
  • O npc zera altomaticamente
  • O horario é configurado de acordo com o horario do seu computador
  • Após o npc zerar, o player poderá pegar o presente diario dele, e só poderá pegar outro no proximo dia
  • Funciona perfeitamente na versão 8.60 TFS 0.4

O NPC usa a função "string.sub(os.date()".

Abra a pasta data/npc/scripts/ e crie um documento de texto .lua com o nome present e cole isso:


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

	---------------- config msg ------------------

	local frase1 = 'Present'  -- (Player) -- Oque o player ira dizer para o npc --

	local frase2 = 'Presente'  -- (Player) -- Oque o player ira dizer para o npc² --

	local frase3 = 'Você quer o presente agora?'-- Npc)  -- voce quer agora? --

	local frase4 = 'yes' -- (Player) -- yes --

	local frase5 = 'Me desculpe! Você já ganhou hoje.' -- (Npc) -- voce ja ganhou por hj --

	local frase6 = 'Obrigado, volte sempre' -- (Npc) -- aqui esta e seja feliz --

	local frase7 = 'no' -- (Player) -- nao --

	local frase8 = 'ok, poderas pegar mais tarde' -- (Npc) -- ok entao pega mais tarde --

	local storage = 3333 -- storage que define o dia nao mexa a nao ser que saiba ps: use uma storage que nao esteja sendo usada =D--

	local itemid = 7702 -- Present Diary --

	----------------------------------------------

	if (msgcontains(msg, frase1) or msgcontains(msg, frase2)) and getPlayerStorageValue(cid, storage) == tonumber(string.sub(os.date(),4,5)) then

				selfSay(frase5, cid)

	elseif(msgcontains(msg, frase1) or msgcontains(msg, frase2)) then

		selfSay(frase3, cid)

		talkState[talkUser] = 1

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

			selfSay(frase6, cid)

			setPlayerStorageValue(cid, storage, tonumber(string.sub(os.date(),4,5)))

			doPlayerAddItem(cid, itemid)

		talkState[talkUser] = 0

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

		talkState[talkUser] = 0

		selfSay(frase8, cid)

		end

	return TRUE

end


npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

Nem preciso ensinar como configurar né? Agora em data/npc/ crie um arquivo .xml e renomeie para present, abra-o e adicione:

<?xml version="1.0" encoding="UTF-8"?>

<npc name="Fiscal da presenca" script="Present.lua" walkinterval="2000" floorchange="0">

	<health now="100" max="100"/>

	<look type="128" head="17" body="54" legs="114" feet="0" addons="3"/>

	<parameters>

		<parameter key="message_greet" value="Hello |PLAYERNAME|, I am a Present diary! Say {present} to receive your gift today."/>

	</parameters>

</npc>

EDIT: O item 7702 que está no script, é um item que eu fiz que dar ao player muitos outros items, como uma bousa de items, que ao clicar, dar items Random entre 1 a 15... Você poderá colocar o ID que quiser, também poderá pegar minha ideia se preferir... Caso gostaria de por esse script na pagina do seu gesior ta aqui. Para adicionar, va até Htdocs ou www/ e crie um arquivo .php com o nome Present e adicione isso:

<HTML>

<HEAD>

<TITLE>

<?php

	$main_content .= '

	<h1><center><b>Presen&ccedil;a Di&aacute;ria<h1></center></b>

<table width="100%" cellspacing=1 cellpadding=4 border="0">

  <tr bgcolor="'.$config['site']['vdarkborder'].'">

	<th align="left">Legenda</th>

  </tr>

  <tr bgcolor="'.$config['site']['darkborder'].'">

	<td align="left" valign="top">

	<ul>

	<li>

	<strong>

	Você terá a oportunidade de participar da Missão de Presença Diária obtida com a NPC Fiscal de Presença, ganhando recompensas diárias. São dez tipos de recompensas, então se programe para não perder nenhum dia do evento em busca da recompensa máxima!

	</strong>

	</li>

	  <br>

	  <li>

	<strong>

	  Essa é uma missão especial que fica disponível temporariamente de tempos em tempos. Basta já ter alcançado no mínimo o nível 200 para poder participar. Você pode repetir a missão diariamente e acumular prêmios.</td>

	</strong>

	</li>

	</ul>

  </tr>

</table>

<br>

<table width="100%" cellspacing=1 cellpadding=4 border="0">

  <tr bgcolor="'.$config['site']['vdarkborder'].'">

	<th width="100%">Como participar?</th>

  </tr>

</table>

<table cellspacing=1 cellpadding=4 width="100%" border="0">

  <tr bgcolor="'.$config['site']['darkborder'].'" align="center">

	<td width="100%" align="center"><strong>Primeiro, você precisa falar com o NPC Fiscal de Presença localizado próximo ao "NPC DE RINGS" na cidade principal de Draconia para pegar a Missão. Lembrando que você só pode pegar essa Missão uma vez por dia.</strong></td>

  </tr>

</table>

<br>

<table width="100%" cellspacing=1 cellpadding=4 border="0">

  <tr bgcolor="'.$config['site']['vdarkborder'].'">

	<th width="100%">E qual é essa recompensa?</th>

  </tr>

</table>

<table cellspacing=1 cellpadding=4 width="100%" border="0">

  <tr bgcolor="'.$config['site']['darkborder'].'" align="center">

	<td width="100%" align="center"><strong>Todo dia que você completar a Missão, vai receber um pacote de itens. Abaixo listarei os items disponiveis possiveis de dropar no "presencia diaria".</strong></td>

  </tr>

</table>

<br>

<table width="100%" cellspacing=1 cellpadding=4 border="0">

  <tr bgcolor="'.$config['site']['vdarkborder'].'">

	<th width="33%">Item</th>

	<th width="33%">Chance de droop</th>

  </tr>

</table>

<table cellspacing=1 cellpadding=4 width="100%" border="0">

  <tr bgcolor="'.$config['site']['darkborder'].'" align="center">

	<td width="33%" align="center"><strong>100k</strong></td>

	<td width="33%"><strong>10%</strong></td>

  </tr>

  <tr bgcolor="'.$config['site']['lightborder'].'" align="center">

	<td width="33%"><strong>Magic Plate Armor</strong></td>

	<td width="33%"><strong>10%</strong></td>

  </tr>

  <tr bgcolor="'.$config['site']['darkborder'].'" align="center">

	<td width="33%"><strong>Boots Of Haste</strong></td>

	<td width="33%"><strong>10%</strong></td>

  </tr>

  <tr bgcolor="'.$config['site']['lightborder'].'" align="center">

	<td width="33%"><strong>Demon Shield</strong></td>

	<td width="33%"><strong>10%</strong></td>

  </tr>

  <tr bgcolor="'.$config['site']['darkborder'].'" align="center">

	<td width="33%"><strong>Frozen Starlight</strong></td>

	<td width="33%"><strong>10%</strong></td>

  </tr>

  <tr bgcolor="'.$config['site']['lightborder'].'" align="center">

	<td width="33%"><strong>Annihilation Bear</strong></td>

	<td width="33%"><strong>10%</strong></td>

  </tr>

  <tr bgcolor="'.$config['site']['darkborder'].'" align="center">

	<td width="33%"><strong>Piece Of Draconian Steel</strong></td>

	<td width="33%"><strong>10%</strong></td>

  </tr>

  <tr bgcolor="'.$config['site']['lightborder'].'" align="center">

	<td width="33%"><strong>Golden Legs</strong></td>

	<td width="33%"><strong>10%</strong></td>

  </tr>

  <tr bgcolor="'.$config['site']['darkborder'].'" align="center">

	<td width="33%"><strong>Crown</strong></td>

	<td width="33%"><strong>10%</strong></td>

  </tr>

  <tr bgcolor="'.$config['site']['lightborder'].'" align="center">

	<td width="33%"><strong>Goldfish Bowl</strong></td>

	<td width="33%"><strong>10%</strong></td>

  </tr>

</table>

<br>

<p align="right">

Page Present By: <a href="mailto:[email protected]">Weslley</a>


	';

?>

</TITLE>

<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">

</HEAD>

Agora em Index.php adicione:

   	 case "present":

				$topic = "Present Diary";

				$subtopic = "present";

				include("present.php");

		break;

Depois va em layout/.(nomedolayout)./layout.php abra e adicione:

<a href='?subtopic=present'>

  <div id='submenu_present' class='Submenuitem' onMouseOver='MouseOverSubmenuItem(this)' onMouseOut='MouseOutSubmenuItem(this)'>

	<div class='LeftChain' style='background-image:url(<?PHP echo $layout_name; ?>/images/general/chain.gif);'></div>

	<div id='ActiveSubmenuItemIcon_present' class='ActiveSubmenuItemIcon' style='background-image:url(<?PHP echo $layout_name; ?>/images/menu/icon-activesubmenu.gif);'></div>

	<div class='SubmenuitemLabel'>Presence diary</div>

	<div class='RightChain' style='background-image:url(<?PHP echo $layout_name; ?>/images/general/chain.gif);'></div>

  </div>

</a>

Screenshot:

semttulots.png

Script Present + pagina gesior.rar

Créditos: Willams 80%

............Subyth 20%

Editado por Subyth.
Adicionando QUOTE (veja o histórico de edições)

  • Respostas 19
  • Visualizações 4.8k
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • Nome: Present Tipo de arquivo: Npc Versão: 8.6x Bem pessoal, estava demorando para postar esse npc maravilhoso de uma ídeia genial que eu tive e será; maravilhosamente útil para

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

  • Não, ele é basico. Ele adiciona uma storagevalue ao player, quando é 00:00 hr no computador ele rezeta o storagevalue do player, mais não avisa o tempo que falta para pegar novamente.

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

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 msg = string.lower(msg)

local config = {

hours = 24,

storage = 58485,

rewards = {{itemid = 2173,chance = 15},{itemid = 2123,chance = 25},{itemid = 2160,chance = 30}} -- itens que ele poderá ganhar 

}

function doAddReward()

a = true

while a == true do

local m = math.random(1,#config.rewards)

if config.rewards[m].chance > math.random(1, 100) then

doPlayerAddItem(cid, config.rewards[m].itemid, isItemStackable(config.rewards[m].itemid) and 100 or 1)

npcHandler:say("seu prêmio foi: "..getItemNameById(config.rewards[m].itemid), cid)

a = false

end

end

end

if isInArray({"presente","present"}, msg) then

npcHandler:say("você deseja receber seu presente agora?! {yes}", cid)

talkState[talkUser] = 1

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

if getPlayerStorageValue(cid,config.storage) <= os.time() then

doAddReward()

setPlayerStorageValue(cid, config.storage, os.time()+config.hours*3600)

else

npcHandler:say("Desculpe, mas você deve aguardar até "..os.date("%d %B %Y %X ", getPlayerStorageValue(cid,config.storage)).." para pegar seu presente novamente!", cid)

talkState[talkUser] = 0

end

elseif msg == "no" then  

selfSay("Then not", cid)  

talkState[talkUser] = 0  

npcHandler:releaseFocus(cid)  

end

return TRUE

end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

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

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