AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Verify online users. (https://forums.alliedmods.net/showthread.php?t=139880)

killergirl 10-06-2010 11:47

Verify online users.
 
I need a little help to my script. I don't know is there exist a command to check if there are online users like:

PHP Code:

if(!is_there_online_users(){
execute
}
else{
execute this



Mxnn 10-06-2010 12:16

Re: Verify online users.
 
With get_players you can do that.get_players()
If second parameter (&num) is 0, there are nor players in the server
Also, function is_user_connected() return if the user is connected or not.

hleV 10-06-2010 12:26

Re: Verify online users.
 
PHP Code:

/* Returns number of players put in server. 
* If flag is set then also connecting are counted. */
native get_playersnum(flag=0); 


killergirl 10-06-2010 12:29

Re: Verify online users.
 
Thank you for fast reply. I solved the problem.

(I have a war server and I want to make additional scripts, to moderate the game if there is no admins online.)

I have a second question about "maximum team score". So is there 2 players, one CT and one T, and somebody reach the maximum score allowed, suddenly both get's a team switch.

Eg. T reach 10 allowed score and he will be changed to CT, and the CT player changed to T, after the switch the game will be restarted.

Any ideas?

GXLZPGX 10-06-2010 14:25

Re: Verify online users.
 
Quote:

Originally Posted by killergirl (Post 1317086)
Thank you for fast reply. I solved the problem.

(I have a war server and I want to make additional scripts, to moderate the game if there is no admins online.)

I have a second question about "maximum team score". So is there 2 players, one CT and one T, and somebody reach the maximum score allowed, suddenly both get's a team switch.

Eg. T reach 10 allowed score and he will be changed to CT, and the CT player changed to T, after the switch the game will be restarted.

Any ideas?

Look up the DeathMsg event.

PHP Code:

new t_Score;
public 
deathmsgevent()
{
     new 
iKiller read_data(1)
     
     if( 
get_user_team(iKiller) == )
     {
          
t_Score++

          if( 
t_Score == 10 )
          {
               
//end the round the way that best fits you
          
}
     }


use get_user_team(iKiller) == 2 to retrieve CT's, and increase a variable the same way. Hope you understand.

killergirl 10-06-2010 15:20

Re: Verify online users.
 
PHP Code:

#include <amxmodx>
#include <cstrike>

new t_Score;
new 
ct_Score;

public 
plugin_init(){
    
register_plugin("CT T Switch""1.0""Author")
    
    
register_event("DeathMsg""deathmsgevent""a")
}

public 
deathmsgevent(){
    
    new 
iKiller read_data(1)
    new 
iKillertwo read_data(1)
    
    if( 
get_user_team(iKiller) == )
    {
        
t_Score++
        
        if( 
t_Score == 10 )
        {
            if(
get_user_team(iKiller) == CS_TEAM_T){
                
cs_set_user_team(iKiller,CS_TEAM_CT)
                
cs_set_user_team(iKillertwo,CS_TEAM_T)
            }
            else{
                
client_print(0print_chat"Something is wrong! TERRORIST")
            }
        }
        else{
            return 
PLUGIN_CONTINUE;
        }
    }
    if( 
get_user_team(iKillertwo) == )
    {
        
ct_Score++
        
        if( 
ct_Score == 10 )
        {
            if(
get_user_team(iKillertwo) == CS_TEAM_CT){
                
cs_set_user_team(iKiller,CS_TEAM_CT)
                
cs_set_user_team(iKillertwo,CS_TEAM_T)
            }
            else{
                
client_print(0print_chat"Something is wrong! CT")
            }
        }
        else{
            return 
PLUGIN_CONTINUE;
        }
    }
    return 
PLUGIN_CONTINUE;


I don't know is this ok, or maybe I need to change here?
PHP Code:

###
if(get_user_team(iKiller) == CS_TEAM_T)
###
if(get_user_team(iKillertwo) == CS_TEAM_CT)
### 

with:
PHP Code:

###
if(get_user_team(iKiller) == 1)
###
if(get_user_team(iKillertwo) == 1)
### 


hleV 10-06-2010 15:33

Re: Verify online users.
 
Use cs_get_user_team() if it's for CS. And you're retrieving same players' teams twice for unknown reason.

GXLZPGX 10-06-2010 15:34

Re: Verify online users.
 
Quote:

Originally Posted by killergirl (Post 1317229)
PHP Code:

#include <amxmodx>
#include <cstrike>

new t_Score;
new 
ct_Score;

public 
plugin_init(){
    
register_plugin("CT T Switch""1.0""Author")
    
    
register_event("DeathMsg""deathmsgevent""a")
}

public 
deathmsgevent(){
    
    new 
iKiller read_data(1)
    new 
iKillertwo read_data(1)
    
    if( 
get_user_team(iKiller) == )
    {
        
t_Score++
        
        if( 
t_Score == 10 )
        {
            if(
get_user_team(iKiller) == CS_TEAM_T){
                
cs_set_user_team(iKiller,CS_TEAM_CT)
                
cs_set_user_team(iKillertwo,CS_TEAM_T)
            }
            else{
                
client_print(0print_chat"Something is wrong! TERRORIST")
            }
        }
        else{
            return 
PLUGIN_CONTINUE;
        }
    }
    if( 
get_user_team(iKillertwo) == )
    {
        
ct_Score++
        
        if( 
ct_Score == 10 )
        {
            if(
get_user_team(iKillertwo) == CS_TEAM_CT){
                
cs_set_user_team(iKiller,CS_TEAM_CT)
                
cs_set_user_team(iKillertwo,CS_TEAM_T)
            }
            else{
                
client_print(0print_chat"Something is wrong! CT")
            }
        }
        else{
            return 
PLUGIN_CONTINUE;
        }
    }
    return 
PLUGIN_CONTINUE;


I don't know is this ok, or maybe I need to change here?
PHP Code:

###
if(get_user_team(iKiller) == CS_TEAM_T)
###
if(get_user_team(iKillertwo) == CS_TEAM_CT)
### 

with:
PHP Code:

###
if(get_user_team(iKiller) == 1)
###
if(get_user_team(iKillertwo) == 1)
### 


You only need one iKiller. It will get a new killer every time, don't worry.

To get the victim, use something like

new iVictim = read_data(2)

killergirl 10-06-2010 15:51

Re: Verify online users.
 
PHP Code:

#include <amxmodx>
#include <cstrike>

new t_Score

public plugin_init(){
    
register_plugin("CT T Switch""1.0""Author")
    
    
register_event("DeathMsg""deathmsgevent""a")
}

public 
deathmsgevent(){
    
    new 
iKiller read_data(1)
    new 
iVictim read_data(2
    
    if( 
get_user_team(iKiller) == )
    {
        
t_Score++
        
        if( 
t_Score == 10 )
        {
            if(
get_user_team(iKiller) == 1){
                
cs_set_user_team(iKiller,CS_TEAM_CT)
                
cs_set_user_team(iVictim,CS_TEAM_T)
            }
            else{
                
client_print(0print_chat"Something is wrong!")
            }
        }
        else{
            return 
PLUGIN_CONTINUE;
        }
    }
    return 
PLUGIN_CONTINUE;


I'm so stupid, I can't understand what are you guys talking about :cry:

GXLZPGX 10-06-2010 15:54

Re: Verify online users.
 
Quote:

Originally Posted by killergirl (Post 1317250)
PHP Code:

#include <amxmodx>
#include <cstrike>

new t_Score

public plugin_init(){
    
register_plugin("CT T Switch""1.0""Author")
    
    
register_event("DeathMsg""deathmsgevent""a")
}

public 
deathmsgevent(){
    
    new 
iKiller read_data(1)
    new 
iVictim read_data(2
    
    if( 
get_user_team(iKiller) == )
    {
        
t_Score++
        
        if( 
t_Score == 10 )
        {
            if(
get_user_team(iKiller) == 1){
                
cs_set_user_team(iKiller,CS_TEAM_CT)
                
cs_set_user_team(iVictim,CS_TEAM_T)
            }
            else{
                
client_print(0print_chat"Something is wrong!")
            }
        }
        else{
            return 
PLUGIN_CONTINUE;
        }
    }
    return 
PLUGIN_CONTINUE;


I'm so stupid, I can't understand what are you guys talking about :cry:

Why are you retrieving the killers team twice?


All times are GMT -4. The time now is 10:28.

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