Jump to content

[HELP] Prestige System by me


Recommended Posts

Hi guys, today i was trying to create a prestige system by myself, but i dont know if the code is right... also i dont know the code for giving 15% piercing and critical hits as you can see commented in the quest... 

Can you guys take a look at this and tell me what you think, and maybe tell me the apply to those 2 bonuses?

 

quest prestige_system begin
	state start begin
		when login with pc.get_level() >= 150 then
			local lvl = mysql_query('SELECT p_lvl FROM account.account WHERE id = '..pc.get_account_id()..' LIMIT 1')
			if lvl < 5 then
				send_letter("Prestige System")
			end
		end
		when button or info begin
			local lvl = mysql_query('SELECT p_lvl FROM account.account WHERE id = '..pc.get_account_id()..' LIMIT 1')
			say_title("Prestige System")
			say()
			say("Once you got to the max level you can")
			say("now level up to a Prestige Rank Level.")
			say()
			say("You will have some bonuses if you are")
			say("at Prestige Rank 1 or more, and the ")
			say("bonus will be different in each rank.")
			say()
			say_reward("You can now rank up to Prestige.")
			local s = select ("More Info" , "Rank up" , "Close")
			if s == 1 then
				say_title("Prestige System")
				say()
				say("The Prestige system have 5 ranks.")
				say("Everytime you rank up one prestige")
				say("level, you get back to level 1 but")
				say("you will have some bonuses.")
				say()
				say("What will I receive?")
				say_reward("Prestige Rank 1 - At level 1 you'll have 20 stat points")
				say_reward("Prestige Rank 2 - You will get Strong vs Monsters 15% permanently")
				say_reward("Prestige Rank 3 - Your Max. HP will increase 3000 (3k)")
				say_reward("Prestige Rank 4 - Your critical and piercing percentage will be 15% more")
				say_reward("Prestige Rank 5 - You'll resist 10% more vs every other character")
				say()
				say()
				say("This system was created by RachadoPT")
			elseif s == 2 then
				say_title("Prestige System")
				say()
				say("Are you sure you want to rank up")
				say("to the next Prestige Level?")
				local s1 = select ("Yes" , "No")
				if s1 == 1 then
					local nlvl = 0
					if lvl == 0 then
						command("a "..pc.get_name.." 1")
						--1st prestige
						mysql_query('UPDATE account.account SET stat_point = 20 WHERE id = '..pc.get_account_id()..' LIMIT 1')
						nlvl = nlvl + 1
						mysql_query('UPDATE account.account SET p_lvl = nlvl WHERE id = '..pc.get_account_id()..' LIMIT 1')
					elseif lvl == 1 then
						command("a "..pc.get_name.." 1")
						--2nd prestige
						affect.add_collect_point(POINT_ATTBONUS_MONSTER,15,60*60*24*365*60)
						nlvl = nlvl + 1
						mysql_query('UPDATE account.account SET p_lvl = nlvl WHERE id = '..pc.get_account_id()..' LIMIT 1') 
					elseif lvl == 2 then
						command("a "..pc.get_name.." 1")
						--3rd prestige
						affect.add_collect(apply.MAX_HP,3000,60*60*24*365*40)
						nlvl = nlvl + 1
						mysql_query('UPDATE account.account SET p_lvl = nlvl WHERE id = '..pc.get_account_id()..' LIMIT 1') 
					elseif lvl == 3 then
						command("a "..pc.get_name.." 1")	
						--4th prestige
						affect.add_collect(apply.CRITICAL_PCT,15,60*60*24*365*40) -- i dont know the right code
						affect.add_collect(apply.PIERCING_PCT,15,60*60*24*365*40) -- for these 2 functions (give 15% more critical and piercing hits)
						nlvl = nlvl + 1
						mysql_query('UPDATE account.account SET p_lvl = nlvl WHERE id = '..pc.get_account_id()..' LIMIT 1')
					elseif lvl == 4 then 
						command("a "..pc.get_name.." 1")
						--5th prestige
						affect.add_collect_point(POINT_RESIST_WARRIOR,10,60*60*24*365*60)
						affect.add_collect_point(POINT_RESIST_ASSASSIN,10,60*60*24*365*60)
						affect.add_collect_point(POINT_RESIST_SURA,10,60*60*24*365*60)
						affect.add_collect_point(POINT_RESIST_SHAMAN,10,60*60*24*365*60)
						nlvl = nlvl + 1
						mysql_query('UPDATE account.account SET p_lvl = nlvl WHERE id = '..pc.get_account_id()..' LIMIT 1')
				else
					return
			elseif s == 3 then
				return
		end
	end
end

 

Greetz, RachadoPT

Link to comment
Share on other sites

You had some mistakes at sql queries but I fix them for you.

quest prestige_system begin
    state start begin
        when login with pc.get_level() >= 150 then
            local lvl = mysql_query('SELECT p_lvl FROM account.account WHERE id = '..pc.get_account_id()..' LIMIT 1')
            if lvl < 5 then
                send_letter("Prestige System")
            end
        end
        when button or info begin
            local lvl = mysql_query('SELECT p_lvl FROM account.account WHERE id = '..pc.get_account_id()..' LIMIT 1')
            say_title("Prestige System")
            say()
            say("Once you got to the max level you can")
            say("now level up to a Prestige Rank Level.")
            say()
            say("You will have some bonuses if you are")
            say("at Prestige Rank 1 or more, and the ")
            say("bonus will be different in each rank.")
            say()
            say_reward("You can now rank up to Prestige.")
            local s = select ("More Info" , "Rank up" , "Close")
            if s == 1 then
                say_title("Prestige System")
                say()
                say("The Prestige system have 5 ranks.")
                say("Everytime you rank up one prestige")
                say("level, you get back to level 1 but")
                say("you will have some bonuses.")
                say()
                say("What will I receive?")
                say_reward("Prestige Rank 1 - At level 1 you'll have 20 stat points")
                say_reward("Prestige Rank 2 - You will get Strong vs Monsters 15% permanently")
                say_reward("Prestige Rank 3 - Your Max. HP will increase 3000 (3k)")
                say_reward("Prestige Rank 4 - Your critical and piercing percentage will be 15% more")
                say_reward("Prestige Rank 5 - You'll resist 10% more vs every other character")
                say()
                say()
                say("This system was created by RachadoPT")
            elseif s == 2 then
                say_title("Prestige System")
                say()
                say("Are you sure you want to rank up")
                say("to the next Prestige Level?")
                local s1 = select ("Yes" , "No")
                if s1 == 1 then
                    local nlvl = 0
                    if lvl == 0 then
                        command("a "..pc.get_name.." 1")
                        --1st prestige
                        nlvl = nlvl + 1
						mysql_query('UPDATE account.account SET stat_point = 20,p_lvl = '..nlvl..' WHERE id = '..pc.get_account_id()..' LIMIT 1')
                    elseif lvl == 1 then
                        command("a "..pc.get_name.." 1")
                        --2nd prestige
                        affect.add_collect_point(POINT_ATTBONUS_MONSTER,15,60*60*24*365*60)
                        nlvl = nlvl + 1
                        mysql_query('UPDATE account.account SET p_lvl = '..nlvl..' WHERE id = '..pc.get_account_id()..' LIMIT 1')
                    elseif lvl == 2 then
                        command("a "..pc.get_name.." 1")
                        --3rd prestige
                        affect.add_collect(apply.MAX_HP,3000,60*60*24*365*40)
                        nlvl = nlvl + 1
                        mysql_query('UPDATE account.account SET p_lvl = '..nlvl..' WHERE id = '..pc.get_account_id()..' LIMIT 1')
                    elseif lvl == 3 then
                        command("a "..pc.get_name.." 1")   
                        --4th prestige
                        affect.add_collect(apply.CRITICAL_PCT,15,60*60*24*365*40) -- i dont know the right code
                        affect.add_collect(apply.PENETRATE_PCT,15,60*60*24*365*40) -- for these 2 functions (give 15% more critical and piercing hits)
                        nlvl = nlvl + 1
                        mysql_query('UPDATE account.account SET p_lvl = '..nlvl..' WHERE id = '..pc.get_account_id()..' LIMIT 1')
                    elseif lvl == 4 then
                        command("a "..pc.get_name.." 1")
                        --5th prestige
                        affect.add_collect_point(POINT_RESIST_WARRIOR,10,60*60*24*365*60)
                        affect.add_collect_point(POINT_RESIST_ASSASSIN,10,60*60*24*365*60)
                        affect.add_collect_point(POINT_RESIST_SURA,10,60*60*24*365*60)
                        affect.add_collect_point(POINT_RESIST_SHAMAN,10,60*60*24*365*60)
                        nlvl = nlvl + 1
                        mysql_query('UPDATE account.account SET p_lvl = '..nlvl..' WHERE id = '..pc.get_account_id()..' LIMIT 1')
                else
                    return
            elseif s == 3 then
                return
        end
    end
end

A little tip: You can find the bonuses id from questlib.lua just search apply = { and you'll see there the whole bonus list

  • Love 1
Link to comment
Share on other sites

You had some mistakes at sql queries but I fix them for you.

quest prestige_system begin
    state start begin
        when login with pc.get_level() >= 150 then
            local lvl = mysql_query('SELECT p_lvl FROM account.account WHERE id = '..pc.get_account_id()..' LIMIT 1')
            if lvl < 5 then
                send_letter("Prestige System")
            end
        end
        when button or info begin
            local lvl = mysql_query('SELECT p_lvl FROM account.account WHERE id = '..pc.get_account_id()..' LIMIT 1')
            say_title("Prestige System")
            say()
            say("Once you got to the max level you can")
            say("now level up to a Prestige Rank Level.")
            say()
            say("You will have some bonuses if you are")
            say("at Prestige Rank 1 or more, and the ")
            say("bonus will be different in each rank.")
            say()
            say_reward("You can now rank up to Prestige.")
            local s = select ("More Info" , "Rank up" , "Close")
            if s == 1 then
                say_title("Prestige System")
                say()
                say("The Prestige system have 5 ranks.")
                say("Everytime you rank up one prestige")
                say("level, you get back to level 1 but")
                say("you will have some bonuses.")
                say()
                say("What will I receive?")
                say_reward("Prestige Rank 1 - At level 1 you'll have 20 stat points")
                say_reward("Prestige Rank 2 - You will get Strong vs Monsters 15% permanently")
                say_reward("Prestige Rank 3 - Your Max. HP will increase 3000 (3k)")
                say_reward("Prestige Rank 4 - Your critical and piercing percentage will be 15% more")
                say_reward("Prestige Rank 5 - You'll resist 10% more vs every other character")
                say()
                say()
                say("This system was created by RachadoPT")
            elseif s == 2 then
                say_title("Prestige System")
                say()
                say("Are you sure you want to rank up")
                say("to the next Prestige Level?")
                local s1 = select ("Yes" , "No")
                if s1 == 1 then
                    local nlvl = 0
                    if lvl == 0 then
                        command("a "..pc.get_name.." 1")
                        --1st prestige
                        nlvl = nlvl + 1
						mysql_query('UPDATE account.account SET stat_point = 20,p_lvl = '..nlvl..' WHERE id = '..pc.get_account_id()..' LIMIT 1')
                    elseif lvl == 1 then
                        command("a "..pc.get_name.." 1")
                        --2nd prestige
                        affect.add_collect_point(POINT_ATTBONUS_MONSTER,15,60*60*24*365*60)
                        nlvl = nlvl + 1
                        mysql_query('UPDATE account.account SET p_lvl = '..nlvl..' WHERE id = '..pc.get_account_id()..' LIMIT 1')
                    elseif lvl == 2 then
                        command("a "..pc.get_name.." 1")
                        --3rd prestige
                        affect.add_collect(apply.MAX_HP,3000,60*60*24*365*40)
                        nlvl = nlvl + 1
                        mysql_query('UPDATE account.account SET p_lvl = '..nlvl..' WHERE id = '..pc.get_account_id()..' LIMIT 1')
                    elseif lvl == 3 then
                        command("a "..pc.get_name.." 1")   
                        --4th prestige
                        affect.add_collect(apply.CRITICAL_PCT,15,60*60*24*365*40) -- i dont know the right code
                        affect.add_collect(apply.PENETRATE_PCT,15,60*60*24*365*40) -- for these 2 functions (give 15% more critical and piercing hits)
                        nlvl = nlvl + 1
                        mysql_query('UPDATE account.account SET p_lvl = '..nlvl..' WHERE id = '..pc.get_account_id()..' LIMIT 1')
                    elseif lvl == 4 then
                        command("a "..pc.get_name.." 1")
                        --5th prestige
                        affect.add_collect_point(POINT_RESIST_WARRIOR,10,60*60*24*365*60)
                        affect.add_collect_point(POINT_RESIST_ASSASSIN,10,60*60*24*365*60)
                        affect.add_collect_point(POINT_RESIST_SURA,10,60*60*24*365*60)
                        affect.add_collect_point(POINT_RESIST_SHAMAN,10,60*60*24*365*60)
                        nlvl = nlvl + 1
                        mysql_query('UPDATE account.account SET p_lvl = '..nlvl..' WHERE id = '..pc.get_account_id()..' LIMIT 1')
                else
                    return
            elseif s == 3 then
                return
        end
    end
end

A little tip: You can find the bonuses id from questlib.lua just search apply = { and you'll see there the whole bonus list

Thank you very much :$ BTW, all the rest of the code is good? I cant test it right now to say if it is working or not ><

 

 

 

 

Link to comment
Share on other sites

 

I think yes I didn't see any syntax errors or something like this,so I guess it should be working fine

Good, I'll try it later then, thank you very much, once again :D

 

Greetz, RachadoPT

 

 

I edited the code a little and it is not working in game... I'm level 150 and there is no letter for me to click >< even with the first version you corrected to me it doesn't work... look at the new code:

 

quest prestige_system begin
    state start begin
        when login with pc.get_level >= 150 begin
			local idc = mysql_query('SELECT id FROM player.player WHERE account_id = '..pc.get_account_id()..' LIMIT 1')
            local lvl = mysql_query('SELECT p_lvl FROM player.player WHERE id = '..idc..' LIMIT 1')
            if lvl < 5 then
                send_letter("Prestige System")
            end
        end
        when button or info begin
            local idc = mysql_query('SELECT id FROM player.player WHERE account_id = '..pc.get_account_id()..' LIMIT 1')
            local lvl = mysql_query('SELECT p_lvl FROM player.player WHERE id = '..idc..' LIMIT 1')
            say_title("Prestige System")
            say()
            say("Once you got to the max level you can")
            say("now level up to a Prestige Rank Level.")
            say()
            say("You will have some bonuses if you are")
            say("at Prestige Rank 1 or more, and the ")
            say("bonus will be different in each rank.")
            say()
            say_reward("You can now rank up to Prestige.")
            local s = select ("More Info" , "Rank up" , "Close")
            if s == 1 then
                say_title("Prestige System")
                say()
                say("The Prestige system have 5 ranks.")
                say("Everytime you rank up one prestige")
                say("level, you get back to level 1 but")
                say("you will have some bonuses.")
                say()
                say("What will I receive?")
                say_reward("Prestige Rank 1 - At level 1 you'll have 20 stat points")
                say_reward("Prestige Rank 2 - You will get Strong vs Monsters 15% permanently")
                say_reward("Prestige Rank 3 - Your Max. HP will increase 3000 (3k)")
                say_reward("Prestige Rank 4 - Your critical and piercing percentage will be 15% more")
                say_reward("Prestige Rank 5 - You'll resist 10% more vs every other character")
                say()
                say()
                say("This system was created by RachadoPT")
            elseif s == 2 then
                say_title("Prestige System")
                say()
                say("Are you sure you want to rank up")
                say("to the next Prestige Level?")
                local s1 = select ("Yes" , "No")
                if s1 == 1 then
                    local nlvl = 0
                    if lvl == 0 then
                        command("a "..pc.get_name.." 1")
                        --1st prestige
                        nlvl = nlvl + 1
                        mysql_query('UPDATE account.account SET stat_point = 20,p_lvl = '..nlvl..' WHERE id = '..pc.get_account_id()..' LIMIT 1')
                        mysql_query('UPDATE player.player SET p_lvl = '..nlvl..' WHERE id = '..pc.get_account_id()..' LIMIT 1')
                    elseif lvl == 1 then
                        command("a "..pc.get_name.." 1")
                        --2nd prestige
                        affect.add_collect_point(POINT_ATTBONUS_MONSTER,15,60*60*24*365*60)
                        nlvl = nlvl + 1
                        mysql_query('UPDATE player.player SET p_lvl = '..nlvl..' WHERE id = '..pc.get_account_id()..' LIMIT 1')
                    elseif lvl == 2 then
                        command("a "..pc.get_name.." 1")
                        --3rd prestige
                        affect.add_collect(apply.MAX_HP,3000,60*60*24*365*40)
                        nlvl = nlvl + 1
                        mysql_query('UPDATE player.player SET p_lvl = '..nlvl..' WHERE id = '..pc.get_account_id()..' LIMIT 1')
                    elseif lvl == 3 then
                        command("a "..pc.get_name.." 1")   
                        --4th prestige
                        affect.add_collect(apply.CRITICAL_PCT,15,60*60*24*365*40) -- i dont know the right code
                        affect.add_collect(apply.PENETRATE_PCT,15,60*60*24*365*40) -- for these 2 functions (give 15% more critical and piercing hits)
                        nlvl = nlvl + 1
                        mysql_query('UPDATE player.player SET p_lvl = '..nlvl..' WHERE id = '..pc.get_account_id()..' LIMIT 1')
                    elseif lvl == 4 then
                        command("a "..pc.get_name.." 1")
                        --5th prestige
                        affect.add_collect_point(POINT_RESIST_WARRIOR,10,60*60*24*365*60)
                        affect.add_collect_point(POINT_RESIST_ASSASSIN,10,60*60*24*365*60)
                        affect.add_collect_point(POINT_RESIST_SURA,10,60*60*24*365*60)
                        affect.add_collect_point(POINT_RESIST_SHAMAN,10,60*60*24*365*60)
                        nlvl = nlvl + 1
                        mysql_query('UPDATE player.player SET p_lvl = '..nlvl..' WHERE id = '..pc.get_account_id()..' LIMIT 1')
                    end
                else
                    return
                end
            elseif s == 3 then
                return
			end
        end
    end
end

 

What is the problem? :/

Link to comment
Share on other sites

@RachadoPT Sorry , I was on mobile and I wasn't paying attention

 

Post channel syserr here

I was lookin in the channel syserr and i saw something of that quest, and i resolved it but now i have a new problem in the syserr ><

 

syserr:

SYSERR: Nov  1 16:11:23 :: RunState: LUA_ERROR: [string "prestige_system"]:3: attempt to call global `mysql_query' (a nil value) WITH ERRORCODE 1
SYSERR: Nov  1 16:11:23 :: RunState: LUA_STATE: index 0 ref 3
SYSERR: Nov  1 16:11:23 :: WriteRunningStateToSyserr: LUA_ERROR: quest prestige_system.start click
SYSERR: Nov  1 16:14:23 :: Analyze: login phase does not handle this packet! header 3
SYSERR: Nov  1 16:14:23 :: Process: UNKNOWN HEADER: 227, LAST HEADER: 3(5), REMAIN BYTES: 3, fd: 18 

 

All the rest of the syserr is related to maps and motions.

 

The new system code:

quest prestige_system begin
    state start begin
        when login begin
            local n = pc.get_level()
            if n >= 150 then
                local idc = mysql_query('SELECT id FROM player.player WHERE account_id = '..pc.get_account_id()..' LIMIT 1')
                local lvl = mysql_query('SELECT p_lvl FROM player.player WHERE id = '..idc..' LIMIT 1')
                if lvl < 5 then
                    send_letter("Prestige System")
                end
            end
        end
        when button or info begin
            local idc = mysql_query('SELECT id FROM player.player WHERE account_id = '..pc.get_account_id()..' LIMIT 1')
            local lvl = mysql_query('SELECT p_lvl FROM player.player WHERE id = '..idc..' LIMIT 1')
            say_title("Prestige System")
            say()
            say("Once you got to the max level you can")
            say("now level up to a Prestige Rank Level.")
            say()
            say("You will have some bonuses if you are")
            say("at Prestige Rank 1 or more, and the ")
            say("bonus will be different in each rank.")
            say()
            say_reward("You can now rank up to Prestige.")
            local s = select ("More Info" , "Rank up" , "Close")
            if s == 1 then
                say_title("Prestige System")
                say()
                say("The Prestige system have 5 ranks.")
                say("Everytime you rank up one prestige")
                say("level, you get back to level 1 but")
                say("you will have some bonuses.")
                say()
                say("What will I receive?")
                say_reward("Prestige Rank 1 - At level 1 you'll have 20 stat points")
                say_reward("Prestige Rank 2 - You will get Strong vs Monsters 15% permanently")
                say_reward("Prestige Rank 3 - Your Max. HP will increase 3000 (3k)")
                say_reward("Prestige Rank 4 - Your critical and piercing percentage will be 15% more")
                say_reward("Prestige Rank 5 - You'll resist 10% more vs every other character")
                say()
                say()
                say("This system was created by RachadoPT")
            elseif s == 2 then
                say_title("Prestige System")
                say()
                say("Are you sure you want to rank up")
                say("to the next Prestige Level?")
                local s1 = select ("Yes" , "No")
                if s1 == 1 then
                    local nlvl = 0
                    if lvl == 0 then
                        command("a "..pc.get_name.." 1")
                        --1st prestige
                        nlvl = nlvl + 1
                        mysql_query('UPDATE account.account SET stat_point = 20,p_lvl = '..nlvl..' WHERE id = '..pc.get_account_id()..' LIMIT 1')
                        mysql_query('UPDATE player.player SET p_lvl = '..nlvl..' WHERE id = '..pc.get_account_id()..' LIMIT 1')
                    elseif lvl == 1 then
                        command("a "..pc.get_name.." 1")
                        --2nd prestige
                        affect.add_collect_point(POINT_ATTBONUS_MONSTER,15,60*60*24*365*60)
                        nlvl = nlvl + 1
                        mysql_query('UPDATE player.player SET p_lvl = '..nlvl..' WHERE id = '..pc.get_account_id()..' LIMIT 1')
                    elseif lvl == 2 then
                        command("a "..pc.get_name.." 1")
                        --3rd prestige
                        affect.add_collect(apply.MAX_HP,3000,60*60*24*365*40)
                        nlvl = nlvl + 1
                        mysql_query('UPDATE player.player SET p_lvl = '..nlvl..' WHERE id = '..pc.get_account_id()..' LIMIT 1')
                    elseif lvl == 3 then
                        command("a "..pc.get_name.." 1")   
                        --4th prestige
                        affect.add_collect(apply.CRITICAL_PCT,15,60*60*24*365*40) -- i dont know the right code
                        affect.add_collect(apply.PENETRATE_PCT,15,60*60*24*365*40) -- for these 2 functions (give 15% more critical and piercing hits)
                        nlvl = nlvl + 1
                        mysql_query('UPDATE player.player SET p_lvl = '..nlvl..' WHERE id = '..pc.get_account_id()..' LIMIT 1')
                    elseif lvl == 4 then
                        command("a "..pc.get_name.." 1")
                        --5th prestige
                        affect.add_collect_point(POINT_RESIST_WARRIOR,10,60*60*24*365*60)
                        affect.add_collect_point(POINT_RESIST_ASSASSIN,10,60*60*24*365*60)
                        affect.add_collect_point(POINT_RESIST_SURA,10,60*60*24*365*60)
                        affect.add_collect_point(POINT_RESIST_SHAMAN,10,60*60*24*365*60)
                        nlvl = nlvl + 1
                        mysql_query('UPDATE player.player SET p_lvl = '..nlvl..' WHERE id = '..pc.get_account_id()..' LIMIT 1')
                    end
                else
                    return
                end
            elseif s == 3 then
                return
            end
        end
    end
end 

Link to comment
Share on other sites

Seems like you don't have the mysql query function ... Try to add those to questlib.lua

function split(str, delim, maxNb)
    if str == nil then return str end
    if string.find(str, delim) == nil then return { str } end
    if maxNb == nil or maxNb < 1 then maxNb = 0 end
    local result = {}
    local pat = "(.-)" .. delim .. "()"
    local nb = 0
    local lastPos
    for part, pos in string.gfind(str, pat) do
        nb = nb + 1
        result[nb] = part
        lastPos = pos
        if nb == maxNb then break end
    end
    if nb ~= maxNb then result[nb + 1] = string.sub(str, lastPos) end
    return result
end

mysql_query = function(query)
    if not pre then
        local rt = io.open('CONFIG','r'):read('*all')
        pre,_= string.gsub(rt,'.+PLAYER_SQL:%s(%S+)%s(%S+)%s(%S+)%s(%S+).+','-h%1 -u%2 -p%3 -D%4')
    end
    math.randomseed(os.time())
    local fi,t,out = 'mysql_data_'..math.random(10^9)+math.random(2^4,2^10),{},{}
    --os.execute('mysql '..pre..' --e='..string.format('%q',query)..' > '..fi) -- für MySQL51
    os.execute('mysql '..pre..' -e'..string.format('%q',query)..' > '..fi) -- für MySQL55
    for av in io.open(fi,'r'):lines() do table.insert(t,split(av,'t')) end; os.remove(fi);
    for i = 2, table.getn(t) do table.foreach(t[i],function(a,
        out[i-1]               = out[i-1] or {}
        out[i-1][a]            = tonumber( or b or 'NULL'
        out[t[1][a]]           = out[t[1][a]] or {}
        out[t[1][a]][i-1]      = tonumber( or b or 'NULL'
    end) end
    return out
end
  • Love 1
Link to comment
Share on other sites

 

Seems like you don't have the mysql query function ... Try to add those to questlib.lua

function split(str, delim, maxNb)
    if str == nil then return str end
    if string.find(str, delim) == nil then return { str } end
    if maxNb == nil or maxNb < 1 then maxNb = 0 end
    local result = {}
    local pat = "(.-)" .. delim .. "()"
    local nb = 0
    local lastPos
    for part, pos in string.gfind(str, pat) do
        nb = nb + 1
        result[nb] = part
        lastPos = pos
        if nb == maxNb then break end
    end
    if nb ~= maxNb then result[nb + 1] = string.sub(str, lastPos) end
    return result
end

mysql_query = function(query)
    if not pre then
        local rt = io.open('CONFIG','r'):read('*all')
        pre,_= string.gsub(rt,'.+PLAYER_SQL:%s(%S+)%s(%S+)%s(%S+)%s(%S+).+','-h%1 -u%2 -p%3 -D%4')
    end
    math.randomseed(os.time())
    local fi,t,out = 'mysql_data_'..math.random(10^9)+math.random(2^4,2^10),{},{}
    --os.execute('mysql '..pre..' --e='..string.format('%q',query)..' > '..fi) -- für MySQL51
    os.execute('mysql '..pre..' -e'..string.format('%q',query)..' > '..fi) -- für MySQL55
    for av in io.open(fi,'r'):lines() do table.insert(t,split(av,'t')) end; os.remove(fi);
    for i = 2, table.getn(t) do table.foreach(t[i],function(a,
        out[i-1]               = out[i-1] or {}
        out[i-1][a]            = tonumber( or b or 'NULL'
        out[t[1][a]]           = out[t[1][a]] or {}
        out[t[1][a]][i-1]      = tonumber( or b or 'NULL'
    end) end
    return out
end

Good, it solved the other problem :D

 

Now the problem is this:

SYSERR: Nov  1 16:51:41 :: RunState: LUA_ERROR: [string "prestige_system"]:4: attempt to concatenate local `idc' (a table value) WITH ERRORCODE 1
SYSERR: Nov  1 16:51:41 :: RunState: LUA_STATE: index 0 ref 3
SYSERR: Nov  1 16:51:41 :: WriteRunningStateToSyserr: LUA_ERROR: quest prestige_system.start click
Link to comment
Share on other sites

qf - Quest Flag

io - input/output (files saved in your filesystem)

 

command("a "..pc.get_name.." 1")
 

seriously guy? This command is only for gm use. i don't judge you but use some of your brain. better is to add new function - for example pc.set_level(level)...

 

Actually i though about this command, but i didn't know how to do the level reset part, so i did it like that, also i dont know how to create new funcions and i dont know how to use these gf and io too, as i said, i'm a complete noob in questing or even lua programming. All i know about this is what i saw in other quests or tutorials in the internet ><

Link to comment
Share on other sites

  • Premium

You can use quest flag by using pc.getqf("flag") for get value and pc.setqf("flag", value) to set value. It's basics. I know you would to use new table in mysql but in most cases it doesn't nessesary. Try to recode that.

Honestly i do smillar system before. check my old quest for that. It's nasty coded but work ^^

------------------------------------
--- Reborn System By Zonni @2014 ---
------------------------------------

define max_reborn_level 8

quest reborn_system begin
	state start begin
		function give_bonus(id)
			if id == 1 then
				affect.add_collect(apply.MAX_HP, 2000, 60*60*24*365*60)
			elseif id == 2 then
				affect.add_collect(apply.MAX_HP, 2000, 60*60*24*365*60)
			elseif id == 3 then
				affect.add_collect(apply.MAX_HP, 2000, 60*60*24*365*60)
			elseif id == 4 then
				affect.add_collect(apply.MAX_HP, 2000, 60*60*24*365*60)
			elseif id == 5 then
				affect.add_collect(apply.MAX_HP, 2000, 60*60*24*365*60)
			elseif id == 6 then
				affect.add_collect(apply.MAX_HP, 2000, 60*60*24*365*60)
			elseif id == 7 then
				affect.add_collect(apply.MAX_HP, 2000, 60*60*24*365*60)
			elseif id == 8 then
				affect.add_collect(apply.MAX_HP, 2000, 60*60*24*365*60)
			end
		end
		
		when login or levelup with pc.get_level() >= 105 and is_test_server() and game.get_event_flag("reborn_system_active") = 1 begin
			local reborn_level = pc.get_reborn_level()
			--syschat("Test - reborn level: "..reborn_level..".")
			if reborn_level < max_reborn_level then
				if reborn_level == 0 then
					send_letter("~Reborn character")
				else
					send_letter("~Reborn character - Level "..reborn_level)
				end
			end
		end
		
		when button or info begin
			say_title("Reborn system:")
			----"123456789012345678901234567890123456789012345678901234567890"|
			say("If you reborn your character you will")
			say("recive extra bonuses:")
			say("+2000 HP")
			say("Your level willl be decreased to one.")
			say("")
			wait()
			local reborn_level = pc.get_reborn_level()
			if reborn_level == 0 then
				say("Do you really want to reset your level to one")
				say("and recive this special bonuses?")
				local s = select("Yes", "No")
				if s == 2 then
					return
				elseif s == 1 then
					pc.set_level(1)
					pc.give_exp2(-pc.get_exp())
					pc.set_reborn_level(1)
					reborn_system.give_bonus(1)
					say_title("Reborn System:")
					say("Your character have now 1 reborn level. Take off your equipement")
					say("and put into storage. After relog your eq will automaticly")
					say("take off from you.")
					say("You recive super bonuses!")
					say("")
					clear_letter()
				end
			elseif reborn_level == 1 then
				say("Do you really want to reset your level to one")
				say("and recive this special bonuses?")
				local s = select("Yes", "No")
				if s == 2 then
					return
				elseif s == 1 then
					pc.set_level(1)
					pc.give_exp2(-pc.get_exp())
					pc.set_reborn_level(2)
					reborn_system.give_bonus(2)
					say_title("Reborn System:")
					say("Your character have now 2 reborn level. Take off your equipement")
					say("and put into storage. After relog your eq will automaticly")
					say("take off from you.")
					say("You recive super bonuses!")
					say("")
					clear_letter()
				end
			elseif reborn_level == 2 then
				say("Do you really want to reset your level to one")
				say("and recive this special bonuses?")
				local s = select("Yes", "No")
				if s == 2 then
					return
				elseif s == 1 then
					pc.set_level(1)
					pc.give_exp2(-pc.get_exp())
					pc.set_reborn_level(3)
					reborn_system.give_bonus(3)
					say_title("Reborn System:")
					say("Your character have now 3 reborn level. Take off your equipement")
					say("and put into storage. After relog your eq will automaticly")
					say("take off from you.")
					say("You recive super bonuses!")
					say("")
					clear_letter()
				end
			elseif reborn_level == 3 then
				say("Do you really want to reset your level to one")
				say("and recive this special bonuses?")
				local s = select("Yes", "No")
				if s == 2 then
					return
				elseif s == 1 then
					pc.set_level(1)
					pc.give_exp2(-pc.get_exp())
					pc.set_reborn_level(4)
					reborn_system.give_bonus(4)
					say_title("Reborn System:")
					say("Your character have now 4 reborn level. Take off your equipement")
					say("and put into storage. After relog your eq will automaticly")
					say("take off from you.")
					say("You recive super bonuses!")
					say("")
					clear_letter()
				end
			elseif reborn_level == 4 then
				say("Do you really want to reset your level to one")
				say("and recive this special bonuses?")
				local s = select("Yes", "No")
				if s == 2 then
					return
				elseif s == 1 then
					pc.set_level(1)
					pc.give_exp2(-pc.get_exp())
					pc.set_reborn_level(5)
					reborn_system.give_bonus(5)
					say_title("Reborn System:")
					say("Your character have now 5 reborn level. Take off your equipement")
					say("and put into storage. After relog your eq will automaticly")
					say("take off from you.")
					say("You recive super bonuses!")
					say("")
					clear_letter()
				end
			elseif reborn_level == 5 then
				say("Do you really want to reset your level to one")
				say("and recive this special bonuses?")
				local s = select("Yes", "No")
				if s == 2 then
					return
				elseif s == 1 then
					pc.set_level(1)
					pc.give_exp2(-pc.get_exp())
					pc.set_reborn_level(6)
					reborn_system.give_bonus(6)
					say_title("Reborn System:")
					say("Your character have now 6 reborn level. Take off your equipement")
					say("and put into storage. After relog your eq will automaticly")
					say("take off from you.")
					say("You recive super bonuses!")
					say("")
					clear_letter()
				end
			elseif reborn_level == 6 then
				say("Do you really want to reset your level to one")
				say("and recive this special bonuses?")
				local s = select("Yes", "No")
				if s == 2 then
					return
				elseif s == 1 then
					pc.set_level(1)
					pc.give_exp2(-pc.get_exp())
					pc.set_reborn_level(7)
					reborn_system.give_bonus(7)
					say_title("Reborn System:")
					say("Your character have now 7 reborn level. Take off your equipement")
					say("and put into storage. After relog your eq will automaticly")
					say("take off from you.")
					say("You recive super bonuses!")
					say("")
					clear_letter()
				end
			elseif reborn_level == 7 then
				say("Do you really want to reset your level to one")
				say("and recive this special bonuses?")
				local s = select("Yes", "No")
				if s == 2 then
					return
				elseif s == 1 then
					pc.set_level(1)
					pc.give_exp2(-pc.get_exp())
					pc.set_reborn_level(8)
					reborn_system.give_bonus(8)
					say_title("Reborn System:")
					say("Your character have now 8 reborn level. Take off your equipement")
					say("and put into storage. After relog your eq will automaticly")
					say("take off from you.")
					say("You recive super bonuses!")
					say("")
					clear_letter()
				end
			end
		end
	end
end
NeWfd.jpg

Edited by Metin2 Dev
Core X - External 2 Internal
Link to comment
Share on other sites

You can use quest flag by using pc.getqf("flag") for get value and pc.setqf("flag", value) to set value. It's basics. I know you would to use new table in mysql but in most cases it doesn't nessesary. Try to recode that.

Honestly i do smillar system before. check my old quest for that. It's nasty coded but work ^^

------------------------------------
--- Reborn System By Zonni @2014 ---
------------------------------------

define max_reborn_level 8

quest reborn_system begin
	state start begin
		function give_bonus(id)
			if id == 1 then
				affect.add_collect(apply.MAX_HP, 2000, 60*60*24*365*60)
			elseif id == 2 then
				affect.add_collect(apply.MAX_HP, 2000, 60*60*24*365*60)
			elseif id == 3 then
				affect.add_collect(apply.MAX_HP, 2000, 60*60*24*365*60)
			elseif id == 4 then
				affect.add_collect(apply.MAX_HP, 2000, 60*60*24*365*60)
			elseif id == 5 then
				affect.add_collect(apply.MAX_HP, 2000, 60*60*24*365*60)
			elseif id == 6 then
				affect.add_collect(apply.MAX_HP, 2000, 60*60*24*365*60)
			elseif id == 7 then
				affect.add_collect(apply.MAX_HP, 2000, 60*60*24*365*60)
			elseif id == 8 then
				affect.add_collect(apply.MAX_HP, 2000, 60*60*24*365*60)
			end
		end
		
		when login or levelup with pc.get_level() >= 105 and is_test_server() and game.get_event_flag("reborn_system_active") = 1 begin
			local reborn_level = pc.get_reborn_level()
			--syschat("Test - reborn level: "..reborn_level..".")
			if reborn_level < max_reborn_level then
				if reborn_level == 0 then
					send_letter("~Reborn character")
				else
					send_letter("~Reborn character - Level "..reborn_level)
				end
			end
		end
		
		when button or info begin
			say_title("Reborn system:")
			----"123456789012345678901234567890123456789012345678901234567890"|
			say("If you reborn your character you will")
			say("recive extra bonuses:")
			say("+2000 HP")
			say("Your level willl be decreased to one.")
			say("")
			wait()
			local reborn_level = pc.get_reborn_level()
			if reborn_level == 0 then
				say("Do you really want to reset your level to one")
				say("and recive this special bonuses?")
				local s = select("Yes", "No")
				if s == 2 then
					return
				elseif s == 1 then
					pc.set_level(1)
					pc.give_exp2(-pc.get_exp())
					pc.set_reborn_level(1)
					reborn_system.give_bonus(1)
					say_title("Reborn System:")
					say("Your character have now 1 reborn level. Take off your equipement")
					say("and put into storage. After relog your eq will automaticly")
					say("take off from you.")
					say("You recive super bonuses!")
					say("")
					clear_letter()
				end
			elseif reborn_level == 1 then
				say("Do you really want to reset your level to one")
				say("and recive this special bonuses?")
				local s = select("Yes", "No")
				if s == 2 then
					return
				elseif s == 1 then
					pc.set_level(1)
					pc.give_exp2(-pc.get_exp())
					pc.set_reborn_level(2)
					reborn_system.give_bonus(2)
					say_title("Reborn System:")
					say("Your character have now 2 reborn level. Take off your equipement")
					say("and put into storage. After relog your eq will automaticly")
					say("take off from you.")
					say("You recive super bonuses!")
					say("")
					clear_letter()
				end
			elseif reborn_level == 2 then
				say("Do you really want to reset your level to one")
				say("and recive this special bonuses?")
				local s = select("Yes", "No")
				if s == 2 then
					return
				elseif s == 1 then
					pc.set_level(1)
					pc.give_exp2(-pc.get_exp())
					pc.set_reborn_level(3)
					reborn_system.give_bonus(3)
					say_title("Reborn System:")
					say("Your character have now 3 reborn level. Take off your equipement")
					say("and put into storage. After relog your eq will automaticly")
					say("take off from you.")
					say("You recive super bonuses!")
					say("")
					clear_letter()
				end
			elseif reborn_level == 3 then
				say("Do you really want to reset your level to one")
				say("and recive this special bonuses?")
				local s = select("Yes", "No")
				if s == 2 then
					return
				elseif s == 1 then
					pc.set_level(1)
					pc.give_exp2(-pc.get_exp())
					pc.set_reborn_level(4)
					reborn_system.give_bonus(4)
					say_title("Reborn System:")
					say("Your character have now 4 reborn level. Take off your equipement")
					say("and put into storage. After relog your eq will automaticly")
					say("take off from you.")
					say("You recive super bonuses!")
					say("")
					clear_letter()
				end
			elseif reborn_level == 4 then
				say("Do you really want to reset your level to one")
				say("and recive this special bonuses?")
				local s = select("Yes", "No")
				if s == 2 then
					return
				elseif s == 1 then
					pc.set_level(1)
					pc.give_exp2(-pc.get_exp())
					pc.set_reborn_level(5)
					reborn_system.give_bonus(5)
					say_title("Reborn System:")
					say("Your character have now 5 reborn level. Take off your equipement")
					say("and put into storage. After relog your eq will automaticly")
					say("take off from you.")
					say("You recive super bonuses!")
					say("")
					clear_letter()
				end
			elseif reborn_level == 5 then
				say("Do you really want to reset your level to one")
				say("and recive this special bonuses?")
				local s = select("Yes", "No")
				if s == 2 then
					return
				elseif s == 1 then
					pc.set_level(1)
					pc.give_exp2(-pc.get_exp())
					pc.set_reborn_level(6)
					reborn_system.give_bonus(6)
					say_title("Reborn System:")
					say("Your character have now 6 reborn level. Take off your equipement")
					say("and put into storage. After relog your eq will automaticly")
					say("take off from you.")
					say("You recive super bonuses!")
					say("")
					clear_letter()
				end
			elseif reborn_level == 6 then
				say("Do you really want to reset your level to one")
				say("and recive this special bonuses?")
				local s = select("Yes", "No")
				if s == 2 then
					return
				elseif s == 1 then
					pc.set_level(1)
					pc.give_exp2(-pc.get_exp())
					pc.set_reborn_level(7)
					reborn_system.give_bonus(7)
					say_title("Reborn System:")
					say("Your character have now 7 reborn level. Take off your equipement")
					say("and put into storage. After relog your eq will automaticly")
					say("take off from you.")
					say("You recive super bonuses!")
					say("")
					clear_letter()
				end
			elseif reborn_level == 7 then
				say("Do you really want to reset your level to one")
				say("and recive this special bonuses?")
				local s = select("Yes", "No")
				if s == 2 then
					return
				elseif s == 1 then
					pc.set_level(1)
					pc.give_exp2(-pc.get_exp())
					pc.set_reborn_level(8)
					reborn_system.give_bonus(8)
					say_title("Reborn System:")
					say("Your character have now 8 reborn level. Take off your equipement")
					say("and put into storage. After relog your eq will automaticly")
					say("take off from you.")
					say("You recive super bonuses!")
					say("")
					clear_letter()
				end
			end
		end
	end
end
NeWfd.jpg

 

For that quest you need to create new functions right? like pc.get_reborn_level(), i dont know exactly how to create new funtions ><

Edited by Metin2 Dev
Core X - External 2 Internal
Link to comment
Share on other sites

u cant do the "command" if the player no is GM, then how say zonni, u need create a new function to edit the level of the player.

 

pc.setqf("name", value) <--- set the value

 

pc.getqf("name") <--- return the value

 

example:

 

pc.setqf("test", 1) --- set test in 1

 

if pc.getqf("test") == 1 then
say"1"

elseif pc.getqf("test") == 2 then

say"2"

end

 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.