Vice City Multiplayer

VC:MP => mIRC/pawn Scripting => Topic started by: aXXo on March 17, 2010, 11:11:07 PM

Title: [PAWN]"Warning:Tag mismatch" on float return
Post by: aXXo on March 17, 2010, 11:11:07 PM
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?
Title: Re: [PAWN]"Warning:Tag mismatch" on float return
Post by: Force on March 17, 2010, 11:35:11 PM
Need to have forward Float:GetDistance as well, Pawn is really gay with the whole tag thingy.
Title: Re: [PAWN]"Warning:Tag mismatch" on float return
Post by: Jancis_LV on March 18, 2010, 07:24:41 AM
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);
}
Title: Re: [PAWN]"Warning:Tag mismatch" on float return
Post by: Boss on March 18, 2010, 09:24:57 AM
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.
Title: Re: [PAWN]"Warning:Tag mismatch" on float return
Post by: Force on March 18, 2010, 01:24:12 PM
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
}
Title: Re: [PAWN]"Warning:Tag mismatch" on float return
Post by: aXXo on March 18, 2010, 01:43:50 PM
Arright, a function prototype :)

So, is it advisable to have a prototype for every public function?
or just the ones which give tag mismatch?
Title: Re: [PAWN]"Warning:Tag mismatch" on float return
Post by: Force on March 18, 2010, 01:51:06 PM
Only one's that you create yourself that are giving tag mismatch warnings.
Title: Re: [PAWN]"Warning:Tag mismatch" on float return
Post by: Boss on March 18, 2010, 02:15:42 PM
*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