ok i tryed to do teleporting players with so many methods and couldnt find the right one...here is exactly what i need:
tournament/cup/duel is started...num_players increase on every player joining. when the cup is finished (like 1minute) every player is freezed, plugin gets origins from every player, and the point is to transfer all players who participated in cup, to every others positions, at the same time...here is my try:
PHP Code:
new bool: found_orig = false
new origins[ 32 ][ 3 ] //to store every players cordinates
new name[ 32 ][ 32 ]
register_clcmd( "say /joincup", join_cup )
public join_cup( id )
{
num_players++
//code
set_task( 60.0, "finished", id )
}
public finished( id )
{
if( !found_orig )
{
find_origins()
found_orig = true //this bool is added just so find_origins will be executed once, cuz finished is called to every player...could be done better but i think thats not a big issue
}
set_task( 3.0, "teleport_origin", id , _, _, "a", num_players ) //lets teleport all players to other positions
set_task( 3.0*num_players+1.0, "real_end", id ) //make real finished (with all resetings)
}
public find_origins()
{
new playerNum, players[ 32 ], id
get_players( players, playerNum )
for( new i = 0; i < playerNum; i++ )
{
id = players[ i ]
if( in_duel[ id ] )
{
entity_get_vector( id, EV_VEC_origin, origins[ id ] ) //lets get everyones positions
get_user_name( id, name[ id ], 31 ) //and names
}
}
}
public teleport_origin( id )
{
if( in_duel[ id ] )
{
for( new i = 0; i < sizeof( origins ); i++ ) //go through every origin ?
{
//handy debug
client_print( 0, print_console, "Num: %d Nick: %s - %.01f %.01f %.01f", i, name[ i ], origins[ i ][0], origins[ i ][1], origins[ i ][2] )
if( origins[ i ][ 0 ] == 0.0 ) continue
entity_set_vector( id, EV_VEC_origin, origins[ i ] ) //set every player to others origin
origins[ i ][ 0 ] = 0.0 //set that first i[0] to 0 so it will skipped...go for next in loop
break;
}
}
}
public real_end( id )
{
in_duel[ id ] = false
...
client_cmd( id, "say /start" )
}
problem: indexes...if theres 2 players...both got teleported only to one's (who started cup)...second teleport is 0.0, 0.0, 0.0, and the last is to the start (from real_end)
can anyone find where is the problem ? mb in the for loop ?
EDIT: adding break to loop is better, cuz set_task has 'a' flag
__________________