AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   iCount not working properly. (https://forums.alliedmods.net/showthread.php?t=223424)

proffs 08-13-2013 12:21

iCount not working properly.
 
Alright, so i am using this code.
But sometimes it thinks that 1 of the 1 is a CT so it stops the game.
How can i make it that it stops the game when there is 1 T left AND/OR 0 CTs left.


PHP Code:

public Ham_PlayerKillediVictimiAttackershouldgib )
{
if( 
g_iCurrentGame == FUN_13 || !is_user_connectediVictim ) || !is_user_aliveiAttacker ) )
        return 
HAM_IGNORED;
        
    if( 
g_iCurrentGame == FUN_12 || !is_user_connectediVictim ) || !is_user_aliveiAttacker ) )
        return 
HAM_IGNORED;
        
    if( 
g_iCurrentGame == FUN_1 || !is_user_connectediVictim ) || !is_user_aliveiAttacker ) )
        return 
HAM_IGNORED;

    if( 
g_iCurrentGame != GAME_NO )
    {
        new 
iPlayers32 ], iCount;
        
        
get_playersiPlayersiCount"aech""TERRORIST" )
        
        if( 
iCount == StopGame();
    }



Black Rose 08-13-2013 18:29

Re: iCount not working properly.
 
It seems like it would work but you can try this instead if you want to be sure.
Code:
        new iPlayers[ 32 ], iCount;                   get_players( iPlayers, iCount, "aech", "TERRORIST" )                   if( iCount == 1 ) StopGame();
-->
Code:
new iCount = 0; for ( new i = 0 ; i < global_get(glb_MaxClients) ; i++ ) {     if ( is_user_alive(i) && ! is_user_bot(i) && ! is_user_hltv(i) && cs_get_user_team(i) == TEAM_TERRORIST )         iCount++; } if( iCount == 1 ) StopGame();

wickedd 08-13-2013 19:08

Re: iCount not working properly.
 
Get players should work, just make sure it's being called.

@Black Rose

You don't need to check if he's connected and alive. If he's alive he must be connected.

fysiks 08-13-2013 23:37

Re: iCount not working properly.
 
Quote:

Originally Posted by wickedd (Post 2012525)
If he's alive he must be connected.

Sometimes I feel like the contrapositive of that is true, lol. (Alive referring to RL)

proffs 08-14-2013 03:18

Re: iCount not working properly.
 
Quote:

Originally Posted by wickedd (Post 2012525)
Get players should work, just make sure it's being called.

@Black Rose

You don't need to check if he's connected and alive. If he's alive he must be connected.

Here is it being called. It's being called exactly the same on few other games on this plugin.
PHP Code:

public SniperGame()
{
    
g_iCurrentGame GAME_SNIPER
    
    
new iPlayers[32]
    new 
iNum
    
new id
    
    set_cvar_num
("mp_friendlyfire",1)
    
    
get_playersiPlayersiNum"a" )
    for( new 
0iNumi++ )
    {
        
id iPlayers[i

Should be something wrong i think.

And here is a working one that is on few other.
I just want to see what the problem is.


PHP Code:

public Spartaday()
{
    
g_iCurrentGame GAME_SPARTA
    
    
new iPlayers[32]
    new 
iNum
    
new id
    
    get_players
iPlayersiNum"a" )
    
    for( new 
0iNumi++ )
    {
        
id iPlayers[i


proffs 08-15-2013 13:47

Re: iCount not working properly.
 
Hmm, still not working.
Tried to switch get_players( iPlayers, iNum, "a" )
to: get_players( iPlayers, iNum, "aech" )

wickedd 08-15-2013 14:06

Re: iCount not working properly.
 
Post your code.

proffs 08-17-2013 11:19

Count Players.
 
I am using this right now:
PHP Code:

public Ham_PlayerKillediVictimiAttackershouldgib )
{
        new 
iPlayers32 ], iCount;
        
        
get_playersiPlayersiCount"aech""TERRORIST" )
        
        if( 
iCount == StopGame();


I am calling it like this:

PHP Code:

public SniperGame()
{
    
g_iCurrentGame GAME_Sniper
    
    
new iPlayers[32]
    new 
iNum
    
new id
    
    set_cvar_num
("mp_friendlyfire",1)
    
    
get_playersiPlayersiNum"a" )
    
    for( new 
0iNumi++ )
    {
        
id iPlayers[i]
        
        
set_hudmessage 692300, -1.00.3500.15.00.10.1, -
        
show_hudmessage 0"[RPGSD]: Sniper Game Started!")
        
        
strip_user_weaponsid )
        
        if (
cs_get_user_team(id) == CS_TEAM_CT)
        {
            
give_item(id"weapon_knife")
            
give_item(id"weapon_m4a1"
            
give_item(id"weapon_deagle")
            
cs_set_user_bpammoidCSW_M4A190 )
            
cs_set_user_bpammoidCSW_DEAGLE35 )
            
set_user_godmode(id1)
            
fm_reset_user_model(id

But the problem is that when there is 2 lefts, StopGame command runs it automatic.
Because it thinks 1 of the T is CT. He gets CT skin and so on.
Am i doing it wrong?

I got this code from my friend.
But I don't know how to use it can someone help me?

PHP Code:

stock getPlayers(CsTeams:iTeam)
{
new 
players
for(new 133i++)
if(
is_user_connected(i) && !is_user_bot(i) && is_user_alive(i))
if(
cs_get_user_team(i) == iTeamplayers++

return 
players


PHP Code:

if(getPlayers(CS_TEAM_T) == 1


wickedd 08-17-2013 11:54

Re: iCount not working properly.
 
What you are trying to do? What are you trying to accomplish?

proffs 08-17-2013 12:31

Re: iCount not working properly.
 
Quote:

Originally Posted by wickedd (Post 2013981)
Post your code.

Quote:

Originally Posted by wickedd (Post 2015464)
What you are trying to do? What are you trying to accomplish?

When there is 1 T or 0 CT StopGame command should run.


All times are GMT -4. The time now is 15:55.

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