Raised This Month: $ Target: $400
 0% 

Once More array issue


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ProIcons
Senior Member
Join Date: Jan 2009
Location: Greece - Salonica
Old 07-04-2012 , 03:51   Once More array issue
Reply With Quote #1

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

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.
__________________
function rb return $regsubex($$1-,/(.)/g,$+($chr(2) $+ $chr(3),$r(2,15),$chr(2),\1))
ProIcons is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 07-04-2012 , 05:37   Re: Once More array issue
Reply With Quote #2

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.
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
Old 07-04-2012, 06:07
ProIcons
This message has been deleted by ProIcons.
ProIcons
Senior Member
Join Date: Jan 2009
Location: Greece - Salonica
Old 07-06-2012 , 02:14   Re: Once More array issue
Reply With Quote #3

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

c{ new _layerData[ 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
__________________
function rb return $regsubex($$1-,/(.)/g,$+($chr(2) $+ $chr(3),$r(2,15),$chr(2),\1))
ProIcons is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 07-06-2012 , 10:25   Re: Once More array issue
Reply With Quote #4

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 ?
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.

Last edited by hornet; 07-06-2012 at 10:28. Reason: left part out ...
hornet is offline
ProIcons
Senior Member
Join Date: Jan 2009
Location: Greece - Salonica
Old 07-06-2012 , 11:32   Re: Once More array issue
Reply With Quote #5

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
__________________
function rb return $regsubex($$1-,/(.)/g,$+($chr(2) $+ $chr(3),$r(2,15),$chr(2),\1))

Last edited by ProIcons; 07-06-2012 at 11:34.
ProIcons 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 15:15.


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