Raised This Month: $ Target: $400
 0% 

Check most HP


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dkmuniz
Senior Member
Join Date: Jun 2013
Old 11-05-2016 , 14:20   Check most HP
Reply With Quote #1

Hello, how i check what player have more hp in 2, and the player with less Hp die!

PHP Code:
if(GetAliveTeamCount(2) == 2)
            {
                
LoopClients(i)
                {
                    if(
IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == 2)
                    {
                        
//GetClientHealth(i);

                    
}
                }
            } 
Dkmuniz is offline
Djctavia
Junior Member
Join Date: Oct 2016
Old 11-05-2016 , 14:33   Re: Check most HP
Reply With Quote #2

it should look like this (Don't know if that work):

PHP Code:
int clientMaxHP 1;
int clientMinHP 1;

if(
GetAliveTeamCount(2) == 2
{
        for(
int i 1<= MaxClientsi++)
        {        
            if(
IsClientInGame(i) && IsPlayerAlive(i) && !IsFakeClient(i) && GetClientTeam(i) == 2// !IsFakeClient(i) For know if that is a bot
            
{
                if (
GetClientHealth(clientMaxHP) < GetClientHealth(i))
                {
                    
clientMaxHP i;
                }
                    
                if (
GetClientHealth(i) < GetClientHealth(clientMinHP))
                {
                    
clientMinHP i;
                }
            }
        }
        
SlapPlayer(clientMinHP100);

edit:

I change the code, cause init to "-1" will not know the client.

Last edited by Djctavia; 11-05-2016 at 14:38.
Djctavia is offline
Grey83
Veteran Member
Join Date: Dec 2014
Location: Ukraine
Old 11-06-2016 , 01:41   Re: Check most HP
Reply With Quote #3

try this code
PHP Code:
            static int bufferClient[2], bufferHP[2], num 0;
            if(
GetAliveTeamCount(2) == 2)
            {
                for (
int i 1MaxClientsi++)
                {
                    if(
IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == 2)
                    {
                        
bufferHP[num] = GetClientHealth(i);
                        
bufferClient[num] = i;
                        if(
num 0) break;
                        
num++;
                    }
                }

                if(
bufferHP[0] != bufferHP[1])
                {
                    static 
int target;
                    
SlapPlayer(bufferClient[(target bufferHP[0] < bufferHP[1] ? 1)], bufferHP[target]+1);
                }
                else 
// Both players have the same amount of HP
                
{
                    
SlapPlayer(bufferClient[GetRandomInt(01)], bufferHP+1);
                }
            } 
__________________

Last edited by Grey83; 11-06-2016 at 01:46.
Grey83 is offline
Dkmuniz
Senior Member
Join Date: Jun 2013
Old 11-06-2016 , 12:27   Re: Check most HP
Reply With Quote #4

Quote:
Originally Posted by Grey83 View Post
try this code
PHP Code:
            static int bufferClient[2], bufferHP[2], num 0;
            if(
GetAliveTeamCount(2) == 2)
            {
                for (
int i 1MaxClientsi++)
                {
                    if(
IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == 2)
                    {
                        
bufferHP[num] = GetClientHealth(i);
                        
bufferClient[num] = i;
                        if(
num 0) break;
                        
num++;
                    }
                }

                if(
bufferHP[0] != bufferHP[1])
                {
                    static 
int target;
                    
SlapPlayer(bufferClient[(target bufferHP[0] < bufferHP[1] ? 1)], bufferHP[target]+1);
                }
                else 
// Both players have the same amount of HP
                
{
                    
SlapPlayer(bufferClient[GetRandomInt(01)], bufferHP+1);
                }
            } 
error 033: array must be indexed (variable "bufferHP")

Line : SlapPlayer(bufferClient[GetRandomInt(0, 1)], bufferHP+1);
Dkmuniz is offline
Grey83
Veteran Member
Join Date: Dec 2014
Location: Ukraine
Old 11-06-2016 , 12:54   Re: Check most HP
Reply With Quote #5

Dkmuniz, change to
PHP Code:
            static int bufferClient[2], bufferHP[2], num 0;
            if(
GetAliveTeamCount(2) == 2)
            {
                for (
int i 1MaxClientsi++)
                {
                    if(
IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == 2)
                    {
                        
bufferHP[num] = GetClientHealth(i);
                        
bufferClient[num] = i;
                        if(
num 0) break;
                        
num++;
                    }
                }

                static 
int target;
                if(
bufferHP[0] != bufferHP[1]) target bufferHP[0] < bufferHP[1] ? 1;
                else 
target GetRandomInt(01); // Both players have the same amount of HP

                
SlapPlayer(bufferClient[target], bufferHP[target]+1);
            } 
__________________
Grey83 is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 11-07-2016 , 03:15   Re: Check most HP
Reply With Quote #6

Use CS_TEAM_T and _CT
__________________
Neuro Toxin is offline
Grey83
Veteran Member
Join Date: Dec 2014
Location: Ukraine
Old 11-07-2016 , 10:37   Re: Check most HP
Reply With Quote #7

Quote:
#define CS_TEAM_NONE 0 /**< No team yet. */
#define CS_TEAM_SPECTATOR 1 /**< Spectators. */
#define CS_TEAM_T 2 /**< Terrorists. */
#define CS_TEAM_CT 3 /**< Counter-Terrorists. */
cstrike
__________________

Last edited by Grey83; 11-07-2016 at 10:38.
Grey83 is offline
Dkmuniz
Senior Member
Join Date: Jun 2013
Old 11-09-2016 , 09:36   Re: Check most HP
Reply With Quote #8

Works, thanks
Dkmuniz 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 04:11.


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