Error in LoadOrg stock
#4

I'd suggest you to use sscanf to load this kind of stuff, I will write a code how you could load it using sscanf,

EDIT

pawn Код:
stock LoadOrgs( )
{
    new id = 1;
    while( id < MAX_ORGS ) //Loop, checks all the slots, searching for data.
    {
        format( Query,sizeof ( Query ),"SELECT * FROM `orgs` WHERE `ID` = '%d'", id ); // Selects all the information from the table
        mysql_query( Query );

        mysql_store_result( );//stores the data after using SELECT.

        if( mysql_num_rows ( ) ) //if the row is not null.
        {
            if( mysql_fetch_row_format( Query,"|" ) )
            {
                sscanf(Query, "p<|>fffis[24]s[11]s[24]iiiiiii", OrgInfo[ id ][ oX ],  OrgInfo[ id ][ oY ], OrgInfo[ id ][ oZ ], OrgInfo[ id ][ oInt ], OrgInfo[ id ][ oName ], OrgInfo[ id ][ oColor ],
                OrgInfo[ id ][ oLeader ], OrgInfo[ id ][ oSkin ][ 0 ], OrgInfo[ id ][ oSkin ][ 1 ], OrgInfo[ id ][ oSkin ][ 2 ], OrgInfo[ id ][ oWeapon ][ 0 ], OrgInfo[id][oWeapon][ 1 ], OrgInfo[id][oWeapon][ 2 ],
                OrgInfo[ id ][ oBank ]); //seperates the data into variable, so you could use it.

                CreateOrg(OrgInfo[ id ][ oX ],OrgInfo[ id ][ oY ],OrgInfo[ id ][ oZ ],OrgInfo[ id ][ oInt ],OrgInfo[ id ][ oName ],OrgInfo[ id ][ oColor ],OrgInfo[ id ][ oWeapon ][ 0 ],OrgInfo[ id ][ oWeapon ][ 1 ],OrgInfo[ id ][ oWeapon ][ 2 ],
                OrgInfo[ id ][ oSkin ][ 0 ],OrgInfo[ id ][ oSkin ][ 1 ],OrgInfo[ d ][ oSkin ][ 2 ],OrgInfo[ id ][ oType ]);  //creates the organization, using the data that sscanf loaded
            }
        }
        i++;
    }
    return 1;
}
Explanation inside, sscanf version looks simple and neat, eh'?

"p<|>" = Delimiter. / Split's the string.
Reply


Messages In This Thread
Error in LoadOrg stock - by Tayab - 21.12.2013, 18:07
Re: Error in LoadOrg stock - by Konstantinos - 21.12.2013, 18:10
Re: Error in LoadOrg stock - by Tayab - 21.12.2013, 18:26
Re: Error in LoadOrg stock - by Patrick - 21.12.2013, 18:30
Re: Error in LoadOrg stock - by Tayab - 23.12.2013, 14:28

Forum Jump:


Users browsing this thread: 1 Guest(s)