Raised This Month: $ Target: $400
 0% 

[help]how to detect if user is las on hes team?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
2reason2kill
Senior Member
Join Date: Feb 2011
Old 06-14-2011 , 13:29   [help]how to detect if user is las on hes team?
Reply With Quote #1

How can i Detect if the user is last in his team?
2reason2kill is offline
Devil259
Veteran Member
Join Date: Dec 2009
Location: France (59)
Old 06-14-2011 , 13:32   Re: [help]how to detect if user is las on hes team?
Reply With Quote #2

Example for terrorist :

Code:
new playersT[ 32 ] , num , i , tCount get_players( playersT , num , "aech" , "TERRORIST" ) for( i = 0; i < num; i++ ) {      tCount++ } if( tCount == 1 ) {      // do something }

That should works.
__________________
You can do anything you set your mind to, man.


Last edited by Devil259; 12-06-2011 at 06:26.
Devil259 is offline
2reason2kill
Senior Member
Join Date: Feb 2011
Old 06-14-2011 , 14:04   Re: [help]how to detect if user is las on hes team?
Reply With Quote #3

Quote:
Originally Posted by Devil259 View Post
Example for terrorist :

Code:
new playersT[ 32 ] , num , i , tCount get_players( playersT , num , "ach" , "TERRORIST" ) for( i = 0; i < num; i++ ) { tCount++ } if( tCount == 1 ) { // do something }


That should works.


CAn i do it like


PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <cstrike>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
}

public 
Wow()
{
    new 
playersT32 ] , num tCount
    
new name get_user_name
    get_players
playersT num "ach" "TERRORIST" )
    for( 
0numi++ )
    {
    
tCount++
    }

    if( 
tCount == )
    {
    
client_print(0print_chat,"%s Is the last Vampire!",name)
    }
}

public 
Woo()
{
    new 
playersCT32 ] , num ,ctCount
    
new namee get_user_name
    get_players
(playersCT num "ach" "COUNTER-TERRORST")
    for(
0numi++ )
    {
        
ctCount++
    }
    
    if(
ctCount == )
    }
    
client_print(0print_chat,"%s Is The last humen Eat HIM!",namee)
    } 

Last edited by 2reason2kill; 06-14-2011 at 14:10. Reason: spelled do wroong-.-
2reason2kill is offline
Devil259
Veteran Member
Join Date: Dec 2009
Location: France (59)
Old 06-14-2011 , 14:56   Re: [help]how to detect if user is las on hes team?
Reply With Quote #4

1. It isn't COUNTER-TERRORIST but CT (i think).

2. To get the player's name, you can do :

Code:
new szName[ 32 ] get_user_name( id , szName , charsmax( szName ) )
__________________
You can do anything you set your mind to, man.

Devil259 is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-14-2011 , 15:08   Re: [help]how to detect if user is las on hes team?
Reply With Quote #5

Code:
stock bool:IsLastInTeam( iPlayer ) {     new szTeam[ 16 ];     get_user_team( iPlayer, szTeam, charsmax( szTeam ) );         new iPlayers[ 32 ], iNum;     get_players( iPlayers, iNum, "ae", szTeam );         return ( iNum == 1 && iPlayers[ 0 ] == iPlayer ); }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
2reason2kill
Senior Member
Join Date: Feb 2011
Old 06-14-2011 , 15:11   Re: [help]how to detect if user is las on hes team?
Reply With Quote #6

Quote:
Originally Posted by Exolent[jNr] View Post
Code:
stock bool:IsLastInTeam( iPlayer ) { new szTeam[ 16 ]; get_user_team( iPlayer, szTeam, charsmax( szTeam ) ); new iPlayers[ 32 ], iNum; get_players( iPlayers, iNum, "ae", szTeam ); return ( iNum == 1 && iPlayers[ 0 ] == iPlayer ); }
I didnt understand ur way Exolent
2reason2kill is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-14-2011 , 15:16   Re: [help]how to detect if user is las on hes team?
Reply With Quote #7

It's a simple function to use.

Code:
if( IsLastInTeam( iPlayer ) ) {     // iPlayer is last in the team }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
2reason2kill
Senior Member
Join Date: Feb 2011
Old 06-14-2011 , 16:54   Re: [help]how to detect if user is las on hes team?
Reply With Quote #8

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
}

public 
Wow()
{
    new 
playersT32 ] , num tCount
    
new szName32 get_user_nameid szName charsmaxszName ) );
    
get_playersplayersT num "ach" "TERRORIST" )
    for( 
0numi++ )
    {
    
tCount++
    }

    if( 
tCount == )
    {
    
client_print(0print_chat,"%s Is the last Vampire!",szName)
    }
}

public 
Woo()
{
    new 
playersCT32 ] , num ,ctCount
    
new szName32 get_user_nameid szName charsmaxszName ) )
    
get_players(playersCT num "ach" "CT")
    for(
0numi++ )
    {
        
ctCount++
    }
    
    if(
ctCount == )
    }
    
client_print(0print_chat,"%s Is The last humen Eat HIM!",szName)
    } 

Code:
Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c) 1997-2006 ITB CompuPhase, AMX Mod X Team

Error: Expected token: ";", but found "-identifier-" on line 20
Error: Undefined symbol "id" on line 20
Warning: Expression has no effect on line 20
Warning: Expression has no effect on line 20
Error: Expected token: ";", but found ")" on line 20
Error: Too many error messages on one line on line 20

Compilation aborted.
4 Errors.
Could not locate output file C:\Program\AMX Mod X\amxxstudio\Untitled.amx (compile failed).
2reason2kill is offline
Devil259
Veteran Member
Join Date: Dec 2009
Location: France (59)
Old 06-14-2011 , 17:01   Re: [help]how to detect if user is las on hes team?
Reply With Quote #9

Code:
public function( id ) {      if( IsLastInTeam( id ) )      {           // do something      } } stock bool:IsLastInTeam( iPlayer ) {      new szTeam[ 16 ];      get_user_team( iPlayer, szTeam, charsmax( szTeam ) );          new iPlayers[ 32 ], iNum;      get_players( iPlayers, iNum, "ae", szTeam );          return ( iNum == 1 && iPlayers[ 0 ] == iPlayer ); }
__________________
You can do anything you set your mind to, man.

Devil259 is offline
2reason2kill
Senior Member
Join Date: Feb 2011
Old 06-15-2011 , 03:00   Re: [help]how to detect if user is las on hes team?
Reply With Quote #10

Quote:
Originally Posted by Devil259 View Post
Code:
public function( id ) { if( IsLastInTeam( id ) ) { // do something } } stock bool:IsLastInTeam( iPlayer ) { new szTeam[ 16 ]; get_user_team( iPlayer, szTeam, charsmax( szTeam ) ); new iPlayers[ 32 ], iNum; get_players( iPlayers, iNum, "ae", szTeam ); return ( iNum == 1 && iPlayers[ 0 ] == iPlayer ); }

shouldn't this work?


PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <cstrike>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    

}

public function( 
id )
{
     if( 
IsLastInTeamid ) )
     {
         if(
is_user_alive(id))
     {
         if(
cs_get_user_team(id)  == CS_TEAM_CT)
        {
            
client_print(0print_chat,"")
        }
        else
        {
            if(
cs_get_user_team(id) == CS_TEAM_T)
            {
                
client_print(0,print_chat,"")
            }
     
     }
}
stock bool:IsLastInTeamiPlayer )
{
     new 
szTeam16 ];
     
get_user_teamiPlayerszTeamcharsmaxszTeam ) );
    
     new 
iPlayers32 ], iNum;
     
get_playersiPlayersiNum"ae"szTeam );
    
     return ( 
iNum == && iPlayers] == iPlayer ); 

Code:
Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c) 1997-2006 ITB CompuPhase, AMX Mod X Team

Error: Undefined symbol "IsLastInTeam" on line 20
Warning: Loose indentation on line 37
Error: Invalid expression, assumed zero on line 37
Warning: Label name "bool" shadows tag name on line 37
Error: Undefined symbol "IsLastInTeam" on line 37
Error: Undefined symbol "iPlayer" on line 40
Warning: Expression has no effect on line 40
Warning: Expression has no effect on line 40
Error: Expected token: ";", but found ")" on line 40
Error: Invalid expression, assumed zero on line 40
Error: Too many error messages on one line on line 40

Compilation aborted.
7 Errors.
Could not locate output file C:\Documents and Settings\reason\Skrivbord\sdasda.amx (compile failed).
2reason2kill 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 09:16.


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