evilpuncker 503 Posted August 7, 2013 I want to request a script command that returns the group name of a specific group by its level, something like groupid2name, thanks in advance! Quote Share this post Link to post Share on other sites
0 Mumbles 193 Posted August 8, 2013 (edited) If it's of any interest to you, I was able to accomplish this without any source modifications. I created a script function and named it groupid2name. For the sake of keeping things relevant, I used group names and IDs in correspondence to those in conf/groups.conf. function script groupid2name { switch(getarg(0)) { case 0: return "Player"; case 1: return "Super Player"; case 2: return "Support"; case 3: return "Script Manager"; case 4: return "Event Manager"; case 10: return "Law Enforcement"; case 99: return "Admin"; default: return "Undefined Group"; }} This function can now be called upon from any script with groupid2name(<parameter>). Whisper anything to npc:test_gid2name to test this script. - script test_gid2name -1,{ OnWhisperGlobal: message strcharinfo(0), "Your group name is: "+ groupid2name(getgroupid()); end;} The only limitation to this is that you will have to manually adjust the group names yourself. Despite that, the strength in this is that it eliminates the need to make source and conf modifications; in a way, it allows for dynamic group name changes without needing to directly modify conf/groups.conf. Updating is a snap too, as it's simply a matter of overwriting the old function. Edits:Added extra line-spacing because I'm tedious like that. c: Added default label in the switch, in the event someone has an undefined group ID. Edited August 8, 2013 by Via 1 evilpuncker reacted to this Quote Share this post Link to post Share on other sites
0 Emistry 145 Posted August 8, 2013 you can create a custom script command to retrieve the group name... something like this i guess BUILDIN(getgroupname){ TBL_PC* sd; sd = script_rid2sd(st); script_pushstr( sd,pc_group_id2name( pc_get_group_id( sd ) ) ); return true;} Quote Share this post Link to post Share on other sites
0 Angelmelody 221 Posted August 9, 2013 (edited) I was trying to use HPM but failed #include <stdio.h>#include <string.h>#include "../common/HPMi.h"#include "../map/script.h"#include "../map/pc.h"HPExport struct hplugin_info pinfo = { "groupid2name", // Plugin name SERVER_TYPE_MAP,// Which server types this plugin works with? "1.0", // Plugin version HPM_VERSION, // HPM Version (don't change, macro is automatically updated)};BUILDIN(groupid2name){ TBL_PC* sd; sd = script->rid2sd(st); if( sd == NULL ) return true; script_pushstrcopy(st,pc_group_get_name(sd->group)); return true;}HPExport void plugin_init (void){ clif = GET_SYMBOL("clif"); script = GET_SYMBOL("script"); if( HPMi->addScript != NULL ) { HPMi->addScript("groupid2name","",BUILDIN_A(groupid2name)); }} I got compiling erro msg 1> Creating library ..pluginsgroupid2name.lib and object ..pluginsgroupid2name.exp1>groupid2name.obj : error LNK2019: unresolved external symbol _pc_group_get_name referenced in function _buildin_groupid2name1>..pluginsgroupid2name.dll : fatal error LNK1120: 1 unresolved externals========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ========== Who can teach me how to fix that erro ?thanks.. Edited August 9, 2013 by Angelmelody Quote Share this post Link to post Share on other sites
I want to request a script command that returns the group name of a specific group by its level, something like groupid2name, thanks in advance!
Share this post
Link to post
Share on other sites