Jump to content
Sign in to follow this  
Rumor

Block player access to maps based on level

Recommended Posts

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
  • Love 2

Share this post


Link to post

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 2

Share this post


Link to post

Yeah some of my stuff is a little longer than it needs to be, thankyou.

Share this post


Link to post

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

Share this post


Link to post
when login begin
	local tab = {
		 [mapindex] = level,
	}
	if tab[pc.get_map_index()] ~= nil then
		if tab[pc.get_map_index()] > pc.level then
			warp_to_village()
		end
	end
end

Share this post


Link to post

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

Share this post


Link to post
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 ^^

 

 

Share this post


Link to post

Using a timer is a bad idea. With some good timing one can block the quest from actually running by starting another quest and leaving it be on a wait state.

Share this post


Link to post

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.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • 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.