Raised This Month: $ Target: $400
 0% 

set_user_health


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GhostMan
Senior Member
Join Date: Jun 2012
Old 07-10-2012 , 11:56   set_user_health
Reply With Quote #1

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+???) 

Last edited by GhostMan; 07-10-2012 at 11:56.
GhostMan is offline
kramesa
Veteran Member
Join Date: Feb 2011
Location: Brazil
Old 07-10-2012 , 11:57   Re: set_user_health
Reply With Quote #2

set_user_health(id, 200)

lol
__________________
kramesa is offline
GhostMan
Senior Member
Join Date: Jun 2012
Old 07-10-2012 , 12:12   Re: set_user_health
Reply With Quote #3

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

Last edited by GhostMan; 07-10-2012 at 12:15.
GhostMan is offline
Aooka
Veteran Member
Join Date: Aug 2011
Location: Villeurbanne
Old 07-10-2012 , 12:18   Re: set_user_health
Reply With Quote #4

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( );
__________________
Pawn ? Useless

Last edited by Aooka; 07-10-2012 at 12:19.
Aooka is offline
GhostMan
Senior Member
Join Date: Jun 2012
Old 07-10-2012 , 13:25   Re: set_user_health
Reply With Quote #5

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.

Last edited by GhostMan; 07-10-2012 at 13:26.
GhostMan is offline
Veggetta
Member
Join Date: Mar 2008
Location: Portugal
Old 07-10-2012 , 14:29   Re: set_user_health
Reply With Quote #6

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
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
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);
        }
    }


Last edited by Veggetta; 07-10-2012 at 14:41.
Veggetta is offline
Santaaa
BANNED
Join Date: May 2012
Old 07-10-2012 , 14:30   Re: set_user_health
Reply With Quote #7

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)


Last edited by Santaaa; 07-10-2012 at 15:06.
Santaaa is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 07-10-2012 , 14:41   Re: set_user_health
Reply With Quote #8

Nobody in this thread was correct except for OP.

Quote:
Originally Posted by GhostMan View Post
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.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Santaaa
BANNED
Join Date: May 2012
Old 07-10-2012 , 15:07   Re: set_user_health
Reply With Quote #9

Quote:
Originally Posted by Exolent[jNr] View Post
Nobody in this thread was correct except for OP.



That is the right code.

Mine was right too?
Santaaa is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 07-10-2012 , 15:09   Re: set_user_health
Reply With Quote #10

Quote:
Originally Posted by Santaaa View Post
Mine was right too?
get_players already saves the number of found players in the count variable. Your loop is useless.
__________________
<VeCo> 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 15:06.


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