Rules FAQ Members List Search Register Login

 Raised This Month: \$54 Target: \$400 13%

Solved Confusion With Array

Author Message
Senior Member
Join Date: Jul 2017
Location: INDIA,KOLKATA
 10-10-2021 , 12:55   Confusion With Array #1 Hi Guys, I have a bit confession. Code: ```new Array[2] //declared array Array[0] = 2 //stored value 2 in Array[0] Array[1] = 3 //stored value 3 in Array[1]``` now i want to make value to 0 for the total array mean Array[0] and Array[1] values will be 0 so I do it this way Code: ```Array[0] = 0 Array[1] = 0``` is there any other method to do this in 1 line?? __________________ Let's Help Each Other Last edited by soumyadip77; 10-10-2021 at 13:09. Reason: Solved
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
 10-10-2021 , 13:00   Re: Confusion With Array #2 arrayset(Array, 0, sizeof(Array))
Cristian505
Senior Member
Join Date: Oct 2020
 10-10-2021 , 13:22   Re: Confusion With Array #3 Why not Array = 0?
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
 10-10-2021 , 13:49   Re: Confusion With Array #4 Because the compiler will not know that you want to set the entire array to 0 and is going to expect an index. You can only do that for a regular variable. __________________
Natsheh
Veteran Member
Join Date: Sep 2012
 10-10-2021 , 14:23   Re: Confusion With Array #5 Try this and tell me if it works. new Array[2] = { 1, 2 }; Array = { 0, 0 }; __________________ @Jailbreak Main Mod v2.6.6 100% @User Tag Prefix 100% done ! @Mystery Box 100% done ! @VIP System 100% done !
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
10-10-2021 , 19:32   Re: Confusion With Array
#6

Quote:
 Originally Posted by Natsheh Try this and tell me if it works. new Array[2] = { 1, 2 }; Array = { 0, 0 };
It works but arrayset() should be used if setting all cells to the same number because it's more scalable and less likely to break when the array is changed in size in the future.
__________________
Senior Member
Join Date: Jul 2017
Location: INDIA,KOLKATA
10-12-2021 , 15:29   Re: Confusion With Array
#7

Quote:
 new Data[MAX_PLAYERS+1][5]; //Data[0][id] For Kill | Data[id][1] For Death | Data[2][id] For HS | Data[3][id] For Knife Kill new BestPlayerId; new BsestPlayerScore; new BestPlayerName[MAX_NAME_LENGTH]; new CvKillNeed; public plugin_init() { RegisterHookChain(RG_CBasePlayer_TakeDamage, "Damage", 1); RegisterHookChain(RG_CBasePlayer_Killed, "Killed", 1); CvKillNeed = register_cvar("amx_race", "2"); set_task(1.0, "check_score_loop", 456, _, _, "b"); } public check_score_loop() { new Players[MAX_PLAYERS] new pNum; new TempId; get_players(Players, pNum); for(new i ; i < pNum ; i++) { TempId = Players[i]; if(Data[TempId][0] == get_pcvar_num(CvKillNeed)) { BoolData[2] = 1; break } } BestPlayer(); public Killed(Vic, Att, WeaponID) { if(is_user_connected(Att) && is_user_connected(Vic) && Att != Vic) { if(get_member(Att, m_iTeam) != get_member(Vic, m_iTeam)) { if(get_member(Vic, m_bHeadshotKilled)) { Data[Att][2]++; Data[Vic][1]++; } if(rg_get_weapon_info(Att) == WEAPON_KNIFE) { Data[Att][3]++; Data[Vic][1]++; } } } } public Damage(pevVic, pevInflictor, pevAttacker, Float:flDamage, bitsDamageType) { if(is_user_connected(pevVic) && is_user_connected(pevAttacker) && pevVic !=pevAttacker) { if(get_member(pevAttacker, m_iTeam) != get_member(pevVic, m_iTeam)) { DamageStore[pevAttacker] += flDamage; } } } public BestPlayer() { new Players[MAX_PLAYERS] new pNum; new TempId; get_players(Players, pNum); for(new i ; i < pNum ; i++) { TempId = Players[i]; if(Data[TempId][0] > BsestPlayerScore) { BestPlayerId = TempId; BsestPlayerScore = Data[TempId][0]; } } }
In this How to do 2d array "Data" to set 0. And wanna end the plugin if some one reach maximum kill which is set by the "CvKillNeed" cvar i tried but not working.

Can anyone tell ho to do that ?
__________________
Let's Help Each Other
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
 10-12-2021 , 18:00   Re: Confusion With Array #8 PHP Code: ``` for ( new i = 0 ; i < sizeof( arr ) ; i++ )    arrayset( arr[ i ] , 0 , sizeof( arr[] ) );  ``` In your code where you do stuff, put a condition to not do things if kills >= the max. You can get more creative/efficient by unregistering forwards etc. __________________

 Thread Tools Display Modes Linear Mode

 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 Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Server Discussion     Source Servers (SRCDS)     HL1 Servers (HLDS) AMX Mod X     News     Bug Reports     General     Off-Topic     Plugins         Suggestions / Requests         Approved Plugins         New Plugin Submissions         Unapproved/Old Plugins         Translation Request         High-Traffic Plugins             GunGame             UAIO (Ultimate All-In-One Plugin)             xREDIRECT             CSDM             AMX Super             RuneMod             Zombie Plague Mod             SuperHero Mod                 News                 Tech Support                 Scripting Help                 Off-Topic / General Chat                 Heroes                     Suggestions / Requests                     Approved Heroes                     New Submissions                     Unapproved/Old Heroes                         Module Heroes                     SuperHero Mod Stats - By 123                 (OLD) Bug Reports     Scripting         Scripting Help         Code Snippets/Tutorials         Module Coding     Donor Access SourceMod     News     General     Plugins         Plugins         Unapproved Plugins         Plugin/Gameplay Ideas and Requests         High-Traffic Plugins             SourceMod Anti-Cheat             Zombie:Reloaded             SourceBans / SourceBans++             VSH / Freak Fortress             Store             SM_Hosties             HLstatsX:CE     Scripting     Extensions     Snippets and Tutorials     Donor Access     Metamod: Source         Metamod:Source Plugins         Metamod:Source Questions         Coding MM:S Plugins & SM Extensions Hosted Stuff     Asherkin's Plugins         TFDodgeball         TF2Items         SteamTools     Bail's Plugins         CSDM         CS:S DM Off-Topic & Trash     Off-Topic     Trash

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

 DMCA - Archive - Top