AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   HELP!! #define macros value with 2D arrays player data (https://forums.alliedmods.net/showthread.php?t=339451)

wEr3 09-10-2022 14:35

HELP!! #define macros value with 2D arrays player data
 
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. 


kww 09-10-2022 18:19

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

Originally Posted by wEr3 (Post 2788494)
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

wEr3 09-10-2022 19:24

Re: HELP!! #define macros value with 2D arrays player data
 
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.

kww 09-10-2022 19:28

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

Originally Posted by wEr3 (Post 2788523)
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?

wEr3 09-10-2022 19:34

Re: HELP!! #define macros value with 2D arrays player data
 
I don't know , I'm stupid :D I thought that you need 32 columns , since it has 32 players with rows.

lexzor 09-10-2022 19:50

Re: HELP!! #define macros value with 2D arrays player data
 
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]

wEr3 09-10-2022 21:50

Re: HELP!! #define macros value with 2D arrays player data
 
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;




lexzor 09-11-2022 09:55

Re: HELP!! #define macros value with 2D arrays player data
 
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.

wEr3 09-11-2022 15:23

Re: HELP!! #define macros value with 2D arrays player data
 
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 ??

lexzor 09-11-2022 19:00

Re: HELP!! #define macros value with 2D arrays player data
 
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;




All times are GMT -4. The time now is 15:35.

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