GmOcean 92 Posted November 27, 2014 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. Quote Share this post Link to post Share on other sites
0 Garr 117 Posted November 27, 2014 (edited) 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 Edited November 27, 2014 by Garr Quote Share this post Link to post Share on other sites
0 GmOcean 92 Posted November 27, 2014 (edited) 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 November 27, 2014 by GmOcean Quote Share this post Link to post Share on other sites
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?
My guess is:
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