21.12.2013, 18:30
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
Explanation inside, sscanf version looks simple and neat, eh'?
"p<|>" = Delimiter. / Split's the string.
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;
}
"p<|>" = Delimiter. / Split's the string.