AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   where did I wrong ? (https://forums.alliedmods.net/showthread.php?t=210451)

newcomer 03-10-2013 13:37

where did I wrong ?
 
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
}

Podarok 03-10-2013 14:33

Re: where did I wrong ?
 
CSTEAM_SPECTATOR
-->
CS_TEAM_SPECTATOR

and

CSTEAM_TERRORIST
->
CS_TEAM_TERRORIST

newcomer 03-10-2013 14:36

Re: where did I wrong ?
 
I don't think so
He told
Quote:

enum {
CSTEAM_UNASSIGNED = 0,
CSTEAM_TERRORIST,
CSTEAM_CT,
CSTEAM_SPECTATOR
};


Torge 03-10-2013 20:22

Re: where did I wrong ?
 
Never seen such natives just:

CS_TEAM_CT, etc..

Kz1.0 03-10-2013 22:56

Re: where did I wrong ?
 
Quote:

Originally Posted by Torge (Post 1910463)
Never seen such natives just:

CS_TEAM_CT, etc..

He used a custom Module https://forums.alliedmods.net/showthread.php?p=1523616

Podarok 03-11-2013 01:59

Re: where did I wrong ?
 
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 }

newcomer 03-11-2013 05:00

Re: where did I wrong ?
 
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 :)

Backstabnoob 03-11-2013 09:54

Re: where did I wrong ?
 
Changing team in TeamInfo event was crashing my server as well. Try to delay it using set_task.

newcomer 03-11-2013 13:24

Re: where did I wrong ?
 
set_task still carsh
I think problem at
Quote:

new id = read_data(1)

Infernuz 03-11-2013 23:25

Re: where did I wrong ?
 
Why don't you hook team choose menu instead of TeamInfo?


All times are GMT -4. The time now is 21:46.

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