Raised This Month: $51 Target: $400
 12% 

enum & float double array - tag mismatch


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ehha
SourceMod Donor
Join Date: Apr 2006
Location: Sibiu
Old 11-22-2009 , 06:45   enum & float double array - tag mismatch
Reply With Quote #1

Code:
#defien BASE_INT        20.0 #define BASE_MP_REG  0.01 #define INT_MUL   13.0 new Float:stats[33][11]; enum list_stats {     istr = 0,// actual str     iagi,   //1    actual agi     iint,   //2    actual int     php,    //3 hp pool     pmp,    //4 mp pool     rhp,    //5 hp reg     rmp,    //6 mp reg     mhp,    //7 hp max     mmp,    //8 mp max     rap,    //9 ap red     pap //10 ap pool } public client_connect(id) {     stats[id][istr] = 0.0;     stats[id][iagi] = 0.0;     stats[id][iint] = 0.0;     stats[id][php] = 0.0;     stats[id][pmp] = 0.0;     stats[id][rhp] = 0.0;     stats[id][rmp] = 0.0;     stats[id][mhp] = 0.0;     stats[id][mmp] = 0.0;     stats[id][rap] = 0.0; } ... //some func stats[id][iint] = BASE_INT; stats[id][mmp] = HERO_BASE_MP + (stats[id][iint] * INT_MUL); stats[id][pmp] = stats[id][mhp]//warning 213: tag mismatch stats[id][php] = stats[id][mhp]; ... public mp_reg(id) {     new Float:mp_pool = stats[id][pmp]; //warning 213: tag mismatch     mp_pool = mp_pool + BASE_MP_REG + stats[id][rmp];     if(mp_pool > stats[id][mmp])         mp_pool = stats[id][mmp]; //warning 213: tag mismatch }
__________________

Last edited by ehha; 11-25-2009 at 11:15.
ehha is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-22-2009 , 07:16   Re: float double array - tag mismatch
Reply With Quote #2

Try :

PHP Code:
new Float:stats[33][list_stats];
enum _:list_stats

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
ehha
SourceMod Donor
Join Date: Apr 2006
Location: Sibiu
Old 11-22-2009 , 07:30   Re: float double array - tag mismatch
Reply With Quote #3

Done, same problem.
I forgot to mention that stats[id][pmp] & stats[id][pap] takes some astronomical values, over 6 digits.
__________________
ehha is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 11-22-2009 , 07:41   Re: float double array - tag mismatch
Reply With Quote #4

Add Float:

Eg : new Float:mp_pool = Float:stats[id][pmp];

or you can directly put Float: in the enum on each element.
__________________

Last edited by Arkshine; 11-22-2009 at 07:52.
Arkshine is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 11-22-2009 , 07:58   Re: float double array - tag mismatch
Reply With Quote #5

Quote:
Originally Posted by Arkshine View Post
Add Float:

Eg : new Float:mp_pool = Float:stats[id][pmp];

or you can directly put Float: in the enum on each element.
How that could work? Stats is already a float array.

What here fails is the tag list_stats. You have make a decision do you use the tag or not, either connors way or:
PHP Code:
enum //no tag here
{
    
istr 0,// actual str
    
iagi,   //1    actual agi
    //.... 
Though if you have to use it with both the tag an not( can't imagine how that would be possible ):
PHP Code:
stats][ _:php 
Edit: And about Connor's code, no you don't need the _: before the list_stats tag when creating the enum.

Last edited by SnoW; 11-22-2009 at 08:01.
SnoW is offline
Send a message via MSN to SnoW
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 11-22-2009 , 08:10   Re: float double array - tag mismatch
Reply With Quote #6

Quote:
What here fails is the tag list_stats
No.

Quote:
How that could work?
It works because the tag output was not a float and before posting something I test always.
__________________

Last edited by Arkshine; 11-22-2009 at 08:21.
Arkshine is offline
ehha
SourceMod Donor
Join Date: Apr 2006
Location: Sibiu
Old 11-22-2009 , 08:29   Re: float double array - tag mismatch
Reply With Quote #7

This worked:
Code:
enum _:list_stats {     Float:istr = 0,//   actual str     Float:iagi, //1  actual agi     Float:iint, //2  actual int     Float:pmp,  //3   mp pool     Float:rhp,  //4   hp reg     Float:rmp,  //5   mp reg     Float:mhp,  //6   hp max     Float:mmp,  //7   mp max     Float:rap,  //8   ap red     Float:pap   //9    ap pool }new Float:stats[33][list_stats];
Thanks
But I don't understand why it worked, the items from enum should be the 2nd index for the double array, the index should be integer, right?
__________________

Last edited by ehha; 11-22-2009 at 08:33.
ehha is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 11-22-2009 , 10:23   Re: float double array - tag mismatch
Reply With Quote #8

_: is not needed there.

I don't know much about that and I badly explain but in Pawn you can use structs like in C with an enum. The way you use in your code is a struct of severals float vars.
An enum is a list of possible value for a variable.
A struct is a list of different sub-variables ( bool, float, integer, array or custom tags ) for variables.

A simple basic enum :

Code:
enum Mood {     HAPPY,     ANNOYED,     DRUNK,     ENERGETIC,     ALONE    } public MyFunction ( const User ) {     new Mood:UserMood = GetUserMood( User );         if ( UserMood == DRUNK )     {         // Blabla.     } } Mood:GetUserMood( const User ) {     return HAPPY; }

Now, a basic structs :

Code:
enum Rectangle {     Left,     Top,     Right,     Bottom }; new MyRec[ Rectangle ]; MyFunction() {     MyRec[ Left ] = 10;     MyRec[ Top ] = 5;     MyRec[ Right ] = 12;     MyRec[ Bottom ] = 8; }

A struct with differents types :

Code:
const MAX_CLIENTS  = 32; enum PlayerData {     bool:IsAlive,     Float:TotalTime,     UserName[ 32 ],     Health,     Mood:CurrentMood }; new PData[ MAX_CLIENTS + 1 ][ PlayerData ]; public MyFunction2 ( const Player ) {     new Name[ 32 ];     get_user_name( Player, Name, 31 );         PData[ Player ][ IsAlive ] = true;     PData[ Player ][ TotalTime ] = _:100.5;     PData[ Player ][ Health ] = 50;     PData[ Player ][ CurrentMood ] = _:ANNOYED;     copy( PData[ Player ][ UserName ], 31, Name ); }

I've used _: to remove the tag since PData has no tag otherwise you will get a tag mismatch.

So, it works for you because it's a struct of float sub-variables. Since all are float you can tag the var as float too like you have done and then no need to detag when you set a float value.

You can get more informations in the Pawn guide ( .pdf ) you can found on the wiki.
__________________
Arkshine is offline
ehha
SourceMod Donor
Join Date: Apr 2006
Location: Sibiu
Old 11-22-2009 , 11:43   Re: float double array - tag mismatch
Reply With Quote #9

Now I understand, thanks again Arkshine!
__________________
ehha is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 11-22-2009 , 13:31   Re: float double array - tag mismatch
Reply With Quote #10

Quote:
Originally Posted by ehha View Post
Thanks
But I don't understand why it worked, the items from enum should be the 2nd index for the double array, the index should be integer, right?
The tag of the enum values don't need to be float. The tag of the index would never alter to the tag of the variable. I already explained why you had tag mistach in your first code somehow I'm not sure whether you understood it or not.
You are saying the index should be an integer. I don't quite get what are you meaning with an integer. If you are meaning that the index can't be tagged you are wrong.

Quote:
Originally Posted by Arkshine View Post
It works because the tag output was not a float and before posting something I test always.
The output is always the tag the variable is and in this case float. I already said the tag of the index would never alter the tag of the variable.

Last edited by SnoW; 11-22-2009 at 13:35.
SnoW is offline
Send a message via MSN to SnoW
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 23:41.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode