Page 1 of 1

A problem that can't be solved......

Posted: Thu Jan 03, 2013 4:54 am
by Torax
*

Re: A problem that can't be solved......

Posted: Thu Jan 03, 2013 5:36 am
by Jackolantern
I think you need a MySQL conditional keyword, such as IF, so that you can say something like "if value = 0, value = 1" (pseudocode). I have never done this in MySQL, but have in SQL Server where conditionals play a more natural role in T-SQL. But they can be done in MySQL with just a bit harrier syntax. Check out that article, and see if that helps.

Otherwise, you could rethink the way the scoring works, where perhaps everyone starts at a baseline, say 100. Each kill adds to it, and each death takes away from it. It would not be a clean ratio, but it could be more flexible to future modifications such as adding in games where other scoring elements could be involved (like capturing a flag). Hope this helps! :cool:

Re: A problem that can't be solved......

Posted: Thu Jan 03, 2013 9:18 am
by Torax
*

Re: A problem that can't be solved......

Posted: Thu Jan 03, 2013 8:23 pm
by Jackolantern
You could also just perform the +1 to 0 thing in PHP code, and then process it as needed :)

Re: A problem that can't be solved......

Posted: Thu Jan 03, 2013 8:42 pm
by Torax
*

Re: A problem that can't be solved......

Posted: Fri Jan 04, 2013 1:03 am
by Jackolantern
Hmmm, I see what you mean. You would have to pull all records and then do the calculations, which would nullify the LIMIT clause. I will have to think about this one :|

Re: A problem that can't be solved......

Posted: Fri Jan 04, 2013 2:41 am
by Torax
*

Re: A problem that can't be solved......

Posted: Thu Jan 17, 2013 5:38 pm
by hallsofvallhalla
Try this statement...It changes 0 to a little less than 1 so it is just higher than someone with 1.

Code: Select all

$topquery = doquery("SELECT * FROM {{table}} ORDER BY CASE WHEN deaths = 0 THEN kills / .99999 ELSE kills/deaths  DESC LIMIT 50", "users");

Re: A problem that can't be solved......

Posted: Thu Jan 17, 2013 10:16 pm
by Torax
*

Re: A problem that can't be solved......

Posted: Thu Jan 17, 2013 10:54 pm
by hallsofvallhalla
hmm for giggles sake try that. Not sure if it will work.

Code: Select all

$topquery = doquery("SELECT * FROM {{table}} ORDER BY CASE WHEN deaths = 0 THEN kills / .99999 WHEN deaths = 0 AND kills = 0 then .01 ELSE kills/deaths  DESC LIMIT 50", "users");