[MySQL] Cannot load properties, explosion function screws up -
Type-R - 23.04.2014
Hey, everyone! Well im playing around with some scripts, trying to make a little house system, but i cannot load the houses because i get an error.. So the script of loading properties looks like this(im not very good with MySQL):
pawn Код:
stock LoadProperty()
{
new
enX[11],
enY[11],
enZ[11],
exX[11],
exY[11],
exZ[11],
idx;
print("House loading started...");
mysql_query("SELECT NULL FROM properties");
mysql_store_result();
new rows = mysql_num_rows();
mysql_free_result();
CheckMySQL();
for(new i; i < rows; i++) {
new string[128];
format(string, sizeof(string), "SELECT * FROM properties WHERE id = '%d'", i);
mysql_query(string);
mysql_store_result();
new row[1000]; // The length of 1 'row' total.
new field[11][24];
mysql_fetch_row_format(row, "|");
explode(row, field, "|");
mysql_free_result();
mysql_fetch_field_row(enX, "enX");
mysql_fetch_field_row(enY, "enY");
mysql_fetch_field_row(enZ, "enZ");
mysql_fetch_field_row(exX, "exX");
mysql_fetch_field_row(exY, "exY");
mysql_fetch_field_row(exZ, "exZ");
HouseInfo[idx][hEntrancex] = floatstr(enX);
HouseInfo[idx][hEntrancey] = floatstr(enY);
HouseInfo[idx][hEntrancez] = floatstr(enZ);
HouseInfo[idx][hExitx] = floatstr(exX);
HouseInfo[idx][hExity] = floatstr(exY);
HouseInfo[idx][hExitz] = floatstr(exZ);
printf("House %d created", i);
OnHousePickupUpdate(idx);
OnPropTextdrawUpdate(1, idx);
/*++idx;
if(idx == MAX_LOADED_PROPERTIES) {
printf("[SCRIPT]: Notice - there's more properties in database than script can handle. Tweak your MAX_LOADED_PROPERTIES settings");
break;*/
}
print("House loading finished.");
return 1;
}
Then the error i get:
Код:
ADMINAS.pwn(4835) : error 048: array dimensions do not match
ADMINAS.pwn(4938) : warning 203: symbol is never used: "HouseInfo@YSII_Ag"
ADMINAS.pwn(4938) : warning 203: symbol is never used: "HouseInfo@YSII_Cg"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
1 Error.
The error is for this line:
pawn Код:
explode(row, field, "|");
Does anyone know how to fix this error?
Re: [MySQL] Cannot load properties, get an error -
Type-R - 24.04.2014
bump
Re: [MySQL] Cannot load properties, get an error -
Roel - 24.04.2014
It seems explode is a custom function, show us that function.
Re: [MySQL] Cannot load properties, get an error -
Type-R - 24.04.2014
Here it is:
pawn Код:
stock explode(aExplode[][], const sSource[], const sDelimiter[] = " ", iVertices = sizeof aExplode, iLength = sizeof aExplode[]) // By Westie
{
new
iNode,
iPointer,
iPrevious = -1,
iDelimiter = strlen(sDelimiter);
while(iNode < iVertices)
{
iPointer = strfind(sSource, sDelimiter, false, iPointer);
if(iPointer == -1)
{
strmid(aExplode[iNode], sSource, iPrevious, strlen(sSource), iLength);
break;
}
else
{
strmid(aExplode[iNode], sSource, iPrevious, iPointer, iLength);
}
iPrevious = (iPointer += iDelimiter);
++iNode;
}
return iPrevious;
}
I put it at the bottom of the script.
Re: [MySQL] Cannot load properties, get an error -
Type-R - 25.04.2014
Bump
Re: [MySQL] Cannot load properties, get an error -
Type-R - 26.04.2014
So i changed this line explode(row, field, "|");, to strexplode(row, field, "|"); from strlib.inc, got the same error. Switched it to this: strexplode(field, row, "|");( swithced field, and row places) error dissapeared for some reason, but then it wont work.. Anyone know how to fix this?
Re: [MySQL] Cannot load properties, get an error -
Type-R - 27.04.2014
Bump