From 4b1e21eaaadca7dc8869ad543ab4cb1cc242fb89 Mon Sep 17 00:00:00 2001 From: gumi Date: Fri, 21 Jul 2017 16:16:00 -0400 Subject: refine permissions for custom commands --- npc/commands/event.txt | 7 ++++++- npc/commands/motd.txt | 7 ++++++- npc/commands/music.txt | 12 ++++++------ npc/commands/rate-management.txt | 2 +- npc/commands/scheduled-broadcasts.txt | 7 ++++++- npc/commands/zeny.txt | 6 +++--- npc/functions/permissions.txt | 23 ++++++++++++++--------- 7 files changed, 42 insertions(+), 22 deletions(-) diff --git a/npc/commands/event.txt b/npc/commands/event.txt index 3253702a..db98bcf2 100644 --- a/npc/commands/event.txt +++ b/npc/commands/event.txt @@ -43,10 +43,15 @@ function script GlobalEventMenu { end; OnCall: + if (!is_evtc()) + { + end; + } + GlobalEventMenu; closedialog; end; OnInit: - bindatcmd "event", "@event::OnCall", 4, 99, 0; + bindatcmd "event", "@event::OnCall", 0, 99, 0; } diff --git a/npc/commands/motd.txt b/npc/commands/motd.txt index 0e2f5134..9a9c702e 100644 --- a/npc/commands/motd.txt +++ b/npc/commands/motd.txt @@ -165,6 +165,11 @@ function script MOTDConfig { end; OnCall: + if (!is_dev()) + { + end; + } + MOTDConfig; closedialog; end; @@ -184,5 +189,5 @@ OnInit: MOTD_debug_text; .size = getarraysize($MOTD_Messages$); .dsize = getarraysize($@Debug_Messages$); - bindatcmd "motd", "@motd::OnCall", 3, 99, 0; + bindatcmd "motd", "@motd::OnCall", 0, 99, 0; } diff --git a/npc/commands/music.txt b/npc/commands/music.txt index 3f001919..e794060f 100644 --- a/npc/commands/music.txt +++ b/npc/commands/music.txt @@ -15,6 +15,11 @@ end; OnCall: + if (!is_evtc()) + { + end; + } + // TODO: tmw-like argv splitter getmapxy .@map$, .@void, .@void, UNITTYPE_PC; // get map @@ -30,12 +35,7 @@ OnCall: end; OnInit: - if (.hash) - { - htdelete(.hash); // delete it on Live-Reload (@reloadscripts) - } - - bindatcmd "music", "@music::OnCall", 2, 99, 1; + bindatcmd "music", "@music::OnCall", 0, 99, 1; .hash = htnew; // create hashtable htput(.hash, "forest", "bartk - in the forest of the birches"); diff --git a/npc/commands/rate-management.txt b/npc/commands/rate-management.txt index 8f9909e1..995ef940 100644 --- a/npc/commands/rate-management.txt +++ b/npc/commands/rate-management.txt @@ -92,7 +92,7 @@ OnPCLoginEvent: end; OnInit: - bindatcmd "exprate", "@exprate::OnCall", 3, 99, 1; // change exp rate + bindatcmd "exprate", "@exprate::OnCall", 0, 99, 1; // change exp rate // WARNING: using @reloadscript will change the "original" value .original_exp_rate = getbattleflag("base_exp_rate"); diff --git a/npc/commands/scheduled-broadcasts.txt b/npc/commands/scheduled-broadcasts.txt index 17503738..6bfbf293 100644 --- a/npc/commands/scheduled-broadcasts.txt +++ b/npc/commands/scheduled-broadcasts.txt @@ -204,6 +204,11 @@ OnTimer3600000: end; OnCall: + if (!is_evtc() && !is_dev()) + { + end; + } + StoneBoard; closedialog; end; @@ -216,5 +221,5 @@ OnPCLoginEvent: end; OnInit: - bindatcmd "sched", "@sched::OnCall", 3, 99, 0; + bindatcmd "sched", "@sched::OnCall", 0, 99, 0; } diff --git a/npc/commands/zeny.txt b/npc/commands/zeny.txt index 3dd9b4c3..77f6d2de 100644 --- a/npc/commands/zeny.txt +++ b/npc/commands/zeny.txt @@ -88,9 +88,9 @@ OnCall: OnInit: if (debug > 0) { - bindatcmd "e", "@esp::OnCall", 0, 2, 0; - bindatcmd "esp", "@esp::OnCall", 0, 2, 0; - bindatcmd "money", "@esp::OnCall", 0, 2, 0; + bindatcmd "e", "@esp::OnCall", 0, 99, 0; + bindatcmd "esp", "@esp::OnCall", 0, 99, 0; + bindatcmd "money", "@esp::OnCall", 0, 99, 0; end; } diff --git a/npc/functions/permissions.txt b/npc/functions/permissions.txt index 646b3779..62e0da6b 100644 --- a/npc/functions/permissions.txt +++ b/npc/functions/permissions.txt @@ -3,28 +3,33 @@ // gumi // Description: // checks player permissions +// ** admins are implicitly everything + +// administrator +function script is_admin { + return has_permission(PERM_USE_ALL_COMMANDS, getarg(0, getcharid(CHAR_ID_ACCOUNT))); +} // any staff member function script is_trusted { - return has_permission("show_client_version", getarg(0, getcharid(CHAR_ID_ACCOUNT))); + return is_admin(getarg(0, getcharid(CHAR_ID_ACCOUNT))) || + has_permission("show_client_version", getarg(0, getcharid(CHAR_ID_ACCOUNT))); } // developer function script is_dev { - return has_permission(PERM_RECEIVE_REQUESTS, getarg(0, getcharid(CHAR_ID_ACCOUNT))); + return is_admin(getarg(0, getcharid(CHAR_ID_ACCOUNT))) || + has_permission(PERM_RECEIVE_REQUESTS, getarg(0, getcharid(CHAR_ID_ACCOUNT))); } // event coordinator function script is_evtc { - return can_use_command("@monster", getarg(0, getcharid(CHAR_ID_ACCOUNT))); + return is_admin(getarg(0, getcharid(CHAR_ID_ACCOUNT))) || + can_use_command("@monster", getarg(0, getcharid(CHAR_ID_ACCOUNT))); } // game master function script is_gm { - return has_permission("send_gm", getarg(0, getcharid(CHAR_ID_ACCOUNT))); -} - -// administrator -function script is_admin { - return has_permission(PERM_USE_ALL_COMMANDS, getarg(0, getcharid(CHAR_ID_ACCOUNT))); + return is_admin(getarg(0, getcharid(CHAR_ID_ACCOUNT))) || + has_permission("send_gm", getarg(0, getcharid(CHAR_ID_ACCOUNT))); } -- cgit v1.2.3-60-g2f50