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

Need help with an engine or coding not on the list? Need help with a game or the website and forums here? Direct all questions here.
Post Reply
Torax
Posts: 169
Joined: Sun May 13, 2012 2:38 pm

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

Post by Torax »

*
Last edited by Torax on Tue Jan 02, 2018 11:24 pm, edited 1 time in total.
User avatar
Jackolantern
Posts: 10893
Joined: Wed Jul 01, 2009 11:00 pm

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

Post 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:
The indelible lord of tl;dr
Torax
Posts: 169
Joined: Sun May 13, 2012 2:38 pm

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

Post by Torax »

*
Last edited by Torax on Tue Jan 02, 2018 11:24 pm, edited 1 time in total.
User avatar
Jackolantern
Posts: 10893
Joined: Wed Jul 01, 2009 11:00 pm

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

Post by Jackolantern »

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
Torax
Posts: 169
Joined: Sun May 13, 2012 2:38 pm

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

Post by Torax »

*
Last edited by Torax on Tue Jan 02, 2018 11:25 pm, edited 2 times in total.
User avatar
Jackolantern
Posts: 10893
Joined: Wed Jul 01, 2009 11:00 pm

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

Post 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 :|
The indelible lord of tl;dr
Torax
Posts: 169
Joined: Sun May 13, 2012 2:38 pm

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

Post by Torax »

*
Last edited by Torax on Tue Jan 02, 2018 11:25 pm, edited 1 time in total.
User avatar
hallsofvallhalla
Site Admin
Posts: 12031
Joined: Wed Apr 22, 2009 11:29 pm

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

Post 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");
Torax
Posts: 169
Joined: Sun May 13, 2012 2:38 pm

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

Post by Torax »

*
Last edited by Torax on Tue Jan 02, 2018 11:26 pm, edited 1 time in total.
User avatar
hallsofvallhalla
Site Admin
Posts: 12031
Joined: Wed Apr 22, 2009 11:29 pm

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

Post 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");
Post Reply

Return to “Advanced Help and Support”