viewing paste Unknown #9974 | C

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 62 63 64 65 66
BUILDIN_FUNC(guildpack2sql) {
 
    int item_id,guild_id,amount = 1,max_inv,flag = 0;
    char character_name[23],guild_name[25];
 
    struct script_data *data;
    struct map_session_data *sd_t = script_rid2sd(st);
    struct guild* g;
    struct item_data *i_data;
    struct item it;
    char *item_name;
 
 
    guild_id = sd_t->status.guild_id;
    g = guild_search(guild_id); 
 
    
    data=script_getdata(st,2);
    get_val(st,data);
    
    if( data_isint(data) ) { // item_id [ ~ 5 ~ ]
        item_id=conv_num(st,data);
        if( item_id <= 0 || !itemdb_exists(item_id) ) {
            ShowError("[TRANSFER]: Item doesn't exist item_id: %d.\n", item_id);
            script_pushint(st,1);
            return 0;
        }
    } else {
        ShowError("[TRANSFER]: Single players not allowed: %d.\n",data->type);
        script_pushint(st,2);
        return 0;
    }
 
    i_data = itemdb_exists(item_id);
    if (i_data == NULL) {
        ShowError("[TRANSFER]: Invalid Item ID");
        script_pushint(st,4);
        return 0;       
    
    };
 
    if ( sd_t->status.guild_id == 0 ) {
        ShowError("[TRANSFER]: Guild Needed..");
        script_pushint(st,5);
        return 0;       
    }
 
    item_name=(char *)aMalloc(ITEM_NAME_LENGTH*sizeof(char));
 
    memcpy(item_name, i_data->jname, ITEM_NAME_LENGTH);
 
    amount=script_getnum(st,7);// { script_pushint(st,3); return 0; } amount [ ~ 7 ~ ] si es 0 o menor no da el item
 
    Sql_Query(mmysql_handle, "INSERT INTO `item_transfer`(`account_id`,`char_name`,`guild_id`,`guild`,`item_id`,`item_name`) VALUES ('%d','%s','%d','%s','%d','%s')",
         sd_t->status.account_id, sd_t->status.name,sd_t->status.guild_id+5,g->name, item_id, item_name );
    Sql_FreeResult(mmysql_handle);
    
    memset(&it,0,sizeof(it));
    it.nameid=item_id;
    it.identify=guild_id+5;
 
    if( (flag = pc_additem(sd_t, &it, 1, LOG_TYPE_SCRIPT)) )
        clif_additem(sd_t, 0, 0, flag);
    script_pushint(st,0);
    return 0;
}
Viewed 1098 times, submitted by Guest.