Quests /Python Map protect based on player level

Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

[RaffaeL]

Active member
Joined
Apr 12, 2019
Messages
106
Credits
6
I've writed this some time ago, and I'll post here, maybe someone need it.

code_language.lua:
Expand Collapse Copy
--------------------------------------------------------
--          Simple Quest Check level_in_map           --
--              [RaffaeL] - 29.05.2019                --
--------------------------------------------------------
quest map_protect begin
    state start begin
        when login or enter begin
        local check_time = 5
            loop_timer("PROT_CHECK", check_time)
            map_protect.MapProtectCheck()
        end

        when PROT_CHECK.timer begin
            map_protect.MapProtectCheck()
        end

        function MapProtectCheck()
            local map_settings = {
                {0, 0, 0}, -- {map_index, minimum admited level, maximum admited level}
            }

            for m = 1, table.getn(map_settings), 1 do
                local midx = map_settings[m][1]
                local lvlmin = map_settings[m][2]
                local lvlmax = map_settings[m][3]
                local nowlvl = pc.get_level()
                if (pc.get_map_index() == midx) then
                    if nowlvl < lvlmin or nowlvl > lvlmax then
                        chat("Your level doesn't allow you to be here!")
                        chat("You will be teleported to the first map of your kingdom.")
                    warp_to_village()
                    return
                    end
                end
            end
        end
    end
end
 
This quest is make the server slower (too much querry) if you have 200+ players, u will have a little lag from the loop.

I understand what you mean, but that loop doesn't slow down your server(the check are only processing data on login or teleport, also being seen as login). On the other hand, being written on request, this quest was tested on a server with 200+ players, without any issue.
 
Back
Top