AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Get Lower Player Num (https://forums.alliedmods.net/showthread.php?t=140617)

TheKidz 10-14-2010 16:45

Get Lower Player Num
 
How to get the lower player num ? well, lets go to an example:
there is 5 cts, then next round there is 6, so i want to move this last one that goes to cts, and change to t.

i just wonder how to catch their playtime and then get if they are new or no.. .-.

Schwabba 10-14-2010 17:02

Re: Get Lower Player Num
 
PHP Code:

#include <amxmodx>
#include <cstrike>

new PLUGIN[]  = "Teamchanger"
new AUTHOR[]  = "Schwabba"
new VERSION[] = "1.0"

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
set_task(5.0,"CTcheck",0,_,_,"b")
}
public 
CTcheck( )
{
    new 
iPlayers[32],iNumCts
    get_players
(iPlayersiNum)
    for(new 
i=0;i<iNum;i++)
    {
        new 
plr iPlayers[i]
        if(
cs_get_user_team(plr) == CS_TEAM_CT)
        {
            
Cts++
            if (
Cts 5)
            {
                new 
snick[32];
                
get_user_name(plrsnick31);
                
cs_set_user_team(plrCS_TEAM_T)
                
client_print(0print_chat"There are already 5 Ct's, %s got switched to the T's"snick);
                
// Remove '//' on the line below to slay the switched player.
                // set_user_health(plr, 0)
            
}
        }
    }


If there are more than 5 CT's, the 5 CT's with the higher playtime stay CT, all other get switched to T's.

TheKidz 10-14-2010 17:08

Re: Get Lower Player Num
 
i think u didnt understand xD, lets see a more detailed explanation:
i got 3 CTs and 9 TRs playing... 3 TRs go out... so There is 3 CTs and 6 TRs, and by my server rules, there should be 3 to 1 TR/CT.. so how can i move the last CT connected to TRs? .-.

its for Jailbreak... .-.

edit: looking to your code looks like he just see if there are more then 5 Cts the last ID goes TR ?
edit: so if the last id connected goes to TR.. interesting '-'

Schwabba 10-14-2010 17:57

Re: Get Lower Player Num
 
PHP Code:

#include <amxmodx>
#include <cstrike>

new PLUGIN[]  = "Teamchanger"
new AUTHOR[]  = "Schwabba"
new VERSION[] = "1.0"

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
set_task(5.0,"CTcheck",0,_,_,"b")
}

public 
CTcheck( )
{
    new 
iPlayers[32],iNumCtsTs
    get_players
(iPlayersTs"e""TERRORIST"); 
    
get_players(iPlayersiNum)
    for(new 
i=0;i<iNum;i++)
    {
        new 
plr iPlayers[i]
        if(
cs_get_user_team(plr) == CS_TEAM_CT)
        {
            
Cts++
            if (
Cts Ts/&& Cts 2)
            {
                new 
snick[32];
                
get_user_name(plrsnick31);
                
cs_set_user_team(plrCS_TEAM_T)
                
client_print(0print_chat"There are to many Ct's, %s got switched to the T's"snick);
                
// Remove '//' on the line below to slay the switched player.
                // set_user_health(plr, 0)
            
}
        }
    }


Ok now there can be 2 CT's all the time.

When there are 3 CT's, then 1 CT get moved to the T's until the T's are 9 or more players, same with 12 T's and 4 CT's.

issen1 10-14-2010 17:59

Re: Get Lower Player Num
 
get_user_time(id)

http://www.amxmodx.org/funcwiki.php?go=func&id=160

Schwabba 10-14-2010 18:29

Re: Get Lower Player Num
 
PHP Code:

#include <amxmodx>
#include <cstrike>

new PLUGIN[]  = "Teamchanger"
new AUTHOR[]  = "Schwabba"
new VERSION[] = "1.0"

new g_newbie 0;

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
set_task(5.0,"CTcheck",0,_,_,"b")
}

public 
CTcheck( )
{
    new 
iPlayers[32],iNumCtsTsnewbie
    get_players
(iPlayersCts"e""CT"); 
    
get_players(iPlayersTs"e""TERRORIST"); 
    
get_players(iPlayersiNum)
    
newbie 999999
    
for(new i=0;i<iNum;i++)
    {
        new 
plr iPlayers[i]
        if(
cs_get_user_team(plr) == CS_TEAM_CT)
        {
            if(
get_user_time(plr) < newbie)
            {
                
newbie get_user_time(plr)
                
g_newbie plr
            
}
        }
    }
    if (
Cts Ts/&& Cts 2)
    {
        new 
snick[32];
        
get_user_name(g_newbiesnick31);
        
cs_set_user_team(g_newbieCS_TEAM_T)
        
client_print(0print_chat"There are to many Ct's, %s got switched to the T's"snick);
        
// Remove '//' on the line below to slay the switched player.
        // set_user_health(g_newbie, 0)
    
}


Now i made it with get_user_time, because when someone disconnect and a new player gets his id, the old plugin thinks that this player is longer connected.

But i'm not sure if that is rly what you want, because when someone joines CT with a longer connection time as someone else, then the player who already was CT get moved to the T's.

Example:

Player A is T and is connected 10 minutes, player B is CT and is connected 5 minutes.

Player A joines CT and player B get switched to the T's, because player A is longer connected.

issen1 10-16-2010 12:57

Re: Get Lower Player Num
 
Use client_infochanged or something to retrieve the event when a player switches team. Pseudocode:

PHP Code:

public client_infochanged(id)
{
    if(
cs_get_user_team(id) == CS_TEAM_CT)
        if (
g_iCtCount CountOfTerrors/3)
            
cs_set_user_team(idCS_TEAM_CT)
            return;

        
g_iCtTime[id] = get_gametime()
        
g_iCtCount += 1
}

public 
client_disconnect(id)
{
    if (
CountOfCTs CountOfTerrors/3)
          
lastCt 0
          
for (i=133i++)
              if(
cs_get_user_team(id) == CS_TEAM_CT && g_iCtTime[i] > g_iCtTime[lastCt])
                    
lastCt i


Just to give you a basic idea what I'm talking about. Also, if you don't plan on scripting yourself, post in the Request forum.

greets

TheKidz 10-25-2010 21:15

Re: Get Lower Player Num
 
i tried this idea, but it doenst give you the exacly last one :s

sorry abt the late answer ;/ i was busy...


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

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