Jump to content
  • 0
evilpuncker

groupid2name

Question

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

3 answers to this question

Recommended Posts

  • 0

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 by Via

Share this post


Link to post
Share on other sites
  • 0

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;}

Share this post


Link to post
Share on other sites
  • 0

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 by Angelmelody

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.