Raised This Month: $32 Target: $400
 8% 

Solved Float caculation Error


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 10-24-2018 , 15:11   Float caculation Error
Reply With Quote #1

PHP Code:
new Float:g_PlayerZombieInfo[33][2]
...

public 
TurnZombie(id)
{
    ...
    new 
Float:ZbStunZbStun ArrayGetCell(ZombieStunResistg_CurrentClass[id]) //Registered as 1.2
    
new Float:ZbKnockbackZbKnockback ArrayGetCell(ZombieKnockbackg_CurrentClass[id])

    
g_PlayerZombieInfo[id][INFO_STUN] = ZbStun 
    g_PlayerZombieInfo
[id][INFO_KB] = ZbKnockback
    
...
}

public 
TakeDamagePost(victiminflictorattackerFloat:fDamageDamagetype)
{

    
painshock get_pdata_float(victimOFFSET_PAINSHOCK)
    
client_print(0print_chat"(DEBUG) Painshock Pre Post: %f %f"painshockg_PlayerZombieInfo[victim][INFO_STUN]) //Printed: (DEBUG) Painshock Pre Post: 0.500000 1.20000
    
static Float:new_painshock
    
new_painshock painshock g_PlayerZombieInfo[victim][INFO_STUN]
    
client_print(0print_chat"(DEBUG) Painshock Post Post: %f"new_painshock//Printed: (DEBUG) Painshock Post Post: 533515456.00000
    
set_pdata_float(victimOFFSET_PAINSHOCKpainshock)
}

puclic Native_Register_Class()
{
    ...
    
ArrayPushCell(ZombieStunResistget_param_f(6))
    ...

I tried to replace g_PlayerZombieInfo[victim][INFO_STUN] with 1.2 ajd the calculation give correct answer: 0.6
I don't know what I did wrong

Solved
PHP Code:
puclic Native_Register_Class()
{
    ...
    
ArrayPushCell(ZombieStunResistget_param_f(6))
    ...

=>

PHP Code:
puclic Native_Register_Class()
{
    new 
Float:StunStun get_param_f(6)
    ...
    
ArrayPushCell(ZombieStunResistStun)
    ...

__________________
My plugin:

Last edited by Celena Luna; 10-25-2018 at 13:49.
Celena Luna is offline
hitD
Junior Member
Join Date: May 2017
Location: Lithuania
Old 10-24-2018 , 17:48   Re: Float caculation Error
Reply With Quote #2

Why then don't do this?
new_painshock = g_PlayerZombieInfo[victim][INFO_STUN]

As u multiply by 0.5 then u get this answer.
hitD is offline
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 10-24-2018 , 22:57   Re: Float caculation Error
Reply With Quote #3

Quote:
Originally Posted by hitD View Post
Why then don't do this?
new_painshock = g_PlayerZombieInfo[victim][INFO_STUN]

As u multiply by 0.5 then u get this answer.
Because not all weapon/situation it is 0.5.
Ex: With glock and usp, it is 0.5 but with AK hit body, it only 0.8~0.9 (already rounded)
__________________
My plugin:
Celena Luna 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 17:28.


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