summaryrefslogtreecommitdiff
path: root/src/map/atcommand.c
diff options
context:
space:
mode:
authorshennetsind <shennetsind@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-08-17 19:41:29 +0000
committershennetsind <shennetsind@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-08-17 19:41:29 +0000
commitd398b01eb2dceba231b7c313e402817554c3a43d (patch)
treee58896ff84ea57f360a79a00693ad80d4321937b /src/map/atcommand.c
parentc03b423beb53c93a24075516597617ca3f40a493 (diff)
downloadhercules-d398b01eb2dceba231b7c313e402817554c3a43d.tar.gz
hercules-d398b01eb2dceba231b7c313e402817554c3a43d.tar.bz2
hercules-d398b01eb2dceba231b7c313e402817554c3a43d.tar.xz
hercules-d398b01eb2dceba231b7c313e402817554c3a43d.zip
Added 2 (3) new atcommands:
* @unloadnpcfile <file path> ** e.g. "@unloadnpcfile npc/cities/alberta.txt" unloads all npcs created by the npc/cities/alberta.txt file. * @addperm/@rmvperm <permission_name> ** e.g. "@addperm skill_unconditional" / "#rmvperm "player" skill_unconditional" git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16656 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/atcommand.c')
-rw-r--r--src/map/atcommand.c77
1 files changed, 77 insertions, 0 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 58204b491..feda37060 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -8780,6 +8780,80 @@ ACMD_FUNC(reloadquestdb) {
clif_displaymessage(fd, "Quest DB has been reloaded");
return 0;
}
+ACMD_FUNC(addperm) {
+ int perm_size = ARRAYLENGTH(pc_g_permission_name);
+ bool add = (strcmpi(command+1, "addperm") == 0) ? true : false;
+ int i;
+
+ if( !message || !*message ) {
+ sprintf(atcmd_output, "Usage: %s <permission_name>",command);
+ clif_displaymessage(fd, atcmd_output);
+ clif_displaymessage(fd, "-- Permission List");
+ for( i = 0; i < perm_size; i++ ) {
+ sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
+ clif_displaymessage(fd, atcmd_output);
+ }
+ return -1;
+ }
+
+ ARR_FIND(0, perm_size, i, strcmpi(pc_g_permission_name[i].name, message) == 0);
+
+ if( i == perm_size ) {
+ sprintf(atcmd_output,"'%s' is not a known permission",message);
+ clif_displaymessage(fd, atcmd_output);
+ clif_displaymessage(fd, "-- Permission List");
+ for( i = 0; i < perm_size; i++ ) {
+ sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
+ clif_displaymessage(fd, atcmd_output);
+ }
+ return -1;
+ }
+
+ if( add && (sd->permissions&pc_g_permission_name[i].permission) ) {
+ sprintf(atcmd_output, "User '%s' already possesses the '%s' permission",sd->status.name,pc_g_permission_name[i].name);
+ clif_displaymessage(fd, atcmd_output);
+ return -1;
+ } else if ( !add && !(sd->permissions&pc_g_permission_name[i].permission) ) {
+ sprintf(atcmd_output, "User '%s' doesn't possess the '%s' permission",sd->status.name,pc_g_permission_name[i].name);
+ clif_displaymessage(fd, atcmd_output);
+ sprintf(atcmd_output,"-- User '%s' Permissions",sd->status.name);
+ clif_displaymessage(fd, atcmd_output);
+ for( i = 0; i < perm_size; i++ ) {
+ if( sd->permissions&pc_g_permission_name[i].permission ) {
+ sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
+ clif_displaymessage(fd, atcmd_output);
+ }
+ }
+
+ return -1;
+ }
+
+ if( add )
+ sd->permissions |= pc_g_permission_name[i].permission;
+ else
+ sd->permissions &=~ pc_g_permission_name[i].permission;
+
+
+ sprintf(atcmd_output, "User '%s' permissions were updated successfully, be aware the changes are temporary.",sd->status.name);
+ clif_displaymessage(fd, atcmd_output);
+
+ return 0;
+}
+ACMD_FUNC(unloadnpcfile) {
+
+ if( !message || !*message ) {
+ clif_displaymessage(fd, "Usage: @unloadnpcfile <file name>");
+ return -1;
+ }
+
+ if( npc_unloadfile(message) )
+ clif_displaymessage(fd, "File unloaded, be aware mapflags and monsters spawned directly are not removed");
+ else {
+ clif_displaymessage(fd, "File not found");
+ return -1;
+ }
+ return 0;
+}
/**
* Fills the reference of available commands in atcommand DBMap
**/
@@ -9030,6 +9104,9 @@ void atcommand_basecommands(void) {
ACMD_DEF(disguiseguild),
ACMD_DEF(sizeall),
ACMD_DEF(sizeguild),
+ ACMD_DEF(addperm),
+ ACMD_DEF2("rmvperm", addperm),
+ ACMD_DEF(unloadnpcfile),
/**
* For Testing Purposes, not going to be here after we're done.
**/