How do I make a Hit/Visited Counter

Get help using Construct 2

Post » Thu Mar 31, 2016 5:25 pm

ello :)

Im making a game (construct rocks by the way) and I want to ad a counter that tells you at the end of the game event how many times the game has been played. or in the main menu (where ever). So in html you could handle this with a mySQL database and some php i guess.

But is there a way to do it in construct 2?

The Counter is not meant to count only the "users" rounds but all rounds/ the number the "GameOver Screen" was ever opened on this domain by aaaall the players. So basically a normal hit counter.

Would be thankful for any advice ;)
Chris
Chris Hinz

Design, visual development and illustration

www.hinz-art.com
B
8
S
1
Posts: 55
Reputation: 579

Post » Mon Apr 04, 2016 3:13 pm

Yea, PHP is exactly what you need to use. Then have an atomic counter and increment it every time the game is started (or ended, whatever you want to count).
https://www.ravenheart.ca/home
I don't check the forums much anymore, but I will receive an email for PMs.

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
23
S
6
G
1
Posts: 1,419
Reputation: 4,857

Post » Mon Apr 04, 2016 3:31 pm

Thank you ;)

Sort of an update:

didn't manage to solve the problem yet :D
i find myself not figuring out a method that is googleble or easy to accomplish within Construct 2 directly. Maybe somebody will find a clever and elegant solution for a "global" hit counter one day.
Chris Hinz

Design, visual development and illustration

www.hinz-art.com
B
8
S
1
Posts: 55
Reputation: 579

Post » Thu Oct 19, 2017 10:40 pm

Found a solution? searching now, nothing to find...
B
4
S
1
Posts: 3
Reputation: 306

Post » Fri Oct 20, 2017 5:54 am

Nope, sorry to say so.
Chris Hinz

Design, visual development and illustration

www.hinz-art.com
B
8
S
1
Posts: 55
Reputation: 579

Post » Fri Oct 20, 2017 6:05 am

Unless I misunderstood the question, I think it should not be much different from making a custom online leaderboard. But instead of high scores the DB will keep only one number - the hit counter.
Here is the tutorial:
https://www.scirra.com/tutorials/346/on ... -php-mysql

Also see the AJAX section in the FAQ:
viewtopic.php?t=63692&start=0
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :)
B
17
S
9
G
68
Posts: 1,032
Reputation: 37,127

Post » Fri Oct 20, 2017 11:28 am

Thank you for the reply! This idea sounds really good. Will try it in the future, if it works i'll post it here. Thanks again!
Chris Hinz

Design, visual development and illustration

www.hinz-art.com
B
8
S
1
Posts: 55
Reputation: 579

Post » Fri Oct 20, 2017 11:53 am

got it so far, but the problem is, when I add plus one php output is not 2, it is 11...
B
4
S
1
Posts: 3
Reputation: 306

Post » Fri Oct 20, 2017 1:23 pm

@beohs, Are you adding 1 or "1"?
There is a type mismatch somewhere, either in one of the variables or the DB field. Make sure they are all integer/numeric.
You can add (int) before the variable in php to convert string to integer: (int)$x
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :)
B
17
S
9
G
68
Posts: 1,032
Reputation: 37,127

Post » Fri Oct 20, 2017 9:49 pm

B
4
S
1
Posts: 3
Reputation: 306


Return to How do I....?

Who is online

Users browsing this forum: Karpakis and 10 guests