viewing paste Unknown #9903 | Athena

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
BUILDIN_FUNC(rentitem)
{
    struct map_session_data *sd;
    struct script_data *data;
    struct item it;
    int seconds;
    int nameid = 0, flag;
 
    data = script_getdata(st,2);
    get_val(st,data);
 
    if( (sd = script_rid2sd(st)) == NULL )
        return 0;
 
    if( data_isstring(data) )
    {
        const char *name = conv_str(st,data);
        struct item_data *itd = itemdb_searchname(name);
        if( itd == NULL )
        {
            ShowError("buildin_rentitem: Nonexistant item %s requested.\n", name);
            return 1;
        }
        nameid = itd->nameid;
    }
    else if( data_isint(data) )
    {
        nameid = conv_num(st,data);
        if( nameid <= 0 || !itemdb_exists(nameid) )
        {
            ShowError("buildin_rentitem: Nonexistant item %d requested.\n", nameid);
            return 1;
        }
    }
    else
    {
        ShowError("buildin_rentitem: invalid data type for argument #1 (%d).\n", data->type);
        return 1;
    }
 
    seconds = script_getnum(st,3);
    memset(&it, 0, sizeof(it));
    it.nameid = nameid;
    it.identify = 1;
    it.expire_time = (unsigned int)(time(NULL) + seconds);
 
    if( (flag = pc_additem(sd, &it, 1)) )
    {
        clif_additem(sd, 0, 0, flag);
        return 1;
    }
 
    clif_rental_time(sd->fd, nameid, seconds);
    pc_inventory_rental_add(sd, seconds);
 
    if( log_config.enable_logs&LOG_SCRIPT_TRANSACTIONS )
        log_pick_pc(sd, "N", nameid, 1, NULL);
    
    return 0;
}
 
Viewed 854 times, submitted by Guest.