viewing paste loadchar | 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
ACMD_FUNC(loadchar){
        int account_id = 0, char_id, login_id1=0, client_tick, sex=0, sfd;
        TBL_PC *ssd;
    nullpo_retr(-1, sd);
    if( !message || !*message )
    {
        clif_displaymessage(fd, "Please enter the Char ID. Usage @loadchar <charid>.");
        return -1;
    }
    char_id = atoi(message);
    if( char_id < START_CHAR_NUM)
    {
        clif_displaymessage(fd, "Invalid char ID.");
        return -1;
    }
        if( SQL_ERROR == Sql_Query(mmysql_handle, "SELECT char.account_id,`sex`  FROM `char` inner join `login` on  char.account_id = login.account_id WHERE `char_id` = '%d'", char_id) )
        clif_displaymessage(fd, "MySQL Query Error. Please check your database.");
    else if( Sql_NumRows(mmysql_handle) == 0 )
        clif_displaymessage(fd, "No account founds for the charid, uh??.");
        else
    {
        char *data;
        Sql_NextRow(mmysql_handle);
        Sql_GetData(mmysql_handle, 0, &data, NULL); account_id = atoi(data);
                Sql_GetData(mmysql_handle, 1, &data, NULL); sex = atoi(data);
    }
        CREATE(ssd, TBL_PC, 1);
        client_tick = gettick();
        sfd = 0;
//  sd->fd = fd;
//  sd->packet_ver = packet_ver;
//  session[fd]->session_data = sd;
 
    pc_setnewpc(ssd, account_id, char_id, login_id1, client_tick, sex, sfd);
        map_addblock(&ssd->bl);
        clif_spawn(&ssd->bl);
        return 0;
}
Viewed 1550 times, submitted by lighta.