athenso
Average Coder
- Joined
- May 31, 2011
- Messages
- 155
- Solutions
- 3
- Reaction score
- 23
NPC Script:
Npc File:
Those are the files needed to do the rebirth in my server. I have seen people request an Onlook event/function. I made on for that
Events folder -> Scripts -> player.lua
Under function Player: onLook(thing, position, distance) add
Your welcome
Code:
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
local function greetCallback(cid)
local player = Player(cid)
local msg = 'Be welcome, ' .. player:getName() .. '.'
local level = player:getLevel()
local req = 399
npcHandler:say(msg,cid)
npcHandler:addFocus(cid)
return false
end
local function rebirth(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
return false
end
local player = Player(cid)
local level = player:getLevel()
local req = 399
local creature = Player(cid)
local guid = player:getGuid()
if level > req then
player:setStorageValue(85987, player:getStorageValue(85987) == -1 and 1 or player:getStorageValue(85987) + 1)
creature:remove()
db.query("UPDATE `players` SET `level` = 8, `experience` = 4200 WHERE `id` = " .. guid)
else
npcHandler:say('You are not level 400, BEGONE!', cid)
keywordHandler:moveUp(2)
end
return true
end
keywordHandler:addKeyword({'rebirth'}, rebirth, {})
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:addModule(FocusModule:new())
Npc File:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Wiseman" script="wiseman.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100" />
<look type="512" head="114" body="19" legs="95" feet="77" addons="3"/>
</npc>
Those are the files needed to do the rebirth in my server. I have seen people request an Onlook event/function. I made on for that
Events folder -> Scripts -> player.lua
Under function Player: onLook(thing, position, distance) add
Code:
-- Reborn look by Athenso
if thing:isCreature() and thing:isPlayer() then
local reborn = thing:getStorageValue(85987)
if reborn <= 0 then
description = string.format("%s\n [Rebirths Done]: %s", description, 0)
else
description = string.format("%s\n [Rebirths Done]: %s", description, reborn)
end
end
Your welcome