Raised This Month: $ Target: $400
 0% 

say_team - minor problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CsIosefin
Senior Member
Join Date: Aug 2009
Old 07-31-2010 , 10:46   say_team - minor problem
Reply With Quote #1

Code:
public say_team(id)
{
    static name[32], mes[200];
    read_args(mes, 199);
    remove_quotes(mes);
    trim(mes);
    get_user_name(id, name, 31);

    switch(cs_get_user_team(id))
    {
        case CS_TEAM_T:
        {
            if(is_user_alive(id))
            {
                chat(0, "!team[Team] *ALIVE* !g%s !y: !team%s", name, mes);
            }
                else
            {
                chat(0, "!team[Team] *DEAD* !g%s !y: !team%s", name, mes);
            }
        }

        case CS_TEAM_CT:
        {
            if(is_user_alive(id))
            {
                chat(0, "!team[Team] *ALIVE* !g%s !y: !team%s", name, mes);
            } 
                else 
            {
                chat(0, "!team[Team] *DEAD* !g%s !y: !team%s", name, mes);
            }
        }
    }

    return PLUGIN_HANDLED;
}
How do you see only the team?
I wrote and CS_TEAM_CT CS_TEAM_T why not work?
CsIosefin is offline
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 07-31-2010 , 11:10   Re: say_team - minor problem
Reply With Quote #2

Not sure if this is why, but try making a variable before the switch and testing that variable.

Like

New CsTeams:team
team=cs_get_user_team(id)
switch(team)
//CODE HERE
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
CsIosefin
Senior Member
Join Date: Aug 2009
Old 07-31-2010 , 11:18   Re: say_team - minor problem
Reply With Quote #3

nikhilgupta345: I already put up what to select, it selects your team, but not punching the team, this is the problem ...
CsIosefin is offline
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 07-31-2010 , 12:06   Re: say_team - minor problem
Reply With Quote #4

What's wrong with it, do you mean that it's showing to everyone? Not just the team?
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 07-31-2010 , 12:48   Re: say_team - minor problem
Reply With Quote #5

chat(0, ...

That means it's sent to all players, I guess your chat() function is a copy of colorchat or something, and first arg is the player ID.

So, you must do a loop and see wich player is on player's team and send'em the message.

You could either use get_players() function (I understand it's buggy) or just a for() loop and check stuff.

Also, create a variable to hold is_user_alive() if you use the loop... and also, you can do this:

Code:
chat(0, "!team[Team] *%s* !g%s !y: !team%s", (alive ? "ALIVE" : "DEAD"), name, mes);
__________________

Last edited by Hunter-Digital; 07-31-2010 at 12:51.
Hunter-Digital is offline
CsIosefin
Senior Member
Join Date: Aug 2009
Old 07-31-2010 , 13:13   Re: say_team - minor problem
Reply With Quote #6

Code:
public say_team(id)
{
    static name[32], mes[200], players [32];
    read_args(mes, 199);
    remove_quotes(mes);
    trim(mes);
    get_user_name(id, name, 31);

    new player_count = get_playersnum();
    get_players(players, player_count, "c");

for (new i = 0; i < player_count; i++) 
{
    switch(cs_get_user_team(id))
    {
        case CS_TEAM_T:
        {
            if(is_user_alive(players[i]))
            {
                chat(players[i], "!team[Team] *ALIVE* !g%s !y: !team%s", name, mes);
            }
                else
            {
                chat(players[i], "!team[Team] *DEAD* !g%s !y: !team%s", name, mes);
            }
        }

        case CS_TEAM_CT:
        {
            if(is_user_alive(players[i]))
            {
                chat(players[i], "!team[Team] *ALIVE* !g%s !y: !team%s", name, mes);
            } 
                else 
            {
                chat(players[i], "!team[Team] *DEAD* !g%s !y: !team%s", name, mes);
            }
        }
    }
}

    return PLUGIN_HANDLED;
}
That would be a good way?
Expect a response from you Hunter-Digital
CsIosefin is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 07-31-2010 , 13:20   Re: say_team - minor problem
Reply With Quote #7

No, it's not, learn to go through the code and try to simulate in your mind what it does.

Yours, apart from the verry repeatitive call of is_user_alive(), you're calling it wrong, you need to check if the sender is alive, not the receiver.

Code:
public say_team(id)
{
	static name[32], mes[200], players[32], player, alive, num, i, CsTeams:team;

	read_args(mes, 199);
	remove_quotes(mes);
	trim(mes);

	get_user_name(id, name, 31);
	alive = is_user_alive(id);
	team = cs_get_user_team(id);

	num = get_playersnum();
	get_players(players, num, "c");

	for (i = 0; i < num; i++)
	{
		player = players[i];

		/* you could replace is_user_connected(player) with is_user_alive(player) == alive if you don't want dead-alive chat. */

		if(is_user_connected(player) && cs_get_user_team(player) == team)
			chat(player, "!team[Team] *%s* !g%s !y: !team%s", (alive ? "ALIVE" : "DEAD"), name, mes);
	}

	return PLUGIN_HANDLED;
}
__________________

Last edited by Hunter-Digital; 07-31-2010 at 13:24. Reason: rasn fasn vbulletin X(
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 00:16.


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