AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [fw_TakeDamage] Incredible Numbers ! (https://forums.alliedmods.net/showthread.php?t=188276)

MPKiller545 06-24-2012 12:24

[fw_TakeDamage] Incredible Numbers !
 
Hi there !

I have a problem with my code. I wanted to make an ability that 50% of your damage absorbs to your health. (100 damage = 50 additional health)

PHP Code:

public fwTakeDamage(victiminflictorattackerFloat:damage)
{
        if(
siekiera[attacker] == 1)
    {
        
set_user_health(attacker, (get_user_health(attacker) + damage/2))
        
        if(
get_user_health(attacker) > 100)
        
set_user_health(attacker,100)
        
        
set_hudmessage(25500, -1.0, -1.006.012.0)
        
show_hudmessage(attacker"Wartosc leczenia: %i"damage/2)
        return 
HAM_HANDLED
    


The problem is, that message "Wartosc leczenia:" shows me the number like 12471329 when I shoot someone, and I heal with that value. But when I make an ability (for example: You have 30% that you will attack with double damage), It works fine!

Kidev 06-24-2012 12:27

Re: [fw_TakeDamage] Incredible Numbers !
 
'damage' is a float, and not an integer.

MPKiller545 06-24-2012 12:28

Re: [fw_TakeDamage] Incredible Numbers !
 
So, how can I transfer a float to an integer?

I have checked that deleting 'Float:' before damage nothing changes.

Bugsy 06-24-2012 13:07

Re: [fw_TakeDamage] Incredible Numbers !
 
Quote:

Originally Posted by MPKiller545 (Post 1735221)
So, how can I transfer a float to an integer?

I have checked that deleting 'Float:' before damage nothing changes.

floatround()

MPKiller545 06-24-2012 13:43

Re: [fw_TakeDamage] Incredible Numbers !
 
Thank You ; ]


All times are GMT -4. The time now is 06:13.

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