Hi.
Apparantly, im getting a "Warning 213: Tag Mismatch" on the line where im returning a float value in a function.
Function body:
public GetDistance(Float:X1,Float:Y1,Float:Z1,Float:X2,Float:Y2,Float:Z2)
{
new Float:X = floatsub(X2,X1);
new Float:Y = floatsub(Y2,Y1);
new Float:Z = floatsub(Z2,Z1);
new Float:Dist = floatsqroot(floatadd(floatadd(floatpower(X,2),floatpower(Y,2)),floatpower(Z,2)));
return Dist;
}
The function is returning a random, wrong value......
Then, i replaced:
public GetDistance(Float:X1,Float:Y1,Float:Z1,Float:X2,Float:Y2,Float:Z2)
by
public Float:GetDistance(Float:X1,Float:Y1,Float:Z1,Float:X2,Float:Y2,Float:Z2)
The Warning changes to:
warning 208: function with tag result used before definition, forcing reparse
Now the function returns an accurate value....
But still...any method to remove the warning?
Need to have forward Float:GetDistance as well, Pawn is really gay with the whole tag thingy.
I use this:
public GetDistance(x1, y1, z1, x2, y2, z2)
{
new Float:dis;
dis = floatsqroot((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)+(z2-z1)*(z2-z1));
return floatround(dis);
}
Quote from: aXXo on March 17, 2010, 11:11:07 PM
warning 208: function with tag result used before definition, forcing reparse
You need to define your function above wherever it is first used. On top of the script (but below includes) will do.
Just to show you how sucky pawn is, this is how I stopped tag mismatch warnings.
forward Float:DistanceCalc( Float:x1, Float:x2, Float:y1, Float:y2, Float:z1, Float:z2 );
public Float:DistanceCalc( Float:x1, Float:x2, Float:y1, Float:y2, Float:z1, Float:z2 )
{
// Do your stuff here
}
Arright, a function prototype :)
So, is it advisable to have a prototype for every public function?
or just the ones which give tag mismatch?
Only one's that you create yourself that are giving tag mismatch warnings.
*sigh*
1) "public" is not needed.
2) Prototypes (forwards) are not needed.
3) A function returning floats must have "Float:" in front of it and be defined before it's first used.
4) kthxbye