AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Once More array issue (https://forums.alliedmods.net/showthread.php?t=189172)

ProIcons 07-04-2012 03:51

Once More array issue
 
I have these arrays
PHP Code:

new PlayerHostages[MAXPLAYERS];
new 
PlayerHeadShotsMAXPLAYERS ][ ];
new 
PlayerHeadShotsGunMAXPLAYERS ][ 32 ];
new 
PlayerDamageMAXPLAYERS ][ g_Damage ]; 

I haven't really state their size, But when i'm trying for example to add the array size at the end

PHP Code:

new PlayerHostages[MAXPLAYERS][3]; 

Then i can't set to it an integer value. Well at the moment i'm using them like this:
PHP Code:

PlayerHostages[g_PlayerIDs[id]]++; 

and i want to keep ehm work them like that because it is easy:P

How can i make it work by defining ARRAY size...? Because sometimes in the server sends me an error about the array is out of bounds.. and etc.

Alka 07-04-2012 05:37

Re: Once More array issue
 
What do you want to do exactly? You define the array as 2D-imensional new XYZ[][] and after that you want to set its value only to a first dimension XYZ[]++, you can't do that.

new XYZ[][];
XYZ[0][0]++;

new XYZ[];
XYZ[0]++; <-- This is what you'r looking for.

ProIcons 07-06-2012 02:14

Re: Once More array issue
 
In the ddimension.inc that you can add more than 3 dimensions to an array I'm Using it like this

c{ new _:PlayerData[ MAXPLAYERS ][ Score ][ 3 ][ 3 ]};
c{ new _:g_RoundData[MAXPLAYERS][MAXPLAYERS][3][3][Score][3][5]}; //[Killer][Victim][HitPlace][WeaponIndex][Type][Round][Array Size] ;Number
c{ new _:g_WeaponData[MAXPLAYERS][3][Score][3][4]}; //[Killer][WeaponIndex][Type][Round][Array Size] ;Number
c{ new _:g_WeaponDamage[MAXPLAYERS][3][g_DType][3][4]}; //[Killer][WeaponIndex][Type][Round][Array Size] ;Damage
c{ new _:g_HitPlaceDamage[MAXPLAYERS][MAXPLAYERS][3][3][g_DType][3][5]}; //[Killer][Victim][HitPlace][WeaponIndex][Type][Round][Array Size] ;Damage

And Then

d{PlayerData[g_PlayerIDs[g_defuser]][XP][1]}-=15;
WORKS

hornet 07-06-2012 10:25

Re: Once More array issue
 
You can only have 3 dimensions in an array. Also, you can't set a value individually to each dimension.
You should have a data structure.

Something like:
Code:
enum _: RoundData {     Killer,     HitPlace,     WeaponIndex,     Type } new Array: g_aRoundData[ 33 ];
You'd then create a new dynamic array assigned to each cell of g_aRoundData[] containing RoundData, and insert the new data after position ArraySize() - 1 to set the array in order by round.
Note that you would not need Victim in the data because you would use g_aRoundData[ index ] and then fill the other pieces of data accordingly.

EDIT: Are you using Post #1 or Post #3 ?

ProIcons 07-06-2012 11:32

Re: Once More array issue
 
PHP Code:


enum HitPlaces 
Generic,Head,Chest,Stomach,LeftArm,RightArm,LeftLeg,RightLeg };
enum Score Kills,Deaths,Assists,Tks,Defuses,Explodes,XP,Wins,Loses,Draws };
//enum g_rdAction { Kills,Deaths,Assists,Tks,Defuses,Explodes,XP,Wins,Loses,Draws };
enum g_DType Attacker Victim };
enum g_Damage NAttacker,NVictim,TKAttacker,TKVictim };

new 
PlayerHostages[MAXPLAYERS];
new 
PlayerHeadShotsMAXPLAYERS ][ 32 ];
new 
PlayerHeadShotsGunMAXPLAYERS ][ 32 ];
new 
PlayerDamageMAXPLAYERS ][ g_Damage ];

c{ new _:PlayerDataMAXPLAYERS ][ Score ][ ][ ]};
c{ new _:g_RoundData[MAXPLAYERS][MAXPLAYERS][3][3][Score][3][5]}; //[Killer][Victim][HitPlace][WeaponIndex][Type][Round][Array Size] ;Number
c{ new _:g_WeaponData[MAXPLAYERS][3][Score][3][4]}; //[Killer][WeaponIndex][Type][Round][Array Size] ;Number
c{ new _:g_WeaponDamage[MAXPLAYERS][3][g_DType][3][4]}; //[Killer][WeaponIndex][Type][Round][Array Size] ;Damage
c{ new _:g_HitPlaceDamage[MAXPLAYERS][MAXPLAYERS][3][3][g_DType][3][5]}; //[Killer][Victim][HitPlace][WeaponIndex][Type][Round][Array Size] ;Damage 

I'm using this code to take an analytic report about the Stats of the Game of Single Each Round, something like psychostats but more analytic


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

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