Raised This Month: $ Target: $400
 0% 

check alive players from a team problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Owyn
Veteran Member
Join Date: Nov 2007
Old 04-06-2009 , 17:40   Re: check alive players from a team problem
Reply With Quote #1

Quote:
You don't need to check !is_user_alive(i), you already have g_died[i]
player could respawn

register_event
don't think so, cuz it worked fine with other code, i mean it registered CTwin and TE win events fine, and set_task and the function it executes been tested also and worked fine, problem is in checking players must be

gonna test the code and make some logging, what it found and its attributes
__________________
☜ Free Mozy ☂backup\҉sync user
Quote:
Американский форум - Задаёшь вопрос, потом тебе отвечают.
Израильский форум - Задаёшь вопрос, потом тебе задают вопрос.
Русский форум - Задаёшь вопрос, потом тебе долго рассказывают, какой ты мудак.
Owyn is offline
Send a message via ICQ to Owyn
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 04-06-2009 , 17:43   Re: check alive players from a team problem
Reply With Quote #2

Quote:
Originally Posted by .Owyn. View Post
player could respawn
Then catch respawn and set g_died[id] to false...
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ
Dores is offline
Owyn
Veteran Member
Join Date: Nov 2007
Old 04-06-2009 , 17:52   Re: check alive players from a team problem
Reply With Quote #3

Quote:
Originally Posted by Dores View Post
Then catch respawn and set g_died[id] to false...
maybe.. btw, how does it auto sets to false when i don't set it to false nowhere? i mean previous code almost allways showed positive and did set_task with my event

btw, tested my code again, it works when i'm alone and when i play with bot 1x1, but when i tested in in full server and one side killed another without dead players it didn't do anything =s *or it works, i dunno ><
__________________
☜ Free Mozy ☂backup\҉sync user
Quote:
Американский форум - Задаёшь вопрос, потом тебе отвечают.
Израильский форум - Задаёшь вопрос, потом тебе задают вопрос.
Русский форум - Задаёшь вопрос, потом тебе долго рассказывают, какой ты мудак.

Last edited by Owyn; 04-06-2009 at 18:12.
Owyn is offline
Send a message via ICQ to Owyn
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 04-06-2009 , 18:16   Re: check alive players from a team problem
Reply With Quote #4

Ohhhh it should be like this(I can't believe I didn't see it):

PHP Code:
public soundCTWin() 
{
    
checkAlive("CT")
}

public 
soundTWin() 
{
    
checkAlive("TERRORIST")
}

checkAlive(const team[])
{

    new 
players[32], iTotalPlayersibool:g_event true
    
new id;
    
get_playersplayersiTotalPlayers"e"team );
    
    for ( 
0iTotalPlayersi++ )
    {
        
id players[i];
        
        if(!
is_user_connected(id) || cs_get_user_team(id) != CsTeams:GetTeamByChar(team[0])) continue;
                
        if (
g_died[id])
        {
             
g_event false;
             break;
        }
    }

    if (
g_event)
    {
        
set_task(1.5"setFlawlessVictory"team[0]);
    }
    
    return 
1;
}

GetTeamByChar(ch)
{
    switch(
ch)
    {
        case 
'T':
        {
            return 
1;
        }
        
        case 
'C':
        {
            return 
2;
        }
    }
    
    return 
0;

Thought I've been told that get_players isn't reliable, so:

PHP Code:
public soundCTWin() 
{
    
checkAlive("CT");
}

public 
soundTWin() 
{
    
checkAlive("TERRORIST");
}

checkAlive(const team[])
{
    static 
MaxPlayers;
    if(!
MaxPlayers)
    {
        
MaxPlayers get_maxplayers();
    }
    
    new 
bool:event true;
    
    for (new 
id id <= MaxPlayers id++)
    {
        if( !
is_user_connected(id) || cs_get_user_team(id) != CsTeams:GetTeamByChar(team[0])) continue;
                
        if (
g_died[id])
        {
             
g_event false;
             break;
        }
    }

    if (
g_event)
    {
        
set_task(1.5"setFlawlessVictory"team[0]);
    }
    
    return 
1;
}

GetTeamByChar(ch)
{
    switch(
ch)
    {
        case 
'T':
        {
            return 
1;
        }
        
        case 
'C':
        {
            return 
2;
        }
    }
    
    return 
0;

__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ

Last edited by Dores; 04-06-2009 at 18:30.
Dores is offline
Owyn
Veteran Member
Join Date: Nov 2007
Old 04-06-2009 , 18:23   Re: check alive players from a team problem
Reply With Quote #5

it was like it in the 1st page, then was decided not to use get_players with flags cuz it gives wrong data for cstrike =\

ps - i think my code works, tested it 5x5 O_o hope it would work 10x10

btw, when we check user(i) that means we loop thru all users and check them one by one, and what does mean when we check user(players[i]) ?
__________________
☜ Free Mozy ☂backup\҉sync user
Quote:
Американский форум - Задаёшь вопрос, потом тебе отвечают.
Израильский форум - Задаёшь вопрос, потом тебе задают вопрос.
Русский форум - Задаёшь вопрос, потом тебе долго рассказывают, какой ты мудак.
Owyn is offline
Send a message via ICQ to Owyn
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 04-06-2009 , 18:32   Re: check alive players from a team problem
Reply With Quote #6

The players' IDs are assigned into players[32], and we just retrieve the ids according to the number of players found, but you should use the second method that I posted, it should work.
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ
Dores is offline
Owyn
Veteran Member
Join Date: Nov 2007
Old 04-06-2009 , 18:34   Re: check alive players from a team problem
Reply With Quote #7

so it checks it the same way? and replacing check(i) with check(players[i]) is better?
__________________
☜ Free Mozy ☂backup\҉sync user
Quote:
Американский форум - Задаёшь вопрос, потом тебе отвечают.
Израильский форум - Задаёшь вопрос, потом тебе задают вопрос.
Русский форум - Задаёшь вопрос, потом тебе долго рассказывают, какой ты мудак.
Owyn is offline
Send a message via ICQ to Owyn
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-06-2009 , 19:21   Re: check alive players from a team problem
Reply With Quote #8

Why not just pass an integer for the team into the CheckAlive function instead of a string. It would require less functions.
__________________

Last edited by fysiks; 04-06-2009 at 19:25.
fysiks is offline
Owyn
Veteran Member
Join Date: Nov 2007
Old 04-07-2009 , 01:25   Re: check alive players from a team problem
Reply With Quote #9

how is that? O_o
__________________
☜ Free Mozy ☂backup\҉sync user
Quote:
Американский форум - Задаёшь вопрос, потом тебе отвечают.
Израильский форум - Задаёшь вопрос, потом тебе задают вопрос.
Русский форум - Задаёшь вопрос, потом тебе долго рассказывают, какой ты мудак.
Owyn is offline
Send a message via ICQ to Owyn
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 04-07-2009 , 16:45   Re: check alive players from a team problem
Reply With Quote #10

Thanks for the tips, didn't know that :}
__________________
Hunter-Digital is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:18.


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