Tag mismatch - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Tag mismatch (
/showthread.php?tid=641376)
Tag mismatch -
SetPlayerNameTag - 15.09.2017
P_CHEMICAL[playerid][Amount] Is a
FLOAT
PHP код:
if(mysql_num_rows())
{
while(mysql_retrieve_row())
{
mysql_fetch_field_row(temp, "ID"), P_CHEMICAL[playerid][ID][id] = strval(temp);
mysql_fetch_field_row(temp, "Item"), P_CHEMICAL[playerid][ChemicalID][id] = strval(temp);
mysql_fetch_field_row(temp, "Amount"), P_CHEMICAL[playerid][Amount][id] = floatstr(temp); // warning line
id ++;
}
}
PHP код:
stock AddChemical(playerid, chemical, Float:amount)
{
for(new i = 0,j = MAX_CHEMICAL; i < j; i ++)
{
if(P_CHEMICAL[playerid][ChemicalID][i] > 0) continue;
else
{
format(_query, sizeof(_query), "INSERT INTO `chemical`(`Owner`, `Item`, `Amount`) VALUES (%d, %d, %.1f)", cInfo[playerid][SQLID], chemical, amount);
mysql_query(_query);
P_CHEMICAL[playerid][ID][i] = mysql_insert_id();
P_CHEMICAL[playerid][ChemicalID][i] = chemical;
P_CHEMICAL[playerid][Amount][i] = amount; // warning line
P_CHEMICAL[playerid][Owner][i] = cInfo[playerid][SQLID];
break;
}
}
return 1;
}
Re: Tag mismatch -
Meller - 15.09.2017
You're telling the enum to set Amount's I to *
AKA:
P_CHEMICAL[playerid][Owner][i]
should be
P_CHEMICAL[playerid][i][Owner]
P_CHEMICAL[enum 1][enum 2][variable]
Re: Tag mismatch -
Vince - 15.09.2017
Restructure your array so that it looks like this:
Код:
P_CHEMICAL[playerid][id][Amount]
Also you shouldn't name regular variables in all caps; identifiers in all caps are usually reserved for constants with the express purpose to distinguish them from regular variables.
Re: Tag mismatch -
SetPlayerNameTag - 15.09.2017
Thank you, I just noticed it..!