| 06-15-2006, 05:29 PM | #2 |
Normally I would set the sorting to be by player number. That way you can detect GetPlayerId(whichplayer) for the proper number. Since player's always keep their numbers, no matter what, it's a good way of going about it. So... JASS:local integer pnum = GetPlayerId(GetOwningPlayer(GetKillingUnit())) set udg_IntAr_Kills[pnum]=udg_IntAr_Kills[pnum]+1 |
| 06-15-2006, 05:31 PM | #3 |
The whole point of the sort is to, well, have it sorted. Otherwise he wouldn't be doing it. By best suggestion would be to have a second array of all the player numbers which you 'sort' in sync with the array of number of kills. You can then get the correct position in the array for a player from this array. |
| 06-15-2006, 05:42 PM | #4 | |
@ Rising_Dusk: Yeah, thats right, the players number would never change, but the udg_IntAr_Kills will totally change through the insertion sort, so that udg_IntAr_Kills[1] can be the kills from player green (7)...AFAIK Quote:
Hmmm, I already thought of that, but didn't tried it yet, because this idea made me headache... blu_da_noob, do you perhaps already have written a trigger that way? |
| 06-15-2006, 05:45 PM | #5 |
You could always just seek the players in the player array and find that index. |
| 06-15-2006, 05:46 PM | #6 |
AHH... I see what you meant by the sort then. You're sorting them by numbers of kills, I see. Apologies, I must have misinterpreted what you were doing. What you'd need to do is have a second array where the array pointers are the player numbers, and then the values are their position in the first array. (Basically what Blu said >_>) That would allow easy access to the values in the firs array of a certain player. |
| 06-15-2006, 05:50 PM | #7 |
Erm, it appears he already has a secondary array in which he sorts players. Didn't see that. You've basically implemented my idea already, just do as weaadder said and loop through your player array to find the correct spot. |
| 06-15-2006, 05:54 PM | #8 |
@ weaaddar: You mean using if conditions in the insertion sort? Please give me some trigger examples, I'm very confused after clearing it up myself that I can't follow the players change for adding 1 to the right owner of killing unit by using this idea with udg_IntAr_Row[]... The best way to help would post this second array trigger ;) I start trying this now... -> Brain tries to think of a solution... !!!... AHH,ouch,ouch! K, I will try it, but as I said, If you have a trigger like that please show... |
| 06-15-2006, 05:59 PM | #9 |
JASS:local integer i = 0 local player p = GetOwningPlayer(GetKillingUnit()) //or whatever player you want loop exitwhen udg_IntAr_Player[i] == p set i = i + 1 endloop // i is now the correct position in the kill array to increment |
| 06-15-2006, 06:13 PM | #10 | |
K, I will try it on tomorrow, I can't think any more. But one last thing to say: In the insertion sort trigger "udg_IntAr_Kills[x]" and "udg_IntAr_Player[x]". The "x" has less to do with any player number, it is the respectively row where the values are sorted to! set udg_IntAr_Player[ B+1 ]=udg_IntAr_Player[ B ] This just set the player to the player below him... I'm so sad... I feel like I will never get that Multiboard to work *cry* I'm back tomorrow... EDIT: Quote:
Thx for your help so far... |
| 06-15-2006, 07:18 PM | #11 |
Use this instead. JASS:local integer p = GetPlayerId(GetOwningPlayer(GetKillingUnit())) |
| 06-15-2006, 07:26 PM | #12 |
I know that I can use GetPlayerID(), but I... Ah, it is so horrible, I don't understand what you say. I have really no idea how to implement this!!! When should I use this trigger? Where should I use this trigger? I have no second player array I think! I have removed those udg_IntAr_Row now, because they never worked! So how do I make a second player array? In your eyes I'm surely a complete idiot, but I know I'm not, but otherwise I don't get what you try to tell me at a whole... EDIT: udg_IntAr_Player[1] can be any player number udg_IntAr_Player[2] can be any player number . . . udg_IntAr_Player[8] can be any player number Beside that I'm using Player 1 (Red), 2 (Blue), 3, 4, 6, 7, 8 and 11 and udg_IntAr_Player[x] gets only values from 1-8??? So how should this trigger help me??? |
| 06-15-2006, 07:52 PM | #13 |
He's saying in your code, loop through all player indicies and have a SECOND array (In your case udg_IntAr_Player) that loads to it via player number all integer array locations for the other, sorted array. That way you can use the GetPlayerId() bit and then find the array location of that player in the other array, and THEN use that array location to manipulate their kills. |
| 06-16-2006, 12:39 PM | #14 |
That's seriously strange, but after looking through this thread again for arround 2 min today... I understood it! That's crazy, yesterday I understood really nothing and thought that this simple 2nd loop is something really complicated I had to transfer anyhow to my code, but now it's apparent! I only can explain this to me, because yesterday I worked arround 6 hours without break at the udg_IntAr_Row - problem before and I was fully concentrated the whole time... properly it was simply too much for one day! Anyhow for me... But here I have to thank you that you stayed tough and continued with trying to help me! Thanks Rising Dusk! that you explained probs in detail! Thanks blu da noob! that you posted this trigger example! Thanks weaaddar! that you joined this insertion sort subject of me again! I will now try to make it work! This should be done in short time! If not I'm writing back, here at my wc3editing home! Greatest Forum Ever! EDIT: Yeah, works flawlessly! ...and is such an easy solution *argh* |
