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

edit prestige sys

Thorn

Spriting since 2013
Joined
Sep 24, 2012
Messages
2,203
Solutions
1
Reaction score
921
Location
Chile
hii, i have a good working rebirth system that when you reach lvl 400 you can rebirth (400 or more) and get back to lvl 8 with same hp and mana you had before, but i want to change that and make you get back to lvl 8 but not with total mana and health, but with the 50% that you had, is this possible? if any one could help me that would be great :D
here is my script

Lua:
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 = 400
        local cost = 10000
        ------/CONFIGS-------
        -----LOCALS-----
        local id = getPlayerGUID(cid)
        local name = getCreatureName(cid)
        local vocation = getPlayerVocation(cid)
        local storage = getCreatureStorage(cid, 85987)
        ----/LOCALS-----
    if(storage < 100) then
        if(getPlayerLevel(cid) >= level) 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)
                    doRemoveCreature(cid)
                    db.executeQuery("UPDATE `players` SET `level` = 8, `experience` = 4200, `promotion` = 1 WHERE `id` ='"..id.."';")
                    db.executeQuery("UPDATE `players` SET `name` = '"..name.."' WHERE `id` ='"..id.."';")
                else
                    selfSay('Please talk with Promotion Guy 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 400 or higher can be rebirthed.', cid)
            talkState[talkUser] = 0
        end
    else
        selfSay('You have already reached the highest prestige available.', 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())
 
Try this

Lua:
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 = 400
        local cost = 10000
        ------/CONFIGS-------
        -----LOCALS-----
        local id = getPlayerGUID(cid)
        local name = getCreatureName(cid)
        local vocation = getPlayerVocation(cid)
        local storage = getCreatureStorage(cid, 85987)
        ----/LOCALS-----
    if(storage < 100) then
        if(getPlayerLevel(cid) >= level) then
            if(doPlayerRemoveMoney(cid, cost) == TRUE) then
                if(isInArray({5, 6, 7, 8}, vocation)) then
                    doCreatureSetStorage(cid, 85987, math.max(0, storage) + 1)
                    doRemoveCreature(cid)
                    db.executeQuery("UPDATE `players` SET `level` = 8, health = health / 2, healthmax = healthmax / 2, `experience` = 4200, mana = mana / 2, manamax = manamax / 2 WHERE `id` = '"..id.."';")
                else
                    selfSay('Please talk with Promotion Guy 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 400 or higher can be rebirthed.', cid)
            talkState[talkUser] = 0
        end
    else
        selfSay('You have already reached the highest prestige available.', 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())
 
Thanks man it worked just fine! but i'm having this little error :/
XML:
[16/07/2013 18:57:05] [Error - Npc interface] 
[16/07/2013 18:57:05] data/npc/scripts/promotion.lua:onCreatureSay
[16/07/2013 18:57:05] Description: 
[16/07/2013 18:57:05] (luaGetNpcDistanceTo) Thing not found

- - - Updated - - -

and how can i edit the 50%? D: maybe in the future i'd like to change it
 
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local t = {}
 
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
	elseif(msgcontains(msg, 'prestige')) then
        selfSay('Are you ready to prestige and start a new life?', cid)
        t[cid] = 1
    elseif(msgcontains(msg, 'yes') and t[cid] == 1) then
        -------CONFIGS-------
        local level = 400
        local cost = 10000
        ------/CONFIGS-------
        local storage = getCreatureStorage(cid, 85987)
    if(storage < 100) then
        if getPlayerLevel(cid) >= level then
			if getPlayerPromotionLevel(cid) >= 1 then
				if doPlayerRemoveMoney(cid, cost) then
                    doCreatureSetStorage(cid, 85987, math.max(0, storage) + 1)
					local hp, mana = math.floor(getCreatureMaxHealth(cid) / 2), math.floor(getCreatureMaxMana(cid) / 2)
					local q = "UPDATE `players` SET `level` = 8, health = ".. hp ..", healthmax = ".. hp ..", `experience` = 4200, mana = ".. mana ..", manamax = ".. mana .." WHERE `id` = ".. getPlayerGUID(cid)
                    doRemoveCreature(cid)
                    db.executeQuery(q)
				else
					selfSay('You don\'t have enough money. You need to pay 10 mil to be rebirthed.', cid)
					t[cid] = 0
				end
			else
				selfSay('Please talk with Promotion Guy and promote first.', cid)
				t[cid] = 0
			end
        else
            selfSay('Only characters of level 400 or higher can be rebirthed.', cid)
            t[cid] = 0
        end
    else
        selfSay('You have already reached the highest prestige available.', cid)
        t[cid] = 0
    end
    elseif(msgcontains(msg, 'no') and t[cid] == 1) then
        selfSay('Okey. Come back when you feel ready.', cid)
        t[cid] = 0
    end
 
    return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
still having the same error :/ sorry

XML:
[22/07/2013 00:28:10] [Error - Npc interface] 
[22/07/2013 00:28:10] data/npc/scripts/promotion.lua:onCreatureSay
[22/07/2013 00:28:10] Description: 
[22/07/2013 00:28:10] (luaGetNpcDistanceTo) Thing not found
 
That is in a different script. (promotion.lua)
Copy that script here please.

And this is your request about editing the percentage.

Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
 
local t = {}
 
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
	elseif(msgcontains(msg, 'prestige')) then
        selfSay('Are you ready to prestige and start a new life?', cid)
        t[cid] = 1
    elseif(msgcontains(msg, 'yes') and t[cid] == 1) then
        -------CONFIGS-------
        local level = 400
        local cost = 10000
        local hppercent = xx -- change xx to the percent
        local mppercent = xx -- change xx to the percent
        ------/CONFIGS-------
        local storage = getCreatureStorage(cid, 85987)
    if(storage < 100) then
        if getPlayerLevel(cid) >= level then
			if getPlayerPromotionLevel(cid) >= 1 then
				if doPlayerRemoveMoney(cid, cost) then
                    doCreatureSetStorage(cid, 85987, math.max(0, storage) + 1)
					local hp, mana = math.floor((getCreatureMaxHealth(cid)/100)*hppercent), math.floor((getCreatureMaxMana(cid)/100)*mppercent)
					local q = "UPDATE `players` SET `level` = 8, health = ".. hp ..", healthmax = ".. hp ..", `experience` = 4200, mana = ".. mana ..", manamax = ".. mana .." WHERE `id` = ".. getPlayerGUID(cid)
                    doRemoveCreature(cid)
                    db.executeQuery(q)
				else
					selfSay('You don\'t have enough money. You need to pay ".. cost .." gold coins to be rebirthed.', cid)
					t[cid] = 0
				end
			else
				selfSay('Please talk with Promotion Guy and promote first.', cid)
				t[cid] = 0
			end
        else
            selfSay('Only characters of level ".. level .." or higher can be rebirthed.', cid)
            t[cid] = 0
        end
    else
        selfSay('You have already reached the highest prestige available.', cid)
        t[cid] = 0
    end
    elseif(msgcontains(msg, 'no') and t[cid] == 1) then
        selfSay('Okey. Come back when you feel ready.', cid)
        t[cid] = 0
    end
 
    return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Lua:
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 node1 = keywordHandler:addKeyword({'promot'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Yo Puedo Darte La Promotion Por 2cc ¿Quieres Comprar La Promotion?'})
	node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 20000, level = 20, promotion = 1, text = 'Felicitaciones , Tu Ya Eres Promotion.'})
	node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Bien , Entonces Vuelve Cuando Este Listo.', reset = true})


npcHandler:addModule(FocusModule:new())

here is my promotion.lua script, and now i will test the one you give me Zuma master :)

- - - Updated - - -

man i just tested your script and work perfectly! thanks!, and plz if you could help me with that promotion i'd be very grateful :D
 
Last edited:
Back
Top