AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Sorting System (https://forums.alliedmods.net/showthread.php?t=329871)

AnimalMonster 01-11-2021 04:05

Sorting System
 
Hey, i wanted to make a little sorting system by rairity and the weaponid on a weapon menu but i realised that i don t know how i should do it...
Anyone knows to show and example of a sort system other than the amxx's one?
Rarities are from 0 to 5 and weapon ids are stored into an array with size of 24.

AnimalMonster 01-11-2021 04:33

Re: Sorting System
 
This is the work i ve done so far
PHP Code:

stock PlsSort(const lala[])
{
for(new 
0g_WeaponCounti++)
{
new 
idk g_WeaponCount
new WeaponBasedOn ArrayGetCell(BasenOni)
new 
WeaponRarity ArrayGetCell(Item_Rarity)
new 
sr[idk], sb[idk]

for(new 
l=0;l<24;l++)
{
if(
WeaponBasedOn == weapon_based[l])
{
for(new 
k=0k<5;k++)
{
if(
WeaponRarity == k)
{
sr[i] = k
break;
}
sb[i] = l
}
for(new 
p=0p<g_WeaponCount;p++)
{
if(
sr[i] < sr[p] && sb[i] > sb[p])
{
lala[p] = i
}
}
}
return 
1


Would it work??

OciXCrom 01-11-2021 08:15

Re: Sorting System
 
Please, no. Simply use ArraySort() or ArraySortEx() if running AMXX dev-builds.
If you need help, show how the arrays are defined because that code is a complete mess and make no sense.

AnimalMonster 01-15-2021 03:48

Re: Sorting System
 
After a few tries i ve got to nothing and 2nd array can be this: new x[] or new x: x = ArrayCreate(num, num2).
I need to sort some items based on their rarity(5) and return it.

OciXCrom 01-15-2021 07:29

Re: Sorting System
 
Show the full array definitions.


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

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