Quote:
Originally Posted by Depresie
Would something like this work to avoid overflow?
PHP Code:
public HandleTeams() { new iPlayers[32] , iNum , Player; get_players( iPlayers , iNum , "h" ); for ( new i = 0 ; i < iNum ; i++ ) { Player = iPlayers[i]; set_task( (0.05 * i), "JoinGame", Player) } }
public JoinGame(id) { if(!is_user_connected(id)) return; engclient_cmd(id, "jointeam", "5") engclient_cmd(id, "joinclass","5") }
I just want to keep them unasigned after map change, i managed to do that
Then after 30 seconds i want the server to automatically assign them to CT/T teams at the same time without causing overflow ( cs_set_user_team won't work here because as stated by arkshine the players must have their teams and classes selected before using it on them)
All i want is an answer to the question above, if i send them to teams with a delay of 0.05 between each player, using set_task, will it avoid overflowing?
|
Yes, it is a must to work. But may you have to find which is the minimum delay to use.
I think that something like '0.5' seconds is fine. But may be not.
If not, use a higher value than '0.5' seconds as '0.75' seconds.
If yes, you can try use a lower value than '0.5' seconds, to the things ready faster.
If I test it right when developing my plugin, '0.5' seconds does not cause overflow for ~10 console lines printed every '0.5' seconds. But on that time, I think I was not looking for a minimum time:
https://github.com/addonszz/Multi-Mod_Manager/blob/59973f43f43b2443ba2b51f0bfbcdbedeaeaa63b/scripting/multimod_manager.sma#L463
You can try with 'print_chat' to find the minimum value for the task to not cause overflow.
However, on your case it must not to trigger the overflow bug, as already said by fysiks.
Because you are sending it to different clients (not the same client).
Quote:
Originally Posted by fysiks
It will be as if the player is sending those two command really really fast.
|
Overflow example:
Code:
stock kickALuckyGuyByOverflow( luckyGuyId )
{
for( new index = 0; index < 1000; ++index )
{
client_print( luckyGuyId, print_chat, "Hi friend, you will be kicked by the overflow!" );
}
}
Update:
What could may be cause an overflow, is sending these 2 commands at once to the same player:
Code:
engclient_cmd(id, "jointeam", "5")
engclient_cmd(id, "joinclass","5")
But I doubt that, to know it for sure, just enter on you server and do it with yourself, if it not overflow you (kick you), it is fine.
Update2:
Do not do it accumulative/increasing as you are doing it:
Code:
set_task( (0.05 * i), "JoinGame", Player)
It should be the same time/period/equal interval as '0.5' seconds.
To accomplish that, you can use a recursive function, that call itself using the 'set_tast' with the same interval as '0.5' seconds.
Example: (I was not much inspired when I wrote this, I kind do not like how it is today)
Code:
/**
* Recursive function call, by the set task to avoid overflowing the client.
*/
public printHelp( player_id )
{
new formatted_string
[32];
player_id = player_id - TASKIS_PRINT_HELP
new current_print_page_total = g_current_print_page
[ player_id
] * LINES_PER_PAGE
g_current_print_page
[ player_id
] = g_current_print_page
[ player_id
] +
1
// print the page header (creates a recursive call),
// there are not much 'g_cmdsAvailables' them I am not splitting it on multiple recursive call to print them
if( !current_print_page_total
)
{
for( new i =
0; i < sizeof
( g_cmdsAvailables
); i++
)
{
client_print( player_id, print_console, g_cmdsAvailables
[ i
] )
}
set_task( 1.0, "printHelp", player_id + TASKIS_PRINT_HELP )
return
}
// print the page body, until all the pages being printed. (creates a recursive call)
if( current_print_page_total - LINES_PER_PAGE < g_modCounter
)
{
new internal_current_page_limit =
0
new menu_page_total_int = g_modCounter / LINES_PER_PAGE
new menu_page_total =
floatround( float( g_modCounter
) /
float( LINES_PER_PAGE
), floatround_ceil
)
if( g_modCounter < LINES_PER_PAGE +
3 )
{
menu_page_total_int =
1
menu_page_total =
1
}
client_print( player_id, print_console,
"^nPrinting Page: %d of %d",
g_current_print_page
[ player_id
] -
1,
( g_modCounter % LINES_PER_PAGE <
2 ) ? menu_page_total_int : menu_page_total
)
for( new i =
3 + current_print_page_total - LINES_PER_PAGE; i <= g_modCounter; i++
)
{
ArrayGetString
( g_mod_names, i, g_mod_name_temp, charsmax
( g_mod_name_temp
) )
ArrayGetString
( g_mod_shortNames, i, g_mod_short_name_temp, charsmax
( g_mod_short_name_temp
) )
formatex
( formatted_string, charsmax
( formatted_string
),
"%s 1", g_mod_short_name_temp
)
client_print( player_id, print_console,
"amx_setmod %-22s| to use %s", formatted_string,
g_mod_name_temp
)
if( internal_current_page_limit++ >=
( LINES_PER_PAGE -
1 )
&& i < g_modCounter
)
{
set_task( 0.5, "printHelp", player_id + TASKIS_PRINT_HELP )
break
}
}
}
// Resets the pages as we finished printing them
if( current_print_page_total > g_modCounter
)
{
g_current_print_page
[ player_id
] =
0
}
}
__________________