Jump to content
  • 0
Sign in to follow this  
GmOcean

*getskillname

Question

Okay, so I was trying to make this command, when all of a sudden, "map-server crashed".

 

Anyone know where I went wrong with this?

BUILDIN(getskillname) {    TBL_PC *sd = script->rid2sd(st);    uint16 skill_id;    int index;    if(!sd)        return true;    skill_id = script_getnum(st,2);    if (!(index = skill->get_index(skill_id)) || skill->db[index].name == NULL) {        ShowError("script_getskillname: Skill with id %d does not exist in the skill databasen", skill_id);        return 0;    }    script->push_str((st)->stack, C_STR, skill->db[index].name);    return true;}

My guess is:

script->push_str((st)->stack, C_STR, skill->db[index].name);

But, I don't know any other way to actually push the name, because skill->get_name(skill_id); is a const char.

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Hmm, I think it should be C_CONSTSTR.

script->push_str((st)->stack, C_CONSTSTR, skill->db[index].name);

May I ask why you need player data here? If you're looking for skill name from skill ID you don't really need to attach player at all. Moreso, there are predefined routines in script.h, so why use one when you already have script_pushconststr?

 

BUILDIN(getskillname) {    uint16 skill_id;    int index;		if( script_isinttype(st,2) )    skill_id = script_getnum(st,2);    if ( !(index = skill->get_index(skill_id)) || skill->db[index].name == NULL ) {        ShowError("script_getskillname: Skill with id %d does not exist in the skill databasen", skill_id);        return true;    }    script_pushconststr(st, skill->db[index].name);    return true;}

 

P.S. I didn't check it out as I was lazy to recompile my test server for that, and I was lazy to remake that into plugin to test either :P

Edited by Garr

Share this post


Link to post
Share on other sites
  • 0

I'll test it in a bit, first a meal @.@;

 

Also, @why player data, I added it only because I was unsure how to obtain a skill name at first, just ended up not removing it xD

lastly, I tried using script_pushconststr, however visual c++ 2010 kept telling me the way I was using it was either wrong, or couldn't be called the way you're using it, and was recommending script->push_str.

Because the first thing I tried was your example (didn't test with compile) since that was how strcharinfo works (aside from skill name).

 

Edit:

Okay, now I feel dumb -.-; What you posted (what I originally had) does indeed work perfectly. I just stupidly forgot to include skill.h into the plugin, so the map-server crashed running a search for that.

*sigh* sorry for wasting your time. But thanks for the help.

Edited by GmOcean

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...
Sign in to follow this  

×
×
  • Create New...

Important Information

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