Raised This Month: $ Target: $400
 0% 

float to int stock


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Jaylow
Junior Member
Join Date: Dec 2021
Old 04-09-2022 , 00:03   float to int stock
Reply With Quote #1

having issues using a stock int which has floats in it to get a value of player health

TempHealth is an Int, i am getting this error

SendProp m_healthBuffer type is not integer (1 != 0)

Code:
PlayerData[client].TempHealth = GetSurvivorTemporaryHealth(client);



stock int GetSurvivorTemporaryHealth(int client) 
{
    float fDecayRate = GetConVarFloat(FindConVar("pain_pills_decay_rate"));
    float fHealthBuffer = Float:GetEntProp(client, Prop_Send, "m_healthBuffer");
    float fHealthBufferTime = Float:GetEntProp(client, Prop_Send, "m_healthBufferTime");
    int iTempHp = RoundToCeil(fHealthBuffer - ((GetGameTime() - fHealthBufferTime) * fDecayRate)) - 1;
    return iTempHp > 0 ? iTempHp : 0;
}
Jaylow is offline
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 04-09-2022 , 07:06   Re: float to int stock
Reply With Quote #2

When I need a float I just add 0.0 to the value. You could try doing something like this:

PHP Code:
float fHealthBuffer GetEntProp(clientProp_Send"m_healthBuffer") + 0.0
PC Gamer is offline
cravenge
Veteran Member
Join Date: Nov 2015
Location: Chocolate Factory
Old 04-09-2022 , 09:21   Re: float to int stock
Reply With Quote #3

PHP Code:
float fHealthBuffer GetEntPropFloat(clientProp_Send"m_healthBuffer");
float fHealthBufferTime GetEntPropFloat(clientProp_Send"m_healthBufferTime"); 
cravenge is offline
xerox8521
Senior Member
Join Date: Sep 2011
Old 04-09-2022 , 09:41   Re: float to int stock
Reply With Quote #4

You can also convert an integer to a float using the float function.

But in this case you need to use GetEntPropFloat as mentioned above

PHP Code:
int myValue 5;
float myFloatValue float(myValue); 

Last edited by xerox8521; 04-09-2022 at 09:41.
xerox8521 is offline
Jaylow
Junior Member
Join Date: Dec 2021
Old 04-09-2022 , 20:09   Re: float to int stock
Reply With Quote #5

Quote:
Originally Posted by cravenge View Post
PHP Code:
float fHealthBuffer GetEntPropFloat(clientProp_Send"m_healthBuffer");
float fHealthBufferTime GetEntPropFloat(clientProp_Send"m_healthBufferTime"); 
this creates a tag mismatch
Jaylow is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 04-10-2022 , 00:26   Re: float to int stock
Reply With Quote #6

Quote:
Originally Posted by Jaylow View Post
this creates a tag mismatch
Are you sure? GetEntPropFloat() returns a float value and cravenge's example shows it being stored in a float variable. There shouldn't be any tag mismatches unless you're doing something different.
__________________
Psyk0tik is offline
EfeDursun125
Senior Member
Join Date: Feb 2019
Location: Turkey
Old 04-11-2022 , 03:17   Re: float to int stock
Reply With Quote #7

Try this.

RoundToNearest(floatValue)

or

RoundToFloor(floatValue)

EDIT: i mean you can try that int value instead of floats but i don't know it broke the code or something
__________________
CS 1.6 E-BOT (Best Bot For Zombie Plague): https://github.com/EfeDursun125/CS-EBOT

Last edited by EfeDursun125; 04-11-2022 at 03:21.
EfeDursun125 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 16:58.


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