AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   New Thread. Warning report (https://forums.alliedmods.net/showthread.php?t=185515)

Liverwiz 05-18-2012 14:10

New Thread. Warning report
 
Quote:

Originally Posted by Liverwiz (Post 1711523)
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.

<VeCo> 05-18-2012 14:11

Re: New Thread. Warning report
 
It seems that everything has an integer value, but calc variable is a float.

Liverwiz 05-18-2012 14:13

Re: New Thread. Warning report
 
Quote:

Originally Posted by <VeCo> (Post 1711545)
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.

mottzi 05-18-2012 14:23

Re: New Thread. Warning report
 
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

<VeCo> 05-18-2012 14:25

Re: New Thread. Warning report
 
You can make one of these variables Float:, use float() native or add * 1.0.

mottzi 05-18-2012 14:28

Re: New Thread. Warning report
 
wouldn't the method I posted work as well?

<VeCo> 05-18-2012 14:32

Re: New Thread. Warning report
 
Quote:

Originally Posted by mottzi (Post 1711556)
wouldn't the method I posted work as well?

Yes, it works too.

Liverwiz 05-18-2012 15:01

Re: New Thread. Warning report
 
Quote:

Originally Posted by mottzi (Post 1711551)
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> (Post 1711553)
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.

mottzi 05-18-2012 15:21

Re: New Thread. Warning report
 
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

Liverwiz 05-18-2012 16:12

Re: New Thread. Warning report
 
Quote:

Originally Posted by mottzi (Post 1711599)
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

The warning was NOT on that line.


All times are GMT -4. The time now is 00:29.

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