Raised This Month: $ Target: $400
 0% 

enum & float double array - tag mismatch


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
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 #1

_: 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
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 13:42.


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