Author Topic: [PAWN]"Warning:Tag mismatch" on float return  (Read 10248 times)

0 Members and 2 Guests are viewing this topic.

Offline aXXo

  • Wiseguy
  • **
  • Posts: 50
    • View Profile
[PAWN]"Warning:Tag mismatch" on float return
« on: March 18, 2010, 01:11:07 am »
Hi.
Apparantly, im getting a "Warning 213: Tag Mismatch" on the line where im returning a float value in a function.
Function body:
Code: [Select]
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:
Code: [Select]
public GetDistance(Float:X1,Float:Y1,Float:Z1,Float:X2,Float:Y2,Float:Z2)
by

Code: [Select]
public Float:GetDistance(Float:X1,Float:Y1,Float:Z1,Float:X2,Float:Y2,Float:Z2)

The Warning changes to:
Code: [Select]
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?

Offline Force

  • LU Developer
  • Made Man
  • *
  • Posts: 242
    • View Profile
Re: [PAWN]"Warning:Tag mismatch" on float return
« Reply #1 on: March 18, 2010, 01:35:11 am »
Need to have forward Float:GetDistance as well, Pawn is really gay with the whole tag thingy.

Offline Jancis_LV

  • Street Thug
  • *
  • Posts: 37
    • View Profile
    • Latvian Vice City
Re: [PAWN]"Warning:Tag mismatch" on float return
« Reply #2 on: March 18, 2010, 09:24:41 am »
I use this:
Code: [Select]
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);
}
Latvian Vice City server
78.84.47.75:5192

Offline Boss

  • VC:MP Beta Tester (inactive)
  • Made Man
  • *
  • Posts: 229
  • Boss
    • View Profile
    • TDH Clan Site
Re: [PAWN]"Warning:Tag mismatch" on float return
« Reply #3 on: March 18, 2010, 11:24:57 am »
Code: [Select]
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.

Offline Force

  • LU Developer
  • Made Man
  • *
  • Posts: 242
    • View Profile
Re: [PAWN]"Warning:Tag mismatch" on float return
« Reply #4 on: March 18, 2010, 03:24:12 pm »
Just to show you how sucky pawn is, this is how I stopped tag mismatch warnings.

Code: [Select]
forward Float:DistanceCalc( Float:x1, Float:x2, Float:y1, Float:y2, Float:z1, Float:z2 );

Code: [Select]
public Float:DistanceCalc( Float:x1, Float:x2, Float:y1, Float:y2, Float:z1, Float:z2 )
{
       // Do your stuff here
}

Offline aXXo

  • Wiseguy
  • **
  • Posts: 50
    • View Profile
Re: [PAWN]"Warning:Tag mismatch" on float return
« Reply #5 on: March 18, 2010, 03: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?

Offline Force

  • LU Developer
  • Made Man
  • *
  • Posts: 242
    • View Profile
Re: [PAWN]"Warning:Tag mismatch" on float return
« Reply #6 on: March 18, 2010, 03:51:06 pm »
Only one's that you create yourself that are giving tag mismatch warnings.

Offline Boss

  • VC:MP Beta Tester (inactive)
  • Made Man
  • *
  • Posts: 229
  • Boss
    • View Profile
    • TDH Clan Site
Re: [PAWN]"Warning:Tag mismatch" on float return
« Reply #7 on: March 18, 2010, 04: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