Jump to content
  • 0
Sign in to follow this  
lipitb

Getitemname first database

Question

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

 

 

 

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

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