A problem that can't be solved......
A problem that can't be solved......
*
Last edited by Torax on Tue Jan 02, 2018 11:24 pm, edited 1 time in total.
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: A problem that can't be solved......
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!
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!
The indelible lord of tl;dr
Re: A problem that can't be solved......
*
Last edited by Torax on Tue Jan 02, 2018 11:24 pm, edited 1 time in total.
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: A problem that can't be solved......
You could also just perform the +1 to 0 thing in PHP code, and then process it as needed
The indelible lord of tl;dr
Re: A problem that can't be solved......
*
Last edited by Torax on Tue Jan 02, 2018 11:25 pm, edited 2 times in total.
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: A problem that can't be solved......
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
The indelible lord of tl;dr
Re: A problem that can't be solved......
*
Last edited by Torax on Tue Jan 02, 2018 11:25 pm, edited 1 time in total.
- hallsofvallhalla
- Site Admin
- Posts: 12023
- Joined: Wed Apr 22, 2009 11:29 pm
Re: A problem that can't be solved......
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......
*
Last edited by Torax on Tue Jan 02, 2018 11:26 pm, edited 1 time in total.
- hallsofvallhalla
- Site Admin
- Posts: 12023
- Joined: Wed Apr 22, 2009 11:29 pm
Re: A problem that can't be solved......
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");