AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Empty an Array (https://forums.alliedmods.net/showthread.php?t=155507)

ProIcons 04-23-2011 05:10

Empty an Array
 
How can i empty
WeaponData[ player ][ wpnindex ][ Kills ][ half ]

without define the "wpnindex"

if in the array we have 6 different wpnindex i want to erase them an the 6 arrays...

I mean to empty all the arays that they have [player][kills][half] like i defined

SnoW 04-23-2011 05:40

Re: Empty an Array
 
The emptying isn't a problem here but the fact that your array has four dimensions. I recommend you to use dDimension. If you need further assistance in emptying a dDimension array I will be happy to help.

ProIcons 04-23-2011 06:25

Re: Empty an Array
 
Arrays have always be created at the beginning of a statement ( See how the new/static must be inside the form )

if i want a global array not only to a "public" event or function what i must do...

what is: Float: fCount;

i didn't understood that f2( Float: g{ MyPassedDArray} )



also how can i empty my current array, and how can i find how many wpindexes are in my array with the same "player" "kills"
i removed the "half"

ProIcons 04-23-2011 08:20

Re: Empty an Array
 
PHP Code:

if (TK != 1) {
            
PlayerDatakiller ][ Kills ][ half ]++;
            
PlayerDatavictim ][ Deaths ][ half ]++;
            
//WeaponData[ killer ][ wpnindex ][ Kills ][ half ]++;
            //WeaponData[ victim ][ wpnindex ][ Deaths ][ half ]++;
            
d{WeaponDatakiller ][ wpnindex ][ Kills ][ half ]} = fCount += 1.0;
            
d{WeaponDatavictim ][ wpnindex ][ Deaths ][ half ]} = fCount += 1.0;
        }
        else if (
TK == 1) {
            
PlayerDatakiller ][ Tks ][ half ]++;
            
PlayerDatavictim ][ Deaths ][ half ]++;
            
//WeaponData[ killer ][ wpnindex ][ Tks ][ half ]++;
            
dWeaponDatakiller ][ wpnindex ][ Tks ][ half ] } = fCount += 1.0;
            
//WeaponData[ victim ][ wpnindex ][ Deaths ][ half ]++;
            
dWeaponDatakiller ][ wpnindex ][ Deaths ][ half ] } = fCount += 1.0;
        }
        
msg("Kill Status: Killer: %s (%d) / Victim: %s (%d) / Weapon: %s / Hitplace: %s / TK: %d / HeadShot: %s ",killernamekillervictimnamevictimwprealnameswpnindex ], HitPlaceStringshitplace ] , TK headshot);
        
msg("Kills for Player %s with gun %s = %f",killername,wprealnameswpnindex ],dWeaponDatakiller ][ wpnindex ][ Kills ][ half ] })
        
msg("Deaths for Player %s with gun %s = %f",victimname,wprealnameswpnindex ],dWeaponDatavictim ][ wpnindex ][ Deaths ][ half ] }) 



[Network] Kill Status: Killer: ProIcons<496> (8) / Victim: Test8 (4) / Weapon: Desert Eagle .50AE / Hitplace: Head / TK: 0 / H
[Network] Kills for Player ProIcons<496> with gun Desert Eagle .50 AE = 1.000000
[Network] Deaths for Player Test8 with gun Desert Eagle .50 AE = 2.000000


[Network] Kill Status: Killer: ProIcons<496> (8) / Victim: Test9 (3) / Weapon: Desert Eagle .50AE / Hitplace: Head / TK: 0 / H
[Network] Kills for Player ProIcons<496> with gun Desert Eagle .50 AE = 3.000000
[Network] Deaths for Player Test9 with gun Desert Eagle .50 AE = 4.000000

It is incing the same thing....

SnoW 04-23-2011 10:53

Re: Empty an Array
 
Quote:

Originally Posted by ProIcons (Post 1455908)
i removed the "half"

Could you specify how many dimensions your array currently has?

ProIcons 04-23-2011 10:59

Re: Empty an Array
 
just see my last post...

plus this on public...
c{ new Float:WeaponData[ 33 ][ 32 ][ Score ][ 2 ] };
new Float: fCount;

SnoW 04-23-2011 11:24

Re: Empty an Array
 
Quote:

Originally Posted by ProIcons (Post 1456073)
just see my last post...

plus this on public...
c{ new Float:WeaponData[ 33 ][ 32 ][ Score ][ 2 ] };
new Float: fCount;

The variable fCount was used in the tutorial but is not otherwise related to using dDimension arrays.

You can declare the array as global but public declaration is needed only if you are going to use the array from another plugin.

Code:
c{ new _:A[ 33 ][ 32 ][ 3 ][ 2 ] }; //Global array public func( ) {      //Use the array... } func2( ) {      //Use the array... }

Notice that the array doesn't need to be Float. Use tag _: for easier operation.

Edit:

So ideally, what you would want to do is only

Code:
d{ A[ PlayerOrSomething ][ Killer ][ Weapon ][ WhatWasThis ] }++;

ProIcons 04-23-2011 12:30

Re: Empty an Array
 
Ok now, how can i take from here all the arays that they have
common
killer
Deaths
half

and find the wpnindex for each ?

d{ WeaponData[ killer ][ wpnindex ][ Deaths ][ half ] }

and how can i convert a float to integer

SnoW 04-23-2011 16:58

Re: Empty an Array
 
Quote:

Originally Posted by ProIcons (Post 1456136)
Ok now, how can i take from here all the arays that they have
common
killer
Deaths
half

and find the wpnindex for each ?

d{ WeaponData[ killer ][ wpnindex ][ Deaths ][ half ] }

What you are probably trying to achieve is going through the array with a loop. I don't know what you are trying to do exactly but something similiar below.
Code:
for( int WpI; WpI < MAX; WpI++ )     if( d{ WeaponData[ Killer ][ WpI ][ Deaths ][ Half ] } == CompareTo )     {           //Action     }
Quote:

Originally Posted by ProIcons (Post 1456136)
and how can i convert a float to integer

Look for floatround.

ProIcons 04-23-2011 18:17

Re: Empty an Array
 
and what about to remove the entry of [Killer] ?


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

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