SP
npc

Npc Resetador

Por Spraypaint, 30 de jun. de 2012 em NPCs, monsters e raids

script
13
2.7k
SpraypaintS
30 de junho de 2012 às 02:55

Funcional em:



TFS 8.6 DEV 0.4 (REV3884)

Esse npc não foi criando somente por mim eu apenas aperfeiçoei e coloquei novas

funções tirando também diversos bugs que atrapalhavam seu funcionamento.

 

Em data/npc coloque:




<?xml version="1.0"?><npc name="Resetador" script="data/npc/scripts/reseter.lua" walkinterval="0" floorchange="0">
<health now="100" max="100"/>
<look type="133" head="10" body="122" legs="19" feet="10"/>
<parameters>
<parameter key="message_greet" value="Ola, |PLAYERNAME|. Eu posso {resetar} seu level. "/>
</parameters>
</npc>



 

 

Crie um arquivo .lua em data\npc\scripts e coloque

 


-- config
local minlevel = 50 -- level inical para resetar
local price = 1000 -- preço inicial para resetar
local newlevel = 8 -- level após reset
local newexp = 4200 -- nova experiencia após reset
local lvlByReset = 50 -- level acrescentado por reset
local priceByReset = 100 -- preço acrescentado por reset
local maxResets = 100 -- máximo de resets
-- end config


function addReset(cid)
resets = getResets(cid)
setPlayerStorageValue(cid,1020,resets+1)
return true
end


function getResets(cid)
resets = getPlayerStorageValue(cid,1020)
if resets < 0 then
resets = 0
end
return resets
end




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 needlvl = minlevel + (getResets(cid) * lvlByReset)
local newPrice = price + (getResets(cid) * priceByReset)


if msgcontains(msg, 'resetar') then
if getResets(cid) < maxResets then
selfSay('Voce deseja reset seu char? Isto custará '..newPrice..' gp\'s!', cid)
talkState[talkUser] = 1
else
selfSay('Você ja alcançou seu limite de resets!', cid)
end
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if getPlayerMoney(cid) < newPrice then
selfSay('É Necessario ter '..newPrice..' gp\'s para resetar!', cid)
elseif getPlayerLevel(cid) < needlvl then
selfSay('O level minimo para reset é '..needlvl..'!', cid)
else
doPlayerRemoveMoney(cid,newPrice)
if isInArray(vocs, getPlayerVocation(cid)) then
doPlayerSetVocation(cid, getPlayerVocation(cid)+4)
end
addReset(cid)
playerid = getPlayerGUID(cid)
doRemoveCreature(cid)
db.executeQuery("UPDATE `players` SET `level`="..newlevel..",`experience`="..newexp.." WHERE `players`.`id`= ".. playerid .."")
end
talkState[talkUser] = 0
elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
talkState[talkUser] = 0
selfSay('Ok.', cid)
elseif msgcontains(msg, 'quant') then
selfSay('Voce tem um total de '..getResets(cid)..' reset(s).', cid)
end


return true
end


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



 

Creditos pelo npc base:

@nubinho

Qualquer duvida postem ai abaixo!

Editado Agosto 4 por Spraypaint

VincV
30 de junho de 2012 às 10:54

deu bug na formatação,algums sinais como "<",">" e outros bugaram,arrume

SpraypaintS
30 de junho de 2012 às 12:04

Tente agora !

VincV
30 de junho de 2012 às 18:23

eu n testei.eu apenas avisei, por que estava visivel. e nem testarei

1 mês depois...
LuncVL
22 de julho de 2012 às 21:29

'then' expected near '&' error

lukas13onL
25 de julho de 2012 às 09:33

Aqui está

 

 

-- SCRIPT FEITO POR YUNIE
-- config
minlevel = 400 -- level para resetar
price = 0
newlevel = 10 -- level após reset
newexp = 9300 -- nova experiencia após reset
-- end config

function addReset(cid)
resets = getResets(cid)
setPlayerStorageValue(cid,36874,resets+1)
return true
end

function getResets(cid)
resets = getPlayerStorageValue(cid,36874)
if resets < 0 then
resets = 0
end
return resets
end


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, 'reset') then
selfSay('Do you want to reset your character level? Your character will be logged off if you confirm. You must pay '..price..' gold coins to reset.', cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if getPlayerMoney(cid) < price then
selfSay('You must pay '..price..' gold coins to reset.', cid)
elseif getPlayerLevel(cid) < minlevel then
selfSay('You must be at least level '.. minlevel ..' to reset.', cid)
else
doPlayerRemoveMoney(cid,price)
addReset(cid)
playerid = getPlayerGUID(cid)
doRemoveCreature(cid)
db.executeQuery("UPDATE `players` SET `level`="..newlevel..",`experience`="..newexp.." WHERE `players`.`id`= ".. playerid .."")
end
talkState[talkUser] = 0
elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
talkState[talkUser] = 0
selfSay('Ok.', cid)
elseif msgcontains(msg, 'quant') then
selfSay('You have '..getResets(cid)..' reset(s).', cid)
end

return true
end

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

gab3690G
27 de julho de 2012 às 21:05

Tem como colocar quando resetar muda a vocaçao

PlfmouraP
31 de julho de 2012 às 19:50

Ta dando erro aqui -' / fexa o Ot quando o player vai falar com o NPC

SpraypaintS
31 de julho de 2012 às 20:05

Eu acho que em tfs não roda eu estava testando ele em Forgu~

SpraypaintS
04 de agosto de 2012 às 04:09

Eu refiz alguns testes aqui o script ta funcionando em TFS 8.6 DEV 0.4 (REV3884)+ ...100%

@up

Refiz o topico!Agora ficara mais facil abrçs

Editado Agosto 4 por Spraypaint

1 ano depois...
DavyziinCD
13 de agosto de 2013 às 20:01

Como faz pra reseta o magic level também?

3 meses depois...
gustavo3754G
12 de novembro de 2013 às 07:46

Teria como colocar para trocar a vocação? E não só com um personagem mais com varios.

DBWBrasilD
12 de novembro de 2013 às 08:17

CrazzyMaster

 

 

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 config = {
--[Vocation] = ( Nova Vocation, New Outfit )
[8] = { 9, 137},
[19] = { 20, 198},
[30] = { 31, 565},
[41] = { 42, 565}
}
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, 'reborn') and getPlayerStorageValue(cid,30025) == 4 then
selfSay('You are reborn.', cid)
focus = 0
talk_start = 0

elseif msgcontains(msg, 'reborn') and getPlayerLevel(cid) < 250 and getPlayerStorageValue(cid,30025) ~= 4 then
selfSay('Hmm, Desculpe. Você não tem level 250.', cid)

elseif msgcontains(msg, 'reborn') then
selfSay('Are you sure? {yes}', cid)
talkState[talkUser] = 2

elseif msgcontains(msg, 'yes') and talkState[talkUser] == 2 and getPlayerLevel(cid) >= 250 then
local voc = config[getPlayerVocation(cid)]
doPlayerSetVocation(cid, voc[1])
local outfit = {lookType = voc[2]}
doCreatureChangeOutfit(cid, outfit)
doPlayerAddExp(cid, -(getPlayerExperience(cid)-getExperienceForLevel(1)))
setCreatureMaxHealth(cid, getCreatureMaxHealth(cid)+20000)
setCreatureMaxMana(cid, getCreatureMaxMana(cid)+30000)
doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
doCreatureAddMana(cid, getCreatureMaxMana(cid))
setPlayerStorageValue(cid,30025,4)
talkState[talkUser] = 0

elseif msgcontains(msg, 'yes') and talkState[talkUser] == 2 then
selfSay('Desculpe, ' .. getCreatureName(cid) .. '! Voce precisa reverter ou transformar para rebornar.', cid)
talkState[talkUser] = 0

elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
selfSay('Good bye.', cid)
focus = 0
talk_start = 0
end

return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

 

<npc name="Reborn" script="data/npc/scripts/reborn.lua" walkinterval="0" floorchange="0" access="5" level="1" maglevel="1">
<health now="100" max="100"/>
<look type="118" head="57" body="59" legs="40" feet="76" addons="3"/>
<parameters>
<parameter key="message_greet" value="Hello |PLAYERNAME|. Reborn!" />
</parameters>
</npc>

 

Espero que isso ajude.