Jump to content

Block player access to maps based on level


Rumor

Recommended Posts

M2 Download Center

This is the hidden content, please
( Internal )

This will teleport a player outside of a map if he enters it and isn't a certain level or higher. Useful for when people try to access higher level maps you don't want them in until later via Couple's Ring or warp scroll. This can't be bypassed, it will always teleport them out of the map as soon as they enter it.
 

quest bayblack begin
	state start begin
		when login with pc.get_map_index() == 194 begin
			if pc.get_level() < 70 then
				warp_to_village()
			end
		end
	end
end

quest capedragon begin
	state start begin
		when login with pc.get_map_index() == 195 begin
			if pc.get_level() < 100 then
				warp_to_village()
			end
		end
	end
end

quest mountthunder begin
	state start begin
		when login with pc.get_map_index() == 197 begin
			if pc.get_level() < 130 then
				warp_to_village()
			end
		end
	end
end
  • Metin2 Dev 3
  • Love 5
Link to comment
Share on other sites

  • Former Staff

You could do it with way less writing:

quest levellimit begin
    state start begin
        when login begin
            maxmapindex = 350
            for i = 0, maxmapindex, 1 do
                maparray[i] = nil
            end
            --maparray[mapindex] = level
            maparray[194] = 70
            maparray[195] = 100
            maparray[197] = 130
            index = pc.get_map_index()
            if maparray[index] ~= nil then
                if pc.get_level() < maparray[index] then
                    warp_to_village()
                end
            end
        end
    end
end
This should work. I cant test it right now
  • Love 3
Link to comment
Share on other sites

  • Developer

Hi

This way should work too:

 

quest levellimit begin
	state start begin
		when login begin
			-- Map Index, minLevel
			maparray = {194, 70, 195, 100, 197, 130}
			for i = 1, table.getn(maparray), 2 do -- table.getn(maparray)= #maparray
				if pc.get_map_index() == maparray[i] and pc.level < maparray[i+1] then
					warp_to_village()
				end
			end
		end
	end
end
  • Love 1

when you return 0 and server doesn't boot:

unknown.png

Link to comment
Share on other sites

Hi

This way should work too:

 

quest levellimit begin
	state start begin
		when login begin
			-- Map Index, minLevel
			maparray = {194, 70, 195, 100, 197, 130}
			for i = 1, table.getn(maparray), 2 do -- table.getn(maparray)= #maparray
				if pc.get_map_index() == maparray[i] and pc.level < maparray[i+1] then
					warp_to_village()
				end
			end
		end
	end
end

Thanks for share Roman, and thanks for other codes.

 

Last quest very modern :P

Link to comment
Share on other sites

  • 4 months later...
quest check_level begin
    state start begin
        function check_level(map,level)
            if pc.get_map_index() == map and pc.get_level() < level then
                return true
            else
                return false
            end
        end
        function kick_out()
            say_title("system:")
            say("this map is not for ur level")
            say("u will kicked out>")
            wait()
            warp_to_village()
        end
        when login with check_level.check_level(21,30) == true begin
            timer("kick_out_timer",1)
        end
        when login with check_level.check_level(2,50) == true begin
            timer("kick_out_timer",1)
        end
        when login with check_level.check_level(3,100) == true begin
            timer("kick_out_timer",1)
        end
        when kick_out_timer.timer begin
            check_level.kick_out()
        end
    end

this for all maps with all levels ^^

 

 

Link to comment
Share on other sites

  • Premium

You could do it with way less writing:

quest levellimit begin
    state start begin
        when login begin
            maxmapindex = 350
            for i = 0, maxmapindex, 1 do
                maparray[i] = nil
            end
            --maparray[mapindex] = level
            maparray[194] = 70
            maparray[195] = 100
            maparray[197] = 130
            index = pc.get_map_index()
            if maparray[index] ~= nil then
                if pc.get_level() < maparray[index] then
                    warp_to_village()
                end
            end
        end
    end
end
This should work. I cant test it right now

 

Why global variables?

 

You have done the best quest here, but i don't see the sense in the global variables.

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

Link to comment
Share on other sites

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.