Raised This Month: $ Target: $400
 0% 

Solved [ H3LP ] Position by votes


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DarthMan
Veteran Member
Join Date: Aug 2011
Old 07-12-2017 , 16:08   Re: [ H3LP ] Position by votes
Reply With Quote #1

Quote:
Originally Posted by HamletEagle View Post
A basic way of sorting an array is:
PHP Code:
new array[100], aux
for(new isizeof array - 1i++)
{
    for(new 
1sizeof array; j++)
    {
        if(array[
i] > array[j])
        {
            
aux = array[i]
            array[
i] = array[j]
            array[
j] = aux
        
}
    }

To reverse the sorting order, change > to <. Apply that to your votes array.
Ideally you would have an array that contains both the votes and the map name, by using an enum. Then you sort the array by the points and on the first/last slot(depending on how you sort) will be the most voted map name.
Thanks, jsut seen this now
DarthMan is offline
SpawnerF
Member
Join Date: Apr 2017
Location: Morocco
Old 07-12-2017 , 17:26   Re: [ H3LP ] Position by votes
Reply With Quote #2

@HamletEagle, it would be better if it's in a stock function and don't specify the array size.

You can use something like that:

Code:
stock sortedArray(arr[], size = sizeof arr) {     new temp;         for (new i = 0; i < size; i++)     {         for (new j = 0; j < size - 1; j++)         {             if (arr[j] > arr[j + 1])             {                 temp = arr[j + 1];                 arr[j + 1] = arr[j];                 arr[j] = temp;             }         }     }     }

You can use it like that :

Code:
new     arr[ ] = { 12345, 123, 12, 1234567, 123456789, 123456 } ; sortedArray(arr)     for(new i; i < sizeof arr; i++ ) {     server_print("%d", arr[ i ]); }
__________________
XX was created just for giving evidence and not meant to damage public servers.
&We do not test on public servers.
Thank's.

Last edited by SpawnerF; 07-12-2017 at 17:42.
SpawnerF is offline
DarthMan
Veteran Member
Join Date: Aug 2011
Old 07-13-2017 , 02:58   Re: [ H3LP ] Position by votes
Reply With Quote #3

Quote:
Originally Posted by SpawnerF View Post
@HamletEagle, it would be better if it's in a stock function and don't specify the array size.

You can use something like that:

Code:
stock sortedArray(arr[], size = sizeof arr) {     new temp;         for (new i = 0; i < size; i++)     {         for (new j = 0; j < size - 1; j++)         {             if (arr[j] > arr[j + 1])             {                 temp = arr[j + 1];                 arr[j + 1] = arr[j];                 arr[j] = temp;             }         }     }     }

You can use it like that :

Code:
new     arr[ ] = { 12345, 123, 12, 1234567, 123456789, 123456 } ; sortedArray(arr)     for(new i; i < sizeof arr; i++ ) {     server_print("%d", arr[ i ]); }
Hamlet's emthod worked, but it's better with a stock. I ropdered the votes, but now, how can I order the map names depending on the votes so that the map with most votes will be placed first?
DarthMan is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 07-12-2017 , 18:48   Re: [ H3LP ] Position by votes
Reply With Quote #4

Didnt i already solved that for you??
Seems that you dont listen...
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
DarthMan
Veteran Member
Join Date: Aug 2011
Old 07-13-2017 , 02:23   Re: [ H3LP ] Position by votes
Reply With Quote #5

Quote:
Originally Posted by Natsheh View Post
Didnt i already solved that for you??
Seems that you dont listen...
Hi and nope, it didn't work. Your method on the other plug-in added them in the order fo attacking not in the roder of the health. And this is different, it adds by votes, and the hud issue not lsiting all maps seemed to be due to the dhud having a buffer limit of 128, but with normal hudmessage there is no way to make the hud message static to not dissapear.

Last edited by DarthMan; 07-13-2017 at 02:26.
DarthMan is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-13-2017 , 03:17   Re: [ H3LP ] Position by votes
Reply With Quote #6

I told you in my post how to design this.
__________________
HamletEagle is offline
DarthMan
Veteran Member
Join Date: Aug 2011
Old 07-13-2017 , 03:37   Re: [ H3LP ] Position by votes
Reply With Quote #7

Quote:
Originally Posted by HamletEagle View Post
I told you in my post how to design this.
Yeah, and I was able to do it for votes, but now I want to assign the mapname depending on the vote.
So basically I was only able to sort the votes, but I want to sort the position fo the maps depending on the votes as well.
About enum, I don't know how to do it correctly since an array has a 1D size and the other has a 2D size, and if I'm not mistaken enum only supports 1D arrays.

Last edited by DarthMan; 07-13-2017 at 04:13.
DarthMan 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 23:08.


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