eezclide Posted March 1, 2020 Group: Members Topic Count: 4 Topics Per Day: 0.00 Content Count: 12 Reputation: 0 Joined: 05/31/14 Last Seen: March 28, 2020 Share Posted March 1, 2020 ive been tryin to figure our what's the prob here. Im not that good yet in scripting /** * Jezznar * getskillname (skillid); **/ BUILDIN_FUNC(getskillname) { int skill_id; char *skill_name; //get input skill_id if (!script_hasdata(st, 2)) { script_pushconststr(st, "null"); return SCRIPT_CMD_SUCCESS; } skill_id = script_getnum(st, 2); if (!skill_get_index(skill_id)) { ShowError("script:conv_str: Unknown skill_id supplied.\"\n"); script_pushconststr(st, "null"); return SCRIPT_CMD_SUCCESS; } skill_name = (char *)aMalloc(SKILL_NAME_LENGTH * sizeof(char)); memcpy(skill_name, skill_db[skill_get_index(skill_id)]->desc, SKILL_DESC_LENGTH); script_pushstr(st, skill_name); return SCRIPT_CMD_SUCCESS; } Quote Link to comment Share on other sites More sharing options...
0 sader1992 Posted March 1, 2020 Group: Content Moderator Topic Count: 55 Topics Per Day: 0.01 Content Count: 1691 Reputation: 716 Joined: 12/21/14 Last Seen: 14 hours ago Share Posted March 1, 2020 try BUILDIN_FUNC(getskillname) { int skill_id; //get input skill_id if (!script_hasdata(st, 2)) { script_pushconststr(st, "null"); return SCRIPT_CMD_SUCCESS; } skill_id = script_getnum(st, 2); if (!skill_get_index(skill_id)) { ShowError("script:conv_str: Unknown skill_id supplied.\"\n"); script_pushconststr(st, "null"); return SCRIPT_CMD_SUCCESS; } script_pushstr(st, skill_db.find(skill_id)->desc); return SCRIPT_CMD_SUCCESS; } Quote Link to comment Share on other sites More sharing options...
Question
eezclide
ive been tryin to figure our what's the prob here. Im not that good yet in scripting
/**
* Jezznar
* getskillname (skillid);
**/
BUILDIN_FUNC(getskillname)
{
int skill_id;
char *skill_name;
//get input skill_id
if (!script_hasdata(st, 2)) {
script_pushconststr(st, "null");
return SCRIPT_CMD_SUCCESS;
}
skill_id = script_getnum(st, 2);
if (!skill_get_index(skill_id)) {
ShowError("script:conv_str: Unknown skill_id supplied.\"\n");
script_pushconststr(st, "null");
return SCRIPT_CMD_SUCCESS;
}
skill_name = (char *)aMalloc(SKILL_NAME_LENGTH * sizeof(char));
memcpy(skill_name, skill_db[skill_get_index(skill_id)]->desc, SKILL_DESC_LENGTH);
script_pushstr(st, skill_name);
return SCRIPT_CMD_SUCCESS;
}
Link to comment
Share on other sites
1 answer to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.