AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to chek if player is connected and is in CT or T team? (https://forums.alliedmods.net/showthread.php?t=164555)

^SmileY 08-12-2011 23:01

How to chek if player is connected and is in CT or T team?
 
How to chek if player is connected and is in CT or T team?

PHP Code:

public CheckClientConnectedTeam(Client,Client2)
{
    if(
is_user_connected(Client) && get_user_team(Client) == CS_TEAM_T && is_user_connected(Client2) && get_user_team(Client2) == CS_TEAM_CT)
    {
        
/*DO SOMETHING*/
        
client_print(0,3,"OK, ALL CLIENTS IS NOW CONNECTED, CONTINUE");
        return 
PLUGIN_HANDLED;
    }
    else
    {
        
/*DO SOMETHING ELSE*/
        
client_print(0,3,"LOL, WAIT FOR CLIENT CONNECT");
        return 
PLUGIN_HANDLED;
    }
    return 
PLUGIN_HANDLED;


HTML Code:

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

Warning: Tag mismatch on line 22
Warning: Tag mismatch on line 22
Header size:            244 bytes
Code size:              680 bytes
Data size:              252 bytes
Stack/heap size:      16384 bytes; estimated max. usage=780 cells (3120 bytes)
Total requirements:  17560 bytes

2 Warnings.
Done.


sader 08-12-2011 23:09

Re: How to chek if player is connected and is in CT or T team?
 
Try this way
PHP Code:

#include <cstrike> 
 
public client_spawn(this)
{  
  if(
cs_get_user_team(this) == CS_TEAM_CT)
  {
 
  }
  else
  {
 
 
  }
 
  return 
PLUGIN_HANDLED;



^SmileY 08-12-2011 23:15

Re: How to chek if player is connected and is in CT or T team?
 
Ops, i edited my funcion, small fail:

is not get_user_team

is cs_get_user_team

PHP Code:

public CheckClientConnectedTeam(Client,Client2)
{
    if((
is_user_connected(Client) && cs_get_user_team(Client) == CS_TEAM_T) && (is_user_connected(Client2) && cs_get_user_team(Client2) == CS_TEAM_CT))
    {
        
client_print(0,3,"OK, ALL CLIENTS IS NOW CONNECTED");
        return 
PLUGIN_HANDLED;
    }
    else
    {
        
/*DO SOMETHING ELSE*/
        
client_print(0,3,"LOL, WAIT FOR CLIENT CONNECT");
        return 
PLUGIN_HANDLED;
    }
    return 
PLUGIN_HANDLED;


Not errors, but is correct way?

Exolent[jNr] 08-12-2011 23:22

Re: How to chek if player is connected and is in CT or T team?
 
Yes.

sader 08-12-2011 23:23

Re: How to chek if player is connected and is in CT or T team?
 
Well you asked how to check if player is connected and on what team he is.
Yes from your code prototype I see you compare two players, but what exactly you trying to achieve?

^SmileY 08-12-2011 23:25

Re: How to chek if player is connected and is in CT or T team?
 
I try to check if 2 players is connected, and player A is in TR or CT team, and player B is in TR or CT team.

PHP Code:

public CheckCaptainJoin(NextCaptainMenu)
{
    if((
is_user_connected(RandomPlayer1) && (cs_get_user_team(RandomPlayer1) == CS_TEAM_T || cs_get_user_team(RandomPlayer1) == CS_TEAM_CT)) && (is_user_connected(RandomPlayer2) && (cs_get_user_team(RandomPlayer2) == CS_TEAM_T || cs_get_user_team(RandomPlayer2) == CS_TEAM_CT)))
    {
        
set_task(2.0,"captain_menu",NextCaptainMenu)
    }
    else
    {
        
set_task(5.0,"CheckCaptainJoin",NextCaptainMenu)
    }



Exolent[jNr] 08-12-2011 23:29

Re: How to chek if player is connected and is in CT or T team?
 
Opposite teams?

^SmileY 08-12-2011 23:31

Re: How to chek if player is connected and is in CT or T team?
 
Its capitains in team :)

But, capitain 1 or 2 its connected to server

sader 08-12-2011 23:34

Re: How to chek if player is connected and is in CT or T team?
 
But you must strore players ID somewhere,somehow.
You can loop through players and do some checks

PHP Code:

for(new i=1i<=32i++)
{
  if(
is_user_alive(i))
  {
  }



Maybe you need somthing like this? How you know if player is Captain?
PHP Code:

new CT_captain_foundT_captain_found;
for(new 
i=1i<=32i++)
{
  if(
is_user_alive(i))
  {
    if(
CT_captain_found == && cs_get_user_team(i) == CS_TEAM_CT && is captain)
    {
      
//somethings goes here
      
CT_captain_found 1
    }
    
    if(
T_captain_found == && cs_get_user_team(i) == CS_TEAM_T && is captain)
    {
      
//somethings goes here
      
T_captain_found 1
    }
  }



^SmileY 08-13-2011 00:03

Re: How to chek if player is connected and is in CT or T team?
 
Solved/


All times are GMT -4. The time now is 03:24.

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