Raised This Month: $ Target: $400
 0% 

New Thread. Warning report


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 05-18-2012 , 14:10   New Thread. Warning report
Reply With Quote #1

Quote:
Originally Posted by Liverwiz View Post
I didn't want to start a new thread for this question for its so short. This line gives me a "warning" on compile and i'm wondering why....

PHP Code:
#define LVL5 180        // Regular knife  RandomFloat(15, 75
#define LEVEL_INCREMENT 31    // Frags per level (after the defined levels 0-5)
new i_offset LVL5 - (LEVEL_INCREMENT*5

Also....is my math right? for use in....
Code:
new Float:calc =  (g_playerFrags[id] + i_offset) / LEVEL_INCREMENT
This is the warning...the quote didn't bring it over.
Quote:
Warning: Tag mismatch on line 857
Was told to make a new thread. here it is.
__________________
What an elegant solution to a problem that doesn't need solving....

Last edited by Liverwiz; 05-18-2012 at 14:14.
Liverwiz is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 05-18-2012 , 14:11   Re: New Thread. Warning report
Reply With Quote #2

It seems that everything has an integer value, but calc variable is a float.
__________________
<VeCo> is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 05-18-2012 , 14:13   Re: New Thread. Warning report
Reply With Quote #3

Quote:
Originally Posted by <VeCo> View Post
It seems that everything has an integer value, but calc variable is a float.
calc is just hte example of how i used i_offset. Wondering if my math is right.
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 05-18-2012 , 14:23   Re: New Thread. Warning report
Reply With Quote #4

new Float:calc = (Float:g_playerFlags[id] + i_offset) / LEVEL_INCREMENT

this should do it. Remeber, one value in your calculation has to be a floating number
__________________
Quote:
#define true ((rand() % 2)? true: false) //Happy debugging suckers
mottzi is offline
Send a message via MSN to mottzi
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 05-18-2012 , 14:25   Re: New Thread. Warning report
Reply With Quote #5

You can make one of these variables Float:, use float() native or add * 1.0.
__________________

Last edited by <VeCo>; 05-18-2012 at 14:26.
<VeCo> is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 05-18-2012 , 15:01   Re: New Thread. Warning report
Reply With Quote #6

Quote:
Originally Posted by mottzi View Post
new Float:calc = (Float:g_playerFlags[id] + i_offset) / LEVEL_INCREMENT

this should do it. Remeber, one value in your calculation has to be a floating number
Quote:
Originally Posted by <VeCo> View Post
You can make one of these variables Float:, use float() native or add * 1.0.
the warning is on the i_offset line.
The Float:calc is fine.
Reason: when you use a division operator it automatically requires your varible you're storing it to to be a float. Otherwise it will give an error or warning or whatever. I don't remember which....

new Float:i = 1 / 2
its accepted because you MUST be a float in order to have division within its calculations.
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 05-18-2012 , 14:28   Re: New Thread. Warning report
Reply With Quote #7

wouldn't the method I posted work as well?
__________________
Quote:
#define true ((rand() % 2)? true: false) //Happy debugging suckers
mottzi is offline
Send a message via MSN to mottzi
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 05-18-2012 , 14:32   Re: New Thread. Warning report
Reply With Quote #8

Quote:
Originally Posted by mottzi View Post
wouldn't the method I posted work as well?
Yes, it works too.
__________________

Last edited by <VeCo>; 05-18-2012 at 14:32.
<VeCo> is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 05-18-2012 , 16:49   Re: New Thread. Warning report
Reply With Quote #9

Quote:
Originally Posted by mottzi View Post
wouldn't the method I posted work as well?
No, cast an integer into Float completly change its value because it is interpreted a different way.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 05-18-2012 , 15:21   Re: New Thread. Warning report
Reply With Quote #10

Your problem was the Tag mismatch. When you have a Float variable and you equal it to something like
Float: myvar = (a + b) / c one of these (a, b or c) has to be a float in order to not have a tagmismatch. AFAIK from C++, when one variable is a float the whole term is converted into a float => no mismatch
__________________
Quote:
#define true ((rand() % 2)? true: false) //Happy debugging suckers

Last edited by mottzi; 05-18-2012 at 15:23.
mottzi is offline
Send a message via MSN to mottzi
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 00:29.


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