Raised This Month: $ Target: $400
 0% 

Solved [ H3LP ] Getting from Array?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 04-11-2017 , 09:18   [ H3LP ] Getting from Array?
Reply With Quote #1

Hello, how to get direct values from a Array? For example, I want do a "filter" into the Array and only get items that can have "number" 1 or only 2.

Code:
new Array:weapon_array; enum _:WeaponData {    WeaponName[32],    WeaponNum } public plugin_precache() {    weapon_array = ArrayCreate(WeaponData); } public test() {    new eWeaponData[WeaponData];    for (new i = 0; i < ArraySize(weapon_array); i++)    {         // Here I dont know how to get...        ArrayGetArray(weapon_array, i, eWeaponData, eWeaponData[WeaponNum] == 2);    } }
__________________









Last edited by CrazY.; 04-27-2017 at 18:38.
CrazY. is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-11-2017 , 10:31   Re: [ H3LP ] Getting from Array?
Reply With Quote #2

You can't. Just retrieve the array, and check afterward.
__________________
Arkshine is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 04-11-2017 , 10:53   Re: [ H3LP ] Getting from Array?
Reply With Quote #3

Ok, I think its possible skip the loop if the number of weapon dont is equal what I need.
__________________








CrazY. is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 04-11-2017 , 11:19   Re: [ H3LP ] Getting from Array?
Reply With Quote #4

PHP Code:
new Array:weapon_name, Array:weapon_num;

public 
plugin_precache()
{
   
weapon_name ArrayCreate(32);
   
weapon_num ArrayCreate(1);
}

public 
test()
{
   new 
eWeaponName[32], wpnnum;

   for (new 
0ArraySize(weapon_name); i++)
   {
        
// Here I dont know how to get...
       
ArrayGetString(weapon_nameieWeaponName31);
       
wpnnum ArrayGetCell(weapon_numi)
   }

__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 04-11-2017 at 11:19.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 04-11-2017 , 11:30   Re: [ H3LP ] Getting from Array?
Reply With Quote #5

Maybe there's a better way of doing things here.
As long as you provide an example that is not describing your actual code accurately there's nothing we can do.

A good way to avoid loops is using custom entity values which could point to a more specific data point or even an array handle.
Perhaps there's a better way of organizing the data in the arrays to make it more accessable.
Dynamic arrays within dynamic arrays sounds like a stupid idea but can be very clever in some cases.
Tries can be used with "custom pointers" so you don't have to search.

But it all depends on what you're doing.
Also, there's no point of avoiding loops if your action is reacting to, for example, a chat command which is not frequently called.
__________________

Last edited by Black Rose; 04-11-2017 at 16:48.
Black Rose is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 04-11-2017 , 15:48   Re: [ H3LP ] Getting from Array?
Reply With Quote #6

Hmm, Ok then, I wil do some tests, after I tell the result.
__________________








CrazY. is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 04-27-2017 , 18:37   Re: [ H3LP ] Getting from Array?
Reply With Quote #7

Solved.
__________________








CrazY. is offline
Reply


Thread Tools
Display Modes

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 17:52.


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