Raised This Month: $ Target: $400
 0% 

Help : int <-> float conversion ?!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
sappounet
Junior Member
Join Date: Jan 2009
Old 01-23-2009 , 20:35   Help : int <-> float conversion ?!
Reply With Quote #1

Hello,

I'm facing a stupid problem ...

I'm creating a program that allows players to get all weapon ammo free.

To do that, i check when they can by (between the respawn and the end of buytime) : freezetime + buytime

So i did that :

Code:
new mp_buytime;
new mp_freezetime;

mp_buytime=get_cvar_num("mp_buytime");  // 0.25
mp_freezetime=get_cvar_num("mp_freezetime");   // 10
I want to know the total duration in second.

Since buytime is in minutes, i did that to get in seconds :

Code:
new buytime_total;
buytime_total=(mp_buytime*60)+mp_freezetime;
When i try to use the buytime_total var, it's not set to the right value (it's not (0.25*60)+10)

Both vars are float ... and i'm bored by float !

So the question is :

Is there an easy way to convert between float and int ?

I'm only using <amxmodx> and <cstrike> includes, and i would like as much as possible to not use other files.

Thank you for your help.
sappounet is offline
Drak
Veteran Member
Join Date: Jul 2005
Old 01-23-2009 , 20:38   Re: Help : int <-> float conversion ?!
Reply With Quote #2

floatround() ?
float() ?
__________________
Oh yeah
Drak is offline
Send a message via MSN to Drak
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 01-23-2009 , 22:02   Re: Help : int <-> float conversion ?!
Reply With Quote #3

This is how you would do it with floats.
Also, you should use pcvars.

Code:
new mp_buytime; new mp_freezetime; public plugin_init() {     mp_buytime = get_cvar_pointer("mp_buytime");     mp_freezetime = get_cvar_pointer("mp_freezetime"); }
Code:
new Float:buytime_total = get_pcvar_float(mp_buytime) * 60.0 + get_pcvar_float(mp_freezetime);
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 01-24-2009 , 05:13   Re: Help : int <-> float conversion ?!
Reply With Quote #4

Quote:
Originally Posted by Exolent[jNr] View Post
Also, you should use pcvars.
Also, you should read a Pawn tutorial.
SnoW is offline
Send a message via MSN to SnoW
sappounet
Junior Member
Join Date: Jan 2009
Old 01-24-2009 , 09:22   Re: Help : int <-> float conversion ?!
Reply With Quote #5

Thanks for your answers !

I got another question :

For server performance, is it better to have 1 big plugin/file or many small ?

Thanks
sappounet is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 01-24-2009 , 11:13   Re: Help : int <-> float conversion ?!
Reply With Quote #6

Quote:
Originally Posted by sappounet View Post
Thanks for your answers !

I got another question :

For server performance, is it better to have 1 big plugin/file or many small ?

Thanks
We are going out of topic here aren't we? Anyway, one big. Though it's so much easier to handle plugins if they are separately.
SnoW is offline
Send a message via MSN to SnoW
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 01-25-2009 , 14:53   Re: Help : int <-> float conversion ?!
Reply With Quote #7

I know that, I agree that, and I said that(at least meant that). But what a hey, there is pretty much people who don't understand anything I'm saying most of the time. Btw, if the part what was wrong, was that I didn't mention how much it will take effect or in what cases, then let's just leave it over, I was just saying which is better. (For server performance)
SnoW is offline
Send a message via MSN to SnoW
Reply


Thread Tools
Display Modes

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 01:40.


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