• 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!

NPC Prestige/rebirth System with onlook working

Tjay

Retired Hoster
Joined
Nov 25, 2009
Messages
588
Reaction score
69
Location
Behind you. Look out!
UPDATED 5-26-2014. On look works properly now add also added a few extras to the npc max rebirths and broadcast on rebirth. Also This is tested on 0.3.6
First for the NPC
1-Open a new notepad or w.e you use. I use Notepad++ alot neater Notepad++ v5.9.3 - Current Version
2-Past the following script below in your npc folder, and save it as Prestige NPC.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Prestige Npc" script="data/npc/scripts/rebirth.lua" walkinterval="2000" floorchange="0">
    <health now="100" max="100"/>
<look type="73" head="78" body="88" legs="0" feet="88" addons="3"/>
    <parameters>
        <parameter key="message_greet" value="Hello |PLAYERNAME|. Im in charge of the 'Prestige' system."/>
        <parameter key="message_farewell" value="Good bye my dear friend."/>
    </parameters>
</npc>
3-Paste the following script below in your npc/scripts folder and save it as Rebirth.lua
Code:
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, 'prestige')) then
        selfSay('Are you ready to prestige and start a new life?', cid)
        talkState[talkUser] = 1
    elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
        -------CONFIGS-------
        local level = 500
        local cost = 10000
        ------/CONFIGS-------
        -----LOCALS-----
        local id = getPlayerGUID(cid)
        local name = getCreatureName(cid)
        local vocation = getPlayerVocation(cid)
        local storage = getCreatureStorage(cid, 85987)
        local Max_Rebirth = 5  --Change this for the number of rebirths

        ----/LOCALS-----
        if(getPlayerLevel(cid) >= level) then
        if getCreatureStorage(cid, 85987) < Max_Rebirth then
            if(doPlayerRemoveMoney(cid, cost) == TRUE) then
                if(isInArray({5, 6, 7, 8}, vocation)) then
                    doCreatureSetStorage(cid, 85987, storage == -1 and 1 or storage + 1)
                                db.executeQuery('UPDATE players SET rebirths=rebirths+'.. 1 ..' WHERE id='..getPlayerGUID(cid))
                            doBroadcastMessage("" ..  name .. " has just prestiged!", TALKTYPE_ORANGE_1)
                    doRemoveCreature(cid)
                    db.executeQuery("UPDATE `players` SET `level` = 8, `experience` = 4200")
                    db.executeQuery("UPDATE `players` SET `name` = '"..name.."' WHERE `id` ='"..id.."';")
                else
                    selfSay('Please talk with Forgotten King and promote first.', cid)
                    talkState[talkUser] = 0
                end
            else
                selfSay('You don\'t have enough money. You need to pay 10 mil to be rebirthed.', cid)
                talkState[talkUser] = 0
            end
        else
            selfSay('You have reached the maximum rebirth.', cid)
            talkState[talkUser] = 0
        end
    else
        selfSay('Only characters of level 500 or higher can be rebirthed.', cid)
        talkState[talkUser] = 0
    end
elseif(msgcontains(msg, 'no') and talkState[talkUser] == 1) then
        selfSay('Okey. Come back when you feel ready.', cid)
        talkState[talkUser] = 0
end

    return true
end

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

If you need help understanding the configs etc just ask.

4-Onlook- for yall that dont know what this is it basicly just adds this to when u look at a character.
You have prestiged "x" times.
----Past the following script below in your Creaturescripts scripts folder, and save it as RebirthDescription.lua
Code:
function onLook(cid, thing, position, lookDistance)
    if isPlayer(thing.uid) and thing.uid ~= cid then
        local sex = getPlayerSex(thing.uid)
        local message = "You see " .. getPlayerName(thing.uid) .. " (Level " .. getPlayerLevel(thing.uid) .. ")."
        if(getPlayerFlagValue(thing.uid, PLAYERFLAG_SHOWGROUPINSTEADOFVOCATION)) then
            message = message .. " " .. (sex == PLAYERSEX_FEMALE and "She" or "He") .. " is a " .. getPlayerGroupName(thing.uid) .. "."
        elseif(getPlayerVocation(thing.uid) ~= 0) then
            message = message .. " " .. (sex == PLAYERSEX_FEMALE and "She" or "He") .. " is a " .. getPlayerVocationName(thing.uid):lower() .. "."
        else
            message = message .. " " .. (sex == PLAYERSEX_FEMALE and "She" or "He") .. " has no vocation."
        end

        if(getPlayerNameByGUID(getPlayerPartner(thing.uid), false, false) ~= nil) then
            message = message .. " " .. (sex == PLAYERSEX_FEMALE and "She" or "He") .. " is " .. (sex == PLAYERSEX_FEMALE and "wife" or "husband") .. " of " .. getPlayerNameByGUID(getPlayerPartner(thing.uid)) .. "."
        end

        if(getPlayerGuildId(thing.uid) > 0) then
            message = message .. " " .. (sex == PLAYERSEX_FEMALE and "She" or "He") .. " is " .. (getPlayerGuildRank(thing.uid) == "" and "a member" or getPlayerGuildRank(thing.uid)) .. " of the " .. getPlayerGuildName(thing.uid)
            message = getPlayerGuildNick(thing.uid) ~= "" and message .. " (" .. getPlayerGuildNick(thing.uid) .. ")." or message .. "."
        end

        if(getPlayerFlagValue(cid, PLAYERCUSTOMFLAG_CANSEECREATUREDETAILS)) then
            message = message .. "\nHealth: [" .. getCreatureHealth(thing.uid) .. " / " .. getCreatureMaxHealth(thing.uid) .. "], Mana: [" .. getCreatureMana(thing.uid) .. " / " .. getCreatureMaxMana(thing.uid) .. "]." 
        end

        if(getPlayerFlagValue(cid, PLAYERCUSTOMFLAG_CANSEEPOSITION)) then
            message = message .. "\nPosition: [X: " .. position.x .. "] [Y: " .. position.y .. "] [Z: " .. position.z .. "]."
        end

        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, message .. (sex == PLAYERSEX_FEMALE and " \nShe" or " \nHe") .. " has prestiged " .. (getCreatureStorage(thing.uid, 85987) == -1 and "0" or getCreatureStorage(thing.uid, 85987)) .. " " .. (math.abs(getCreatureStorage(thing.uid, 85987)) == 1 and "time." or "times."))
        return false
    elseif thing.uid == cid then
        local message = "You see yourself."
        if(getPlayerFlagValue(cid, PLAYERFLAG_SHOWGROUPINSTEADOFVOCATION)) then
            message = message .. " You are " .. getPlayerGroupName(cid) .. "."
        elseif(getPlayerVocation(cid) ~= 0) then
            message = message .. " You are a " .. getPlayerVocationName(cid):lower() .. "."
        else
            message = message .. " You have no vocation."
        end

        if(getPlayerNameByGUID(getPlayerPartner(cid), false, false) ~= nil) then
            message = message .. " You are " .. (getPlayerSex(cid) == PLAYERSEX_FEMALE and "wife" or "husband") .. " of " .. getPlayerNameByGUID(getPlayerPartner(cid)) .. "."
        end

        if(getPlayerGuildId(cid) > 0) then
            message = message .. " You are " .. (getPlayerGuildRank(cid) == "" and "a member" or getPlayerGuildRank(cid)) .. " of the " .. getPlayerGuildName(cid)
            message = getPlayerGuildNick(cid) ~= "" and message .. " (" .. getPlayerGuildNick(cid) .. ")." or message .. "."
        end

        if(getPlayerFlagValue(cid, PLAYERCUSTOMFLAG_CANSEECREATUREDETAILS)) then
            message = message .. "\nHealth: [" .. getCreatureHealth(cid) .. " / " .. getCreatureMaxHealth(cid) .. "], Mana: [" .. getCreatureMana(cid) .. " / " .. getCreatureMaxMana(cid) .. "]."
        end

        if(getPlayerFlagValue(cid, PLAYERCUSTOMFLAG_CANSEEPOSITION)) then
            message = message .. "\nPosition: [X: " .. position.x .. "] [Y: " .. position.y .. "] [Z: " .. position.z .. "]."
        end

        return false, doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, message .. " \nYou have prestiged " .. (getCreatureStorage(cid, 85987) == -1 and "0" or getCreatureStorage(cid, 85987)) .. " " .. (getCreatureStorage(cid, 85987) == 1 and "time." or "times."))
    end

    return true
end
5-Add the code below to ur creaturescripts.xml
Code:
 <event type="look" name="RebirthDescription" event="script" value="rebirthdescription.lua"/>
6-Lastly just register it in your login.lua located in ur creaturescripts script folder. just add this in on a new line
Code:
registerCreatureEvent(cid, "RebirthDescription")
Hope this helps. Sorry for being gone from this. Any questions let me know.
Tjay
 
Last edited:
OMG!!! :'( Why did he do that :'( :'(
Edit: I hate how i have to pay for everything now, i might quit life omg
 
You can post his rebirth system? Are you sure its his 100%? Or it's another one.. If you got same as his pm me with a yes, I dunno if its illegal but i think its not...
 
Sorry for double post Tjay if it works alright post it here pleaseeee!!
 
its works 100%! Thanks, Do you have some ides to show it in highscore on the website i got Gesior AAC. ?
 
Not sure havent tested it works 100% on 0.3.6 and you can find one else to do that im getting friends to help me with the modern acc script for it. If i get the modern acc ill post but probably wont have gesior. sorry bro.
Tjay
 
mm thanks for this but actually it kinda doesnt work for me :/ i wanted to make rebirth from level 717217 and i dont need to be promoted and also no cost for rebirthing but i ruined the script when i made my edits and now even if i placed the npc on the map he doesnt show up where he should... can u fix me ur script to my likings? id appreciate it very much :)

EDIT : heres my script if u can tell me what i did wrong

Code:
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, 'prestige')) then
		selfSay('Are you ready to prestige and start a new life?', cid)
		talkState[talkUser] = 1
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
		-------CONFIGS-------
		local level = 717217 
		local cost = 0
		------/CONFIGS-------
		-----LOCALS-----
		local id = getPlayerGUID(cid)
		local name = getCreatureName(cid)
		----/LOCALS-----
		if(getPlayerLevel(cid) >= level) then
			if(doPlayerRemoveMoney(cid, cost) == TRUE) then
				if(isInArray({1,2,3,4}, vocation)) then
					doCreatureSetStorage(cid, 85987, storage == -1 and 1 or storage + 1)
					doRemoveCreature(cid)
					db.executeQuery("UPDATE `players` SET `level` = 8, `experience` = 4200, `healthmax` = 2000, `manamax` = 2000, `promotion` = 0 WHERE `id` ='"..id.."';")
					db.executeQuery("UPDATE `players` SET `name` = '"..name.."' WHERE `id` ='"..id.."';")
				else
					selfSay('Please talk with Forgotten King and promote first.', cid)
					talkState[talkUser] = 0
				end
			else
				selfSay('You don't have enough money. You need to pay 10 mil to be rebirthed.', cid)
				talkState[talkUser] = 0
			end
		else
			selfSay('Only characters of level 100000 or higher can be rebirthed.', cid)
			talkState[talkUser] = 0
		end
	elseif(msgcontains(msg, 'no') and talkState[talkUser] == 1) then
		selfSay('Okey. Come back when you feel ready.', cid)
		talkState[talkUser] = 0
	end
 
	return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
Back
Top