Thread: 3 dim array ?
View Single Post
JocAnis
Veteran Member
Join Date: Jun 2010
Old 09-27-2018 , 12:24   Re: 3 dim array ?
Reply With Quote #6

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 boolfound_orig false 

new origins32 ][ //to store every players cordinates
new name32 ][ 32 ]

register_clcmd"say /joincup"join_cup 

public 
join_cupid 

    
num_players++ 
    
//code 
    
set_task60.0"finished"id 

public 
finishedid 

    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_task3.0"teleport_origin"id __"a"num_players //lets teleport all players to other positions
        
set_task3.0*num_players+1.0"real_end"id //make real finished (with all resetings)

public 
find_origins() 

    new 
playerNumplayers32 ], id 
    get_players
playersplayerNum )  
    
    for( new 
0playerNumi++ ) 
    { 
        
id players
        if( 
in_duelid ] )
        { 
            
entity_get_vectoridEV_VEC_originoriginsid ] )  //lets get everyones positions
            
get_user_nameidnameid ], 31 //and names
        



public 
teleport_originid 

    if( 
in_duelid ] ) 
    { 
        for( new 
0sizeoforigins ); i++ ) //go through every origin ?
        

            
//handy debug
            
client_print0print_console"Num: %d Nick: %s - %.01f %.01f %.01f"iname], origins][0], origins][1], origins][2]  ) 
            if( 
origins][ ] == 0.0 ) continue 
            
            
entity_set_vectoridEV_VEC_originorigins] )  //set every player to others origin
            
origins][ ] = 0.0 //set that first i[0] to 0 so it will skipped...go for next in loop
                        
break;
        }  
    } 
}
public 
real_endid )
{
in_duelid ] = false
...
client_cmdid"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
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)

Last edited by JocAnis; 09-28-2018 at 07:09.
JocAnis is offline