Quests & Event Resources
Metin2 pc.is_safezone(): C++ safe-zone check exposed to Lua quests
M2City Quests · Editorial · Published 2026-11-04 · Branch-specific details should be checked against your own source.
A custom quest may need to refuse an action while a player is inside a protected town area. This small server integration exposes CHARACTER::IsSafeZone() to Lua as pc.is_safezone(), instead of reproducing map-index lists in every quest. The included README credits EREMIT STUDIO; this is the owner's supplied copy, not a newly verified upstream release.
What is actually in the ZIP
Eight files cover common/service.h, the CHARACTER declaration/implementation, the questlua_pc.cpp binding, the quest function allow-list, and C++/Lua examples. ENABLE_IS_SAFEZONE_FUNCTION gates the additions. The implementation returns true when there is no sectree or the current position has ATTR_BANPK; otherwise it returns false. That no-sectree behaviour is part of this copy and should be considered when calling it outside normal player movement.
Installation checks for your branch
1. Merge the declaration and definition into char.h/char.cpp and enable the macro in the shared server configuration header used by your build.
2. Register the Lua function in RegisterPCFunctionTable and add pc.is_safezone to your quest compiler's permitted function list. Rebuild game and compile only the disposable example quest first.
3. Call the binding in a player quest context with a valid current character. The supplied binding assumes GetCurrentCharacterPtr() returns a character; review this assumption before adapting it to server timers or non-player callbacks.
4. The example uses item 70021. Choose a test-only item/quest trigger in your environment; do not overwrite an existing production item handler.
Expected result and limits
On a staging server, use the example once in an ATTR_BANPK town tile and once outside it. Confirm the Lua boolean changes at the attribute boundary. Cross-check the result against your actual PvP/combat rules: a safe-zone attribute check is not a complete damage authorization policy. Preserve existing server-side attack checks.
Review result
The original archive is unchanged. Archive integrity, checksum and the supplied instruction fragments were inspected. No exact source branch, full build or in-game result is claimed, and no speculative patch was applied.
Editorial resource — M2City
Version: Supplied EREMIT STUDIO integration; no upstream release tag or exact server branch included
Rights: Public redistribution confirmed by the supplying owner. Original author notices retained; no new open-source licence granted.
Validation: ZIP CRC, SHA-256 and all eight member paths checked; supplied C++/Lua instruction fragments reviewed. No full game compilation or live quest test.
Source: Owner-supplied archive record
SHA-256: 5e38c3da29dd115ea5b4f341cc09c63d562531cb0391d1a523d625c6bd429170
Download package
3 download options · Sign in to download
metin2-safezone-quest-function.zipM2City downloadmetin2-safezone-quest-function.zipGoogle Drive mirrormetin2-safezone-quest-function.zipMEGA mirrorMAKE THE NEXT ANSWER BETTER
What happened on your build?
Share a small example, the exact error and how you verified your fix. The discussion is open on the forum.
Need a scoped quest, UI or proto fix? · Explore more development guides · Check your proto files free