Raised This Month: $ Target: $400
 0% 

how to copy a float to a float inside enum ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Owyn
Veteran Member
Join Date: Nov 2007
Old 11-17-2012 , 04:57   how to copy a float to a float inside enum ?
Reply With Quote #1

PHP Code:
enum _:PosData
{
    
Float:bd_pos[3],
    
Float:bd_angles[3]
};

public 
init()
{
    new 
TempData[PosData];
    new 
Float:origin[3], Float:angles[3];
    
TempData[bd_pos] = origin// tag mismatch error
    
TempData[bd_pos][0] = origin[0]; // must be an array error

for strings I used copy() but what can I use for floats?

edit: I probably figured out i need to delcare TempData as a Float, is it because TempData only consists of Floats? if it consisted of a float and an integer I would need to declare it as usual without Float type?
__________________
☜ Free Mozy ☂backup\҉sync user
Quote:
Американский форум - Задаёшь вопрос, потом тебе отвечают.
Израильский форум - Задаёшь вопрос, потом тебе задают вопрос.
Русский форум - Задаёшь вопрос, потом тебе долго рассказывают, какой ты мудак.

Last edited by Owyn; 11-17-2012 at 05:14.
Owyn is offline
Send a message via ICQ to Owyn
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 11-17-2012 , 05:43   Re: how to copy a float to a float inside enum ?
Reply With Quote #2

Quote:
is it because TempData only consists of Floats
It's because your members (bd_*) are floats and TempData would be a float too, same tag, no error.
It's fine to do it like that, if you have only floats as members.

Quote:
if it consisted of a float and an integer I would need to declare it as usual without Float type
In case of others type then float, you have to cast the value.

new TempData[PosData];
new Float:origin[3];

TempData[bd_pos] = origin;

In this example, TempData is untagged, while origin is tagged with Float. That's why you have an error.
To remove the error, you have to untag origin, by doing either "_:origin" or "any:origin".
As note, you have only an error with strong tag (started by an upper-case letter). If origin was using a weak tag (started by an lower-case letter), the compiler casts implicitly the value.
__________________

Last edited by Arkshine; 11-17-2012 at 05:43.
Arkshine is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-17-2012 , 06:11   Re: how to copy a float to a float inside enum ?
Reply With Quote #3

Also, copy the 3 floats (3 vectors coords) 1 by 1.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 11-17-2012 , 06:22   Re: how to copy a float to a float inside enum ?
Reply With Quote #4

No need and the problem would be still here.
__________________

Last edited by Arkshine; 11-17-2012 at 06:24.
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 07:31.


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