Jump to content
  • 0

Getitemname first database


lipitb

Question


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  5
  • Reputation:   0
  • Joined:  06/14/13
  • Last Seen:  

Hi!

I want to modify the function "getitemname" for first check the name in the database as my script:

example:





 function    script    getitemname    {

set @querysql, query_sql("select name_japanese from `ragdb`.`item_db` WHERE `id` ="+getarg(0)+" ORDER BY id ASC LIMIT 0,1", $@itemname$);
if(@querysql == 0) {set $@itemname$, getitemname(getarg(0));}
return;
}
//$@itemname$ = Item name






/*==========================================
 * Get the item name by item_id or null
 *------------------------------------------*/
BUILDIN(getitemname)
{
    int item_id=0;
    struct item_data *i_data;
    char *item_name;
    struct script_data *data;
    
    data=script_getdata(st,2);
    script->get_val(st,data);
    
    if( data_isstring(data) ){
        const char *name=script->conv_str(st,data);
        struct item_data *item_data = itemdb->search_name(name);
        if( item_data )
            item_id=item_data->nameid;
    }else
        item_id=script->conv_num(st,data);
    
    i_data = itemdb->exists(item_id);
    if (i_data == NULL)
    {
        script_pushconststr(st,"null");
        return true;
    }
    item_name=(char *)aMalloc(ITEM_NAME_LENGTH*sizeof(char));
    
    memcpy(item_name, i_data->jname, ITEM_NAME_LENGTH);
    script_pushstr(st,item_name);
    return true;
}




Edited by Patskie
Change to code
Link to comment
Share on other sites

1 answer to this question

Recommended Posts


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10018
  • Reputation:   2369
  • Joined:  10/28/11
  • Last Seen:  

why not just switch to SQL db ... /hmm

conf/inter_athena.conf#L119

Link to comment
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.   Paste as plain text instead

  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.

×
×
  • Create New...