AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved [edit] no kill zones to heal zones (https://forums.alliedmods.net/showthread.php?t=316772)

Meelo 06-09-2019 12:14

[edit] no kill zones to heal zones
 
2 Attachment(s)
Hello, im trying to edit this plugin but there is a problem i can't solve.. so i need to create zone and if someone enter in, it will heal him for 'x' hp.

i did change public player_damage and player_traceattack from original to:

Code:

public dmg()
{
        for(new i; i<g_iZonesNum; i++)
        {
                if(is_user_in_zone(i,i))
                {

                        set_user_health((i),get_user_health(i)+5)

                }
        }
}

and in plugin_init
set_task(1.0, "dmg", .flags="b")

the problem is - it works only for the first player on the map who will enter into created zone, i can't solve it by myself :/

OciXCrom 06-09-2019 12:25

Re: [edit] no kill zones to heal zones
 
i is a zone index, not a player index. I assume there's only one zone, so that's why it works only for the first player, because zone 0 = player 0, they have the same indexes.

You need to loop all players in addition to the zones loop, or assign a different task for each player or each zone, then do only one loop inside the function.

Meelo 06-09-2019 13:53

Re: [edit] no kill zones to heal zones
 
thanks, it's fine now :)


All times are GMT -4. The time now is 17:15.

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