Closed Ubiquitous-X closed 9 years ago
Probably, but we need to specify your goal. I gather that you are trying to detect awards changing hands?
Yes. When update. php is run, and before it writes to awardOutput.txt, I would need it to check if there is a new #1 in each award, and get the player name and the award name out to a string, before it writes the new awardOutput.txt Of course not all changed rankings, only "if award = new awardwinner; do my code". All I need is that string, the rest of the code I manage.
måndag 13 juli 2015 skrev Patrick Dinklage notifications@github.com:
Probably, but we need to specify your goal. I gather that you are trying to detect awards changing hands?
— Reply to this email directly or view it on GitHub https://github.com/pdinklag/MinecraftStats/issues/6#issuecomment-120822628 .
Skickat från Gmail Mobile
Well, there is currently no means to parse the award output, but you could simply load the old $awardsFile
into something like $oldAwards
before the new awards file is saved (in the //Save awards
block):
$oldAwards = unserialize(file_get_contents($awardsFile));
Then, you could add a comparison to the loop, like:
if ( $awards[$id]['id'] != $oldAwards[$id]['id'] ) { /* new award winner */ }
Yeah, id is ambiguous - the $id
variable refers to the stat's ID within the loop, whereas an award's value for 'id'
is the UUID of the player holding it.
Anyway, unless you can figure it out quickly, I can offer a code sample tomorrow.
That seems to be a very good solution, I think I'll try to implement that code when I get home. I can read code, and cut anf paste, but have hard time writing it myself. This seems like I understand how to implement.
måndag 13 juli 2015 skrev Patrick Dinklage notifications@github.com:
Well, there is currently no means to parse the award output, but you could simply load the old $awardsFile into something like $oldAwards before the new awards file is saved (in the //Save awards block).
Then, you could add a comparison to the loop, like: if ( $awards[$id]['id'] != $oldAwards[$id]['id'] ) { /* new award winner */ }
Yeah, id is ambiguous - the $id variable refers to the stat's ID within the loop, whereas an award's value for 'id' is the UUID of the player holding it.
Anyway, unless you can figure it out quickly, I can offer a code sample tomorrow.
— Reply to this email directly or view it on GitHub https://github.com/pdinklag/MinecraftStats/issues/6#issuecomment-120845980 .
Skickat från Gmail Mobile
I am so close to the solution, but not 100%. There is actually no loop in the //Save awards
block, but in //Create award output
.
I created a loop before //Save awards
that successfully grabs the name of the new winner, and the raw stat name of the correct stat.
Of what I understand there is two options from here:
A) Make my new loop associate the stat.name with the correct award name.
B) Implement the $awardsFile
comparison in //Create award output
.
I am not succeeding in any of those. Maybe you have the solution?
The loop i created was:
`$oldAwards = unserialize(file_get_contents($awardsFile));
foreach($awards as $id => $newWinner) {
if ( $awards[$id]['id'] != $oldAwards[$id]['id'] ) {
echo (getPlayerName($newWinner['id'])); //The player name works correct
echo $id; //Need to convert the raw stat name to the award name
}
}
Yep, I meant the award output loop. Just the loading of the old awards file should happen before saving the new one.
This is something you might be able to help me with in an easy way. When running the update.php I also need it to do:
foreach (awardwinner) that differs from the awardwinner in the awardsOutput.txt {