• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Reborn Npc

mocoba

New Member
Joined
Aug 23, 2008
Messages
332
Reaction score
0
How i Fix This Error
PHP:
[11/02/2011 17:43:46] [Error - LuaScriptInterface::loadFile] data/npc/scripts/reborn.lua:41: 'end' expected (to close 'function' at line 14) near '<eof>'
[11/02/2011 17:43:46] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/reborn.lua
[11/02/2011 17:43:46] data/npc/scripts/reborn.lua:41: 'end' expected (to close 'function' at line 14) near '<eof>'
And Script.lua
local t = {
level=700, -- level required for rebirth
RemainingLvl=8, -- {8} = level(normal) level you become after the rebirth
skull=true, -- players with white skull can ascend?
redskull=true, -- players with red skull can ascend?
prot=true, -- players must be in protection zone to ascend?
bat=true -- players must not have battle condition to ascend?
}

local function getResets(cid)
return math.max(0, getPlayerStorageValue(cid, 1020))
end

function onSay(cid, words, param)
local skull = getCreatureSkullType(cid)
if (not t.skull and skull == SKULL_WHITE) or (not t.redskull and skull == SKULL_RED) then
doPlayerSendTextMessage(cid, 22, 'You cannot ascend with a ' .. (skull == SKULL_WHITE and 'white' or 'red') .. ' skull.')
end

local pos = getThingPos(cid)
if t.prot and not getTileInfo(pos).protection then
return doPlayerSendTextMessage(cid, 22, 'You must be in a protection zone to ascend.')
elseif t.bat and hasCondition(cid, CONDITION_INFIGHT) then
return doPlayerSendTextMessage(cid, 22, 'You must lose your battle sign to ascend.')
end

local lvl = getPlayerLevel(cid)
if lvl >= t.level then
local new, newLvl = getResets(cid) + 1, math.max(t.RemainingLvl, t.RemainingLvl + lvl - t.level)
setPlayerStorageValue(cid, 1020, new)
doPlayerSetSpecialDescription(cid, '. ' .. (getPlayerSex(cid) == 0 and 'Sh' or 'H') .. 'e is on Ascension # ' .. new)
doPlayerPopupFYI(cid, 'You have ascended, and you now have ' .. new .. ' reset' .. (new == 1 and '' or 's') .. ' in total.')
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
local pid, hp, mana = getPlayerGUID(cid), math.ceil(getCreatureMaxHealth(cid) * (0.2 * new)), math.ceil(getCreatureMaxMana(cid) * (0.2 * new))
doRemoveCreature(cid)
db.executeQuery('UPDATE `players` SET `level` = ' .. newLvl .. ', `experience` = ' .. getExperienceForLevel(newLvl) .. ', `promotion` = 0, `health` = ' .. hp ..', `healthmax` = ' .. hp .. ', `mana` = ' .. mana .. ', `manamax` = ' .. mana .. ' WHERE `id` = ' .. pid .. ' LIMIT 1;')
else
doPlayerSendCancel(cid, 'You need to reach level ' .. t.level .. ' or higher to ascend.')
doSendMagicEffect(pos, CONST_ME_POFF)
end
return true
Thanks
 
please copy and paste reborn.lua here (but use code instead of php), unless we can see the script we can't help

i can hazard a guess that you need to add another "end" at the bottom of the script though
 
PHP:
local function getResets(cid)
return math.max(0, getPlayerStorageValue(cid, 1020))
end
local t = {
level=700, -- level required for rebirth
RemainingLvl=8, -- {8} = level(normal) level you become after the rebirth
skull=true, -- players with white skull can ascend?
redskull=true, -- players with red skull can ascend?
prot=true, -- players must be in protection zone to ascend?
bat=true -- players must not have battle condition to ascend?
}

function onSay(cid, words, param)
	local skull = getCreatureSkullType(cid)
		if (not t.skull and skull == SKULL_WHITE) or (not t.redskull and skull == SKULL_RED) then
			doPlayerSendTextMessage(cid, 22, 'You cannot ascend with a ' .. (skull == SKULL_WHITE and 'white' or 'red') .. ' skull.')
		end
	local pos = getThingPos(cid)
		if t.prot and not getTileInfo(pos).protection then
			return 
			doPlayerSendTextMessage(cid, 22, 'You must be in a protection zone to ascend.')
		elseif t.bat and hasCondition(cid, CONDITION_INFIGHT) then
			return 
			doPlayerSendTextMessage(cid, 22, 'You must lose your battle sign to ascend.')
		end
	local lvl = getPlayerLevel(cid)
		if lvl >= t.level then
			local new, newLvl = getResets(cid) + 1, math.max(t.RemainingLvl, t.RemainingLvl + lvl - t.level)
			setPlayerStorageValue(cid, 1020, new)
			doPlayerSetSpecialDescription(cid, '. ' .. (getPlayerSex(cid) == 0 and 'Sh' or 'H') .. 'e is on Ascension # ' .. new)
			doPlayerPopupFYI(cid, 'You have ascended, and you now have ' .. new .. ' reset' .. (new == 1 and '' or 's') .. ' in total.')
			doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
			local pid, hp, mana = getPlayerGUID(cid), math.ceil(getCreatureMaxHealth(cid) * (0.2 * new)), math.ceil(getCreatureMaxMana(cid) * (0.2 * new))
			doRemoveCreature(cid)
			db.executeQuery('UPDATE `players` SET `level` = ' .. newLvl .. ', `experience` = ' .. getExperienceForLevel(newLvl) .. ', `promotion` = 0, `health` = ' .. hp ..', `healthmax` = ' .. hp .. ', `mana` = ' .. mana .. ', `manamax` = ' .. mana .. ' WHERE `id` = ' .. pid .. ' LIMIT 1;')
		else
			doPlayerSendCancel(cid, 'You need to reach level ' .. t.level .. ' or higher to ascend.')
			doSendMagicEffect(pos, CONST_ME_POFF)
		end
	return true 
end
 
Code:
function onSay(cid, words, param)
is for talkactions IIRC
Code:
function onCreatureSay(cid, type, msg)
is for NPC chat

I may be wrong, I don't script NPCs often lol
 
Code:
local function getResets(cid)
return math.max(0, getPlayerStorageValue(cid, 1020))
end
local t = {
level=700, -- level required for rebirth
RemainingLvl=8, -- {8} = level(normal) level you become after the rebirth
skull=true, -- players with white skull can ascend?
redskull=true, -- players with red skull can ascend?
prot=true, -- players must be in protection zone to ascend?
bat=true -- players must not have battle condition to ascend?
}

function onCreatureSay(cid, type, msg)
	local skull = getCreatureSkullType(cid)
		if (not t.skull and skull == SKULL_WHITE) or (not t.redskull and skull == SKULL_RED) then
			doPlayerSendTextMessage(cid, 22, 'You cannot ascend with a ' .. (skull == SKULL_WHITE and 'white' or 'red') .. ' skull.')
		end
	local pos = getThingPos(cid)
		if t.prot and not getTileInfo(pos).protection then
			return 
			doPlayerSendTextMessage(cid, 22, 'You must be in a protection zone to ascend.')
		elseif t.bat and hasCondition(cid, CONDITION_INFIGHT) then
			return 
			doPlayerSendTextMessage(cid, 22, 'You must lose your battle sign to ascend.')
		end
	local lvl = getPlayerLevel(cid)


		if lvl >= t.level then
                        if doPlayerRemoveItem(cid, CRYSTALCOINITEMNUMBER, 100) == FALSE then
                              	doPlayerSendCancel(cid, 'You need to 100 Crystal Coins to ascend.')
			        doSendMagicEffect(pos, CONST_ME_POFF) 
                                return FALSE
                        end

			local new, newLvl = getResets(cid) + 1, math.max(t.RemainingLvl, t.RemainingLvl + lvl - t.level)
			setPlayerStorageValue(cid, 1020, new)
			doPlayerSetSpecialDescription(cid, '. ' .. (getPlayerSex(cid) == 0 and 'Sh' or 'H') .. 'e is on Ascension # ' .. new)
			doPlayerPopupFYI(cid, 'You have ascended, and you now have ' .. new .. ' reset' .. (new == 1 and '' or 's') .. ' in total.')
			doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
			local pid, hp, mana = getPlayerGUID(cid), math.ceil(getCreatureMaxHealth(cid) * (0.2 * new)), math.ceil(getCreatureMaxMana(cid) * (0.2 * new))
			doRemoveCreature(cid)
			db.executeQuery('UPDATE `players` SET `level` = ' .. newLvl .. ', `experience` = ' .. getExperienceForLevel(newLvl) .. ', `promotion` = 0, `health` = ' .. hp ..', `healthmax` = ' .. hp .. ', `mana` = ' .. mana .. ', `manamax` = ' .. mana .. ' WHERE `id` = ' .. pid .. ' LIMIT 1;')
		else
			doPlayerSendCancel(cid, 'You need to reach level ' .. t.level .. ' or higher to ascend.')
			doSendMagicEffect(pos, CONST_ME_POFF)
		end
	return true 
end

that should help ;) but replace CRYSTALCOINIDNUMBER with the ID of crystal coin, I don't remember it off the top of my head xD
 
Code:
                        if doPlayerRemoveItem(cid, CRYSTALCOINITEMNUMBER, 100) == FALSE then
                              	doPlayerSendCancel(cid, 'You need to 100 Crystal Coins to ascend.')
			        doSendMagicEffect(pos, CONST_ME_POFF) 
                                return FALSE
                        end

added this if you look ;)
 
Back
Top