AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   set_user_health (https://forums.alliedmods.net/showthread.php?t=189745)

GhostMan 07-10-2012 11:56

set_user_health
 
How to set users health to 100 + more 100 for every alive t? For e.g. if there's 5 alive terrorist, so +500 health

PHP Code:

set_user_health(id100+???) 


kramesa 07-10-2012 11:57

Re: set_user_health
 
set_user_health(id, 200)

lol

GhostMan 07-10-2012 12:12

Re: set_user_health
 
You didnt get it. Number of t's in server is dinamic, when there's 4 alive terrorist so it goes
PHP Code:

set_user_health(id100+400

when 5

PHP Code:

set_user_health(id100+500

I need to get that number after + in some variable

PHP Code:

new randomhealth

randomhealth 
= ????

set_user_health(id100 randomhealth


Aooka 07-10-2012 12:18

Re: set_user_health
 
This :
Code:
set_user_health( id , get_user_health + 100 );

Or like this :
Code:
#define HP 100 set_user_health( id , HP + 100 );

For random take a look at random_num( );

GhostMan 07-10-2012 13:25

Re: set_user_health
 
Na it's still not what i need.

More likely would be like this i guess

PHP Code:

new iPlayers[33]
new 
RandomHealth

get_players
iPlayersRandomHealth"aeh""TERRORIST" );

set_user_health(id100 RandomHealth 100

The "Random" number is not just random random, it depends on number of alive terrorists.

Veggetta 07-10-2012 14:29

Re: set_user_health
 
Just do this, it's the easiest way
PHP Code:

new HEALTH get_user_health 100// <-- Change the '100' to the number you want
//now set the user health
set_user_health(idHEALTH

EASY :D
This:
PHP Code:

new HEALTH get_user_health 

It will read the health the player has, than the '100' will give more additional health
But what you want is this:
PHP Code:

new TEAM cs_get_user_team(id) == CS_TEAM_T;
for(new 
132i++)
{
          if(
TEAM)
          {
                    new 
HEALTH get_user_health(id) * i;
                    
set_user_health(idHEALTH);
           }


And let's hope it works :D
Here's a full code:
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <hamsandwich>
#include <fun>

#define PLUGIN "GiveHealthTeam"
#define VERSION "1.0"
#define AUTHOR "*Vegetta*"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
RegisterHam(Ham_Spawn"player""GiveHealth"1);
}

public 
GiveHealth(id)
{
    new 
TEAM cs_get_user_team(id) == CS_TEAM_T;
    for(new 
132i++)
    {
        if(
TEAM)
        {
            new 
HEALTH get_user_health(id) * i;
            
set_user_health(idHEALTH);
        }
    }



Santaaa 07-10-2012 14:30

Re: set_user_health
 
PHP Code:

public function(id)
{
    new 
players[32], counttcount
    get_players
(playerscount"ae""TERRORIST")
    
    for (new 
i<get_maxplayers(); i++)
    {
        if (
get_user_team(i) == 1)
        {
            
tcount++
        }
    }
    
set_user_health(idtcount 100)



Exolent[jNr] 07-10-2012 14:41

Re: set_user_health
 
Nobody in this thread was correct except for OP.

Quote:

Originally Posted by GhostMan (Post 1747461)
Na it's still not what i need.

More likely would be like this i guess

PHP Code:

new iPlayers[33]
new 
RandomHealth

get_players
iPlayersRandomHealth"aeh""TERRORIST" );

set_user_health(id100 RandomHealth 100

The "Random" number is not just random random, it depends on number of alive terrorists.

That is the right code.

Santaaa 07-10-2012 15:07

Re: set_user_health
 
Quote:

Originally Posted by Exolent[jNr] (Post 1747499)
Nobody in this thread was correct except for OP.



That is the right code.


Mine was right too?

<VeCo> 07-10-2012 15:09

Re: set_user_health
 
Quote:

Originally Posted by Santaaa (Post 1747509)
Mine was right too?

get_players already saves the number of found players in the count variable. Your loop is useless.


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

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