Raised This Month: $ Target: $400
 0% 

where did I wrong ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
newcomer
Member
Join Date: Aug 2011
Old 03-10-2013 , 13:37   where did I wrong ?
Reply With Quote #1

I have try make limit players join team if have limit then they will get auto change team, but it's not work, I don't know why. Please teach me

Quote:
#include <amxmisc>
#include <cs_team_changer>
#define PLUGIN "Limit players"
#define VERSION "1.0"
#define AUTHOR "Test"

public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_event( "TeamInfo", "join_team", "a")
}

public join_team()
{
new victim = read_data(1)
if(!is_user_connected(victim)) return PLUGIN_CONTINUE
new user_team[32]
new tplayers[32], ctplayers[32], tnum, ctnum;
get_players(tplayers, tnum, "e", "TERRORIST");
get_players(ctplayers, ctnum, "e", "CT");
read_data(2, user_team, 31)
switch(user_team[0])
{
case 'C':
{

if((ctnum >= 5) && (tnum < 5))
{
cs_set_team(victim, CSTEAM_TERRORIST)
}
else if((ctnum >= 5) && (tnum >= 5))
{
cs_set_team(victim, CSTEAM_SPECTATOR )
}

}
case 'T':
{
if((tnum >= 5) && (ctnum < 5))
{
cs_set_team(victim, CSTEAM_CT)
}
else if((tnum >= 5) && (ctnum >= 5))
{
cs_set_team(victim, CSTEAM_SPECTATOR)
}
}
}
return PLUGIN_CONTINUE
}
newcomer is offline
Podarok
BANNED
Join Date: Jan 2011
Location: Narnia
Old 03-10-2013 , 14:33   Re: where did I wrong ?
Reply With Quote #2

CSTEAM_SPECTATOR
-->
CS_TEAM_SPECTATOR

and

CSTEAM_TERRORIST
->
CS_TEAM_TERRORIST

Last edited by Podarok; 03-10-2013 at 14:35.
Podarok is offline
newcomer
Member
Join Date: Aug 2011
Old 03-10-2013 , 14:36   Re: where did I wrong ?
Reply With Quote #3

I don't think so
He told
Quote:
enum {
CSTEAM_UNASSIGNED = 0,
CSTEAM_TERRORIST,
CSTEAM_CT,
CSTEAM_SPECTATOR
};
newcomer is offline
Torge
Veteran Member
Join Date: Oct 2011
Old 03-10-2013 , 20:22   Re: where did I wrong ?
Reply With Quote #4

Never seen such natives just:

CS_TEAM_CT, etc..
Torge is offline
Kz1.0
Senior Member
Join Date: Jan 2013
Location: Vietnam
Old 03-10-2013 , 22:56   Re: where did I wrong ?
Reply With Quote #5

Quote:
Originally Posted by Torge View Post
Never seen such natives just:

CS_TEAM_CT, etc..
He used a custom Module https://forums.alliedmods.net/showthread.php?p=1523616
Kz1.0 is offline
Podarok
BANNED
Join Date: Jan 2011
Location: Narnia
Old 03-11-2013 , 01:59   Re: where did I wrong ?
Reply With Quote #6

Rewrite it using cs_get_user_team native....
P.S. If you dont wanna do it, try using also
Code:
cs_set_team_tablescore


If you dont use ZP, use just normal cs_set_user_team function.
Try this and let me know if it works :
Code:
#include <amxmisc> #include <cstrike> #define PLUGIN "Limit players" #define VERSION "1.0" #define AUTHOR "Podarok" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_event( "TeamInfo", "join_team", "a") } public join_team() {     new id = read_data(1)     if(!is_user_connected(id)) return PLUGIN_CONTINUE     new user_team[32]     new tplayers[32], ctplayers[32], tnum, ctnum;     get_players(tplayers, tnum, "e", "TERRORIST");     get_players(ctplayers, ctnum, "e", "CT");     read_data(2, user_team, 31)     switch(user_team[0])     {         case 'C':         {             if((ctnum >= 5) && (tnum < 5))             {                 cs_set_user_team(id, CS_TEAM_T, CS_T_LEET)             }             else if((ctnum >= 5) && (tnum >= 5))             {                 cs_set_user_team( id, CS_TEAM_SPECTATOR )             }         }         case 'T':         {             if((tnum >= 5) && (ctnum < 5))             {                 cs_set_user_team(id, CS_TEAM_CT, CS_CT_GIGN)             }             else if((tnum >= 5) && (ctnum >= 5))             {                 cs_set_user_team( id, CS_TEAM_SPECTATOR )             }         }     }     return PLUGIN_CONTINUE }

Last edited by Podarok; 03-11-2013 at 02:46.
Podarok is offline
newcomer
Member
Join Date: Aug 2011
Old 03-11-2013 , 05:00   Re: where did I wrong ?
Reply With Quote #7

I tried put 9 bots in server, 5 for T and 4 for CT. When I try join T, server change me to Spectator then crash server

Last edited by newcomer; 03-11-2013 at 05:01.
newcomer is offline
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 03-11-2013 , 09:54   Re: where did I wrong ?
Reply With Quote #8

Changing team in TeamInfo event was crashing my server as well. Try to delay it using set_task.
Backstabnoob is offline
newcomer
Member
Join Date: Aug 2011
Old 03-11-2013 , 13:24   Re: where did I wrong ?
Reply With Quote #9

set_task still carsh
I think problem at
Quote:
new id = read_data(1)
newcomer is offline
Infernuz
Member
Join Date: May 2011
Old 03-11-2013 , 23:25   Re: where did I wrong ?
Reply With Quote #10

Why don't you hook team choose menu instead of TeamInfo?

Last edited by Infernuz; 03-11-2013 at 23:25.
Infernuz is offline
Send a message via ICQ to Infernuz
Reply


Thread Tools
Display Modes

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 21:46.


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