AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [help]how to detect if user is las on hes team? (https://forums.alliedmods.net/showthread.php?t=159244)

2reason2kill 06-14-2011 13:29

[help]how to detect if user is las on hes team?
 
How can i Detect if the user is last in his team?

Devil259 06-14-2011 13:32

Re: [help]how to detect if user is las on hes team?
 
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.

2reason2kill 06-14-2011 14:04

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

Originally Posted by Devil259 (Post 1488196)
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)
    } 


Devil259 06-14-2011 14:56

Re: [help]how to detect if user is las on hes team?
 
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 ) )

Exolent[jNr] 06-14-2011 15:08

Re: [help]how to detect if user is las on hes team?
 
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 ); }

2reason2kill 06-14-2011 15:11

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

Originally Posted by Exolent[jNr] (Post 1488260)
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

Exolent[jNr] 06-14-2011 15:16

Re: [help]how to detect if user is las on hes team?
 
It's a simple function to use.

Code:
if( IsLastInTeam( iPlayer ) ) {     // iPlayer is last in the team }

2reason2kill 06-14-2011 16:54

Re: [help]how to detect if user is las on hes team?
 
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).


Devil259 06-14-2011 17:01

Re: [help]how to detect if user is las on hes team?
 
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 ); }

2reason2kill 06-15-2011 03:00

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

Originally Posted by Devil259 (Post 1488328)
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).



All times are GMT -4. The time now is 23:26.

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