NPC Reseter with Look
Hi,
Im have a server 999x and i have this NPC and i decided share with Otland.net
First go to data\npc\scripts and make a reset.lua and put this:
Lua:
--
-- config
local minlevel = 3000 -- level to reset
local minlevel_vip = 2500 -- level for VIP
local price = 100000 Price of reset
local newlevel = 10 -- level after reset
local newexp = 9300 -- Exp after reset
-- end config
function addReset(cid)
return setPlayerStorageValue(cid, 36874, getResets(cid) + 1)
end
function getResets(cid)
return math.max(0, getPlayerStorageValue(cid, 36874))
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
if msgcontains(msg, 'reset') then
selfSay('Voce aceita o reset? se voce confirmar tera que deslogar para que o reset tenha efeito. voce tera que pagar a quantia de '..price..' GP para o reset.', cid)
talkState[cid] = 1
elseif(msgcontains(msg, 'yes') and talkState[cid] == 1) then
if getPlayerMoney(cid) < price then
selfSay('You must pay '..price..' gold coins to reset.', cid)
elseif getPlayerLevel(cid) < (vip.hasVip(cid) and minlevel_vip or minlevel) then
selfSay('Voce precisa ter no minimo level '.. minlevel ..' para o 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[cid] = 0
elseif msgcontains(msg, 'no') and isInArray({1}, talkState[cid]) then
talkState[cid] = 0
selfSay('Yes', cid)
elseif msgcontains(msg, 'resets') then
selfSay('You Have '..getResets(cid)..' reset(s).', cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
now go to data\npc make reset.xml and put this:
Lua:
<?xml version="1.0"?>
<npc name="Reseter" script="data/npc/scripts/reset.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="Hello, |PLAYERNAME|. for reset say {reset}, or you wanna see how many resets you have say {resets}."/>
</parameters>
</npc>
Now for look how many resets have player.
Go to data/creaturescript/scripts and make resetlook.lua and put this:
Lua:
function onLook(cid, thing, position, lookDistance)
if isPlayer(thing.uid) then
doPlayerSetSpecialDescription(thing.uid, (getPlayerSex(thing.uid) == 0 and ".\nShe" or ".\nHe") .." has "..math.max(0, getPlayerStorageValue(thing.uid, 36874)).." resets")
return true
end
return true
end
Now go to login.lua with other registrations put this:
Lua:
registerCreatureEvent(cid, 'ResetLook')
Now go to data/creaturescript and open creaturescripts.xml and put this:
Lua:
<event type="look" name="ResetLook" event="script" value="resetlook.lua"/>
Now have FUN.
DONT FORGET TO REP ME
Last edited: