Raised This Month: $404 Target: $400
 101% 

3 dim array ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
JocAnis
Senior Member
Join Date: Jun 2010
Old 09-17-2018 , 20:06   3 dim array ?
Reply With Quote #1

hello...im making an mini-cup plugin...when its finished, it should store all origins from players who participated, im doing it with:

PHP Code:
new origin32 ][ ]

//and then on finish:

new playerNumplayers32 ], id
get_players
playersplayerNum 
for( new 
0playerNumi++ )
{
    
id players]
    if( 
teleporting_pid ] )
    {
        
entity_get_vectoridEV_VEC_originoriginid ] ) //ok get player's origin
    
}


so the point is to teleport all participans to each positions from the cup (with like set_task 2-3sec)
also, when everyone is teleported to an player's position it should stamp that player's name...i have no idea how to connect name + origin, and call them one by one...any help is welcome

EDIT:
im havin num_players which is adding the count on starting_cup(), so i will add somewhere:

PHP Code:
set_task2.0"teleporting_p"id__"a"num_players 
but later what to do...to make (for) loop, and check if
PHP Code:
bool:player_is_playingid ]
//...then set 
player_is_playingrandomid ) ] = false //obvius i dont know how to controll differents IDs in a loop 
to decrease one by one (so fewer teleports)..but it seems not that correct

Last edited by JocAnis; 09-18-2018 at 07:59. Reason: trying something, but my brain is stupid
JocAnis is offline
shauli
Member
Join Date: Jun 2018
Old 09-18-2018 , 12:51   Re: 3 dim array ?
Reply With Quote #2

I'm sorry, I didn't understand what are you trying to do, can you please explain again?
You have the player's origin, you want to teleport the player to the same origin he had a few seconds ago? or to another player's origin?
shauli is offline
JocAnis
Senior Member
Join Date: Jun 2010
Old 09-18-2018 , 13:01   Re: 3 dim array ?
Reply With Quote #3

if 5 players are playing cup, when its finished, store all 5 positions
then in every 2.0 sec teleport all players to all positions (at the same time), so all will see who got where

i got this on my mind:
new Float: origins[ 5 ][ 3 ] = { ... } (let it be max 5 players)

gotta see will it work, and then somehow for names

Last edited by JocAnis; 09-18-2018 at 13:02.
JocAnis is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 09-19-2018 , 17:53   Re: 3 dim array ?
Reply With Quote #4

The below is how you can associate all data for a player in one place. I don't fully understand what you are trying to do when it finishes and you want to teleport players.

PHP Code:
#include <amxmodx>
#include <fakemeta>

#define MAX_PLAYERS 32

enum PlayerData
{
    
pdName33 ] ,
    
Float:pdOrigin] ,
    
bool:pdPlayerIsPlaying
}

new 
pdDataMAX_PLAYERS ][ PlayerData ];

public 
testid )
{
    
get_user_nameid pdDataid ][ pdName ] , charsmaxpdData[][ pdName ] ) );
    
pevid pev_origin pdDataid ][ pdOrigin ] );
    
pdDataid ][ pdPlayerIsPlaying ] = true;

__________________
Bugsy is offline
JocAnis
Senior Member
Join Date: Jun 2010
Old 09-21-2018 , 15:37   Re: 3 dim array ?
Reply With Quote #5

allright, big thanks Bugsy...its nice to know new things, i will see which method i will add to this plugin
__________________
JocAnis is offline
JocAnis
Senior 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
__________________

Last edited by JocAnis; 09-28-2018 at 07:09.
JocAnis is offline
JocAnis
Senior Member
Join Date: Jun 2010
Old 10-05-2018 , 08:41   Re: 3 dim array ?
Reply With Quote #7

new code..loops are that fast so it cant be executed as i expected to do..gonna try playrloop into originloop
PHP Code:
public teleport_origin1id )
{
    for( new 
0sizeoforigins ); i++ )
    {    
        if( 
origins][ ] == 0.0 ) continue
        
broj++
                
        
set_dhudmessage255850, -1.00.402.52.5 )  
        
show_dhudmessageid"Teleported to: %s"ime_brt] ) 
                
        
entity_set_vectoridEV_VEC_originorigins] ) 
                
        
client_printidprint_console"TP: BROJ: %d NIK:%s - %.01f %.01f %.01f"iime_brt], origins][0], origins][1], origins][2]  )

        if( 
originsi+][ ] != 0.0 )
        {
            
client_printidprint_chat"debug: One more TP comming" )
            
set_task4.0,  "teleport_origin1"id )
        }
        else
        {
            
client_printidprint_chat"debug: No more TPs" )
        }
        if( 
broj >= broj_igraca )
        {
            
origins][ ] = 0.0    
            client_print
idprint_console"DEBUG DEBUG Reseting origin[ %d ] to 0.0, broj = %d GO NEXT ORIG"i,  broj )
            
broj 0
        
}
        break
    }

if noone replies, its fine, at least i can see if i progressed at all lul
__________________
JocAnis is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-05-2018 , 09:22   Re: 3 dim array ?
Reply With Quote #8

I can take a look at this later. Is your only issue the speed at which the setting of origins is happening?
__________________
Bugsy is offline
JocAnis
Senior Member
Join Date: Jun 2010
Old 10-05-2018 , 10:15   Re: 3 dim array ?
Reply With Quote #9

yeah...i mean, i put set_task for every participating ID, but that loop for sizeof origins + that set_task, doesnt go one with other...not the best logic for resolving it...so made new code:

PHP Code:
//ime_brt = name
//broj = number
new od 
new boolg_provereno false

public cup_finishedid )
{
set_task3.0"teleport_origin1"id )
}

public 
teleport_origin1id )
{        
    
set_dhudmessage255850, -1.00.402.52.5 )  
    
show_dhudmessageid"Teleported to: %s"ime_brtod ] ) 
            
    
entity_set_vectoridEV_VEC_originoriginsod ] ) 
            
    
client_printidprint_console"TP: BROJ: %d NIK:%s - %.01f %.01f %.01f"odime_brtod ], originsod ][0], originsod ][1], originsod ][2]  )

    if( 
originsod+][ ] != 0.0 )  //edit: not executed
    
{
        
set_task3.0,  "teleport_origin1"id )
        
client_printidprint_console"PRINTINGGGGG: one more tp" 
    }
    if( !
g_provereno && ( originsod+][ ] != 0.0 )  //edit: not executed
    
{
        
g_provereno true //this bool for just one execute cuz could be 10 id's in cup
        
        
set_task0.2"set_od"555 )
    }
    else
    {
        
client_printidprint_chat"debug: No more TPs" )
    }
}
public 
set_od()
{
    
od++
    
g_provereno false // being able to check next origin

didint test yet with 2or more players, but i think this is a little better way of doing it..anyway, thank you for trying

edit: maybe getting all player's origin problem...cuz origin[ od+1 ][0] isnt excecuted :S
PHP Code:
public find_origins()
{
    new 
id
    get_players
playersplayerNum 
    
    for( new 
0playerNumi++ )
    {
        
id players]
        if( 
in_duelid ] )
        {
            
entity_get_vectoridEV_VEC_originoriginsid ] ) 
            
get_user_nameidime_brtid ], 31 )
            
client_printidprint_chat"PRONADJENO: %.01f %.01f %.01f"origins[id][0],origins[id][1],origins[id][2])

        }
    }

__________________

Last edited by JocAnis; 10-05-2018 at 11:42.
JocAnis is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Location: Muslim and proud!
Old 10-05-2018 , 10:46   Re: 3 dim array ?
Reply With Quote #10

Just for more info

Does enum supports 2d array ? No but there is a hacky way you can achieve that.
__________________
@Jailbreak API MODE 100% done !
@User Tag Prefix 100% done !
@Mystery Box 100% done !

@Arena Mod 90% done !

Gaming Districts Community
Donate

Last edited by Natsheh; 10-05-2018 at 10:46.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
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 00:15.


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