Ir para conteúdo

Npc Resetador


Spraypaint

Posts Recomendados

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 por Spraypaint
Link para o comentário
Compartilhar em outros sites

  • 4 weeks later...

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())

Link para o comentário
Compartilhar em outros sites

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 por Spraypaint
Link para o comentário
Compartilhar em outros sites

  • 1 year later...
  • 2 months later...

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.

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...