Raised This Month: $51 Target: $400
 12% 

HELP!! #define macros value with 2D arrays player data


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
wEr3
Junior Member
Join Date: Jun 2017
Old 09-10-2022 , 14:35   HELP!! #define macros value with 2D arrays player data
Reply With Quote #1

PHP Code:
//#define P_SKILL1                1        // Skill 1 level
    //#define P_SKILL2                2        // Skill 2 level
    //#define P_SKILL3                3        // Skill 4 level
    //#define P_ULTIMATE              4        // Ultimate level
    #define P_LEVEL                    5        // Player Level
    #define P_XP                    6        // Current XP

    // Miscellaneous options
    #define P_SPECMODE                7        // Used to determine if the player is spectating or not
    #define P_SHOWRACEMENU            8        // Should we show the race menu when the player respawns?
    #define P_SHOWICONS                9        // Show player icons/levels for this player?
    #define P_CHANGERACE            10        // Holds the value of what race to change to when the following round starts

    // Used for weapon Reincarnation
    #define P_FLASHCOUNT            11        // Number of flash grenades bought that round
    #define    P_HECOUNT                12        // Number of HE's bought that round
    #define P_SMOKECOUNT            13        // Number of smoke grenades bought that round
    #define P_ARMORONDEATH            14        // Amount of armor the player had when he/she died
    #define P_LASTARMOR                15        // This will contain the previous value of P_ARMORONDEATH

    // Used by various ultimates/abilities
    #define P_TELEMENU                16        // Used by teleport
    #define P_TEAM                    17        // Stores the player's team ID
    //#define P_SHADOWCOUNT            18        // Number of shadow strikes the player has left
    #define P_SERPENTCOUNT            19        // Number of serpent wards the player has left
    #define P_RINGS                    20
    #define P_ULTIMATEDELAY            21
    #define P_RESPAWNBY                22        // Stores how the user is going to respawn

    // Used for DOD
    #define P_MONEY                    23        // Amount of money the player has

    #define P_LAST                    24 
I have hard time understanding those #define values p_data has 33 rows for 32 player but ONLY 24 columns
PHP Code:
new p_data[33][P_LAST]                    // Contains player data

ULT_ResetCooldownidiTimeiHideIcon true )
{
    
p_data[id][P_ULTIMATEDELAY]        = iTime;
    
    
// Hide the user's ultimate icon
    
if ( iHideIcon )
    {
        
ULT_IconidICON_HIDE );
    }
why P_ULTIMATEDELAY has value  21 there are 32 player can someone explain in deep 
I will really  appreciate it

I'm trying to CREATE my Warcraft 3 MODE for ZOMBIE BIOHAZARD , because this mod is created originally for classic.
and it is frustrating. 

Last edited by wEr3; 09-10-2022 at 14:37.
wEr3 is offline
kww
Senior Member
Join Date: Feb 2021
Location: Russia
Old 09-10-2022 , 18:19   Re: HELP!! #define macros value with 2D arrays player data
Reply With Quote #2

Quote:
Originally Posted by wEr3 View Post
why P_ULTIMATEDELAY has value 21 , there are 32 player , can someone explain in deep
I will really appreciate it.
I'm trying to CREATE my Warcraft 3 MODE for ZOMBIE BIOHAZARD , because this mod is created originally for classic.
and it is frustrating.
P_ULTIMATEDELAY has value 21 because it will be 21st column
__________________
Now working on: Side Weapons (Very lazy, tbh)
Avatar source: https://bit.ly/3BAk19g
Discord: kww#9951

Last edited by kww; 09-10-2022 at 18:21.
kww is offline
wEr3
Junior Member
Join Date: Jun 2017
Old 09-10-2022 , 19:24   Re: HELP!! #define macros value with 2D arrays player data
Reply With Quote #3

Yes , but shouldn't we have 32 columns for 32 player (rows) , or we don't need to 32 columns for the 32 rows.sorry for the dumb question.
wEr3 is offline
kww
Senior Member
Join Date: Feb 2021
Location: Russia
Old 09-10-2022 , 19:28   Re: HELP!! #define macros value with 2D arrays player data
Reply With Quote #4

Quote:
Originally Posted by wEr3 View Post
Yes , but shouldn't we have 32 columns for 32 player (rows) , or we don't need to 32 columns for the 32 rows.sorry for the dumb question.
No, why did you think so?
__________________
Now working on: Side Weapons (Very lazy, tbh)
Avatar source: https://bit.ly/3BAk19g
Discord: kww#9951
kww is offline
wEr3
Junior Member
Join Date: Jun 2017
Old 09-10-2022 , 19:34   Re: HELP!! #define macros value with 2D arrays player data
Reply With Quote #5

I don't know , I'm stupid I thought that you need 32 columns , since it has 32 players with rows.
wEr3 is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 09-10-2022 , 19:50   Re: HELP!! #define macros value with 2D arrays player data
Reply With Quote #6

so you have p_data[33] starting from 0 to 32 (the last is EOS, if you will use p_data[33] = 15 you will get an index out of bounds in server console).

players id are starting from 1 to 32, that means p_data[1] is the first player that join the server and so on.

your variable is defined p_data[33][P_LAST] where P_LAST = 24 (last value that can t be used), the numbers from 0 that 23 are powers. for texample you want to print in console the current xp of the player that joined on the server and has id 13.

not using the defined macros, you should use the variable like p_data[13][6] and you will get his XP.

in this case, the author of the plugin used the macros to not memorize numbers for every power so he will use in code p_data[13][P_XP]
lexzor is offline
wEr3
Junior Member
Join Date: Jun 2017
Old 09-10-2022 , 21:50   Re: HELP!! #define macros value with 2D arrays player data
Reply With Quote #7

i'm not sure is that because can you explain this.
#define P_SHOWICONS 9
#define P_SERPENTCOUNT 19

Quote:


CS_GetIcon( id )
{
new szInfo[32];
get_user_info( id, "_wc3", szInfo, 31 );

if ( strlen( szInfo ) > 0 && str_to_num( szInfo ) > 0 )
{
p_data[id][P_SHOWICONS] = true;
}
else
{
p_data[id][P_SHOWICONS] = false;
}

Quote:
WC3_ResetOnNewSession( id )
{
// Shadow Hunter's Serpent Wards
p_data[id][P_SERPENTCOUNT] = 0;



Last edited by wEr3; 09-10-2022 at 21:52.
wEr3 is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 09-11-2022 , 09:55   Re: HELP!! #define macros value with 2D arrays player data
Reply With Quote #8

yes, the ninth slot of the arrray is reserved for P_SHOWICONS

PHP Code:
CS_GetIconid )
{
new 
szInfo[32];
get_user_infoid"_wc3"szInfo31 );

if ( 
strlenszInfo ) > && str_to_numszInfo ) > )
{
p_data[id][P_SHOWICONS] = true; -> tag mismatch warning
}
else
{
p_data[id][P_SHOWICONS] = false; -> tag mismatch warning

that code just detect if player has a icon (idk what icon because you don t provide source) and store the data in that variable with slot 9 (defined as P_SHOWICONS to not memorize the numbers, using words is more easy). there should be a mismatch warning when you compile the code because before giving a variable a boolean value you must define it as a boolean variable

PHP Code:
WC3_ResetOnNewSessionid )
{
// Shadow Hunter's Serpent Wards
p_data[id][P_SERPENTCOUNT] = 0
i think P_SERPENTCOUNT just count something called "wards" (obviously ) ) and that function just reset them when a new round start.

Last edited by lexzor; 09-11-2022 at 09:57.
lexzor is offline
wEr3
Junior Member
Join Date: Jun 2017
Old 09-11-2022 , 15:23   Re: HELP!! #define macros value with 2D arrays player data
Reply With Quote #9

Yes is it big plugin Warcraft 3 mod , so those #define marcos values are just to make more easy to memorize the numbers in COLUMNS , because I'm trying to create my own warcraft 3 zombie mod for biohazard.
I don't need to create array with [33] rows and [32] columns for players in the server.Just how many columns as i wish ??
wEr3 is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 09-11-2022 , 19:00   Re: HELP!! #define macros value with 2D arrays player data
Reply With Quote #10

you must create an array with 33 rows (that means MAX_PLAYERS + 1 in below code) to store players id and have different values of that array for every player

this is how i would start it, maybe this help you

PHP Code:
#include <amxmodx>

enum _:PLAYER_DATA 
{
    
P_NAME[MAX_NAME_LENGTH],
    
P_AUTHID[MAX_AUTHID_LENGTH],
    
P_MONEY,
    
P_LEVEL,
    
P_EXPERIENCE
}

enum _:PLAYER_POWERS
{
    
bool:hasInvis,
    
bool:isInvis,
    
bool:usedInvis,
    
bool:hasDmgMult,
    
dmgMultLevel,
}

new 
g_ePlayerData[MAX_PLAYERS 1][PLAYER_DATA];
new 
g_ePlayerPowers[MAX_PLAYERS 1][PLAYER_POWERS];

public 
client_authorized(id)
{
    
get_user_name(idg_ePlayerData[id][P_NAME], charsmax(g_ePlayerData[][P_NAME]))
    
get_user_authid(idg_ePlayerData[id][P_AUTHID], charsmax(g_ePlayerData[][P_AUTHID]));
    
g_ePlayerData[id][P_MONEY] = 0
    g_ePlayerData
[id][P_LEVEL] = 0
    g_ePlayerData
[id][P_EXPERIENCE] = 0

    g_ePlayerPowers
[id][hasInvis] = false;
    
g_ePlayerPowers[id][isInvis] = false;
    
g_ePlayerPowers[id][usedInvis] = false;
    
g_ePlayerPowers[id][hasDmgMult] = false;
    
g_ePlayerPowers[id][dmgMultLevel] = 0;

lexzor is offline
Reply



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 11:59.


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