Login to game before start

Get help using Construct 2

Post » Sat Dec 08, 2012 3:04 am

And, of course, showing them their stats is all well and good. But there also needs to be an easy way to update a stat.

Here is the php code for that as well...Here

Then ensure it updates the stats in the game to show the new stat score.

For example:

Mouse -> on right button clicks on object 1 -> Ajax -> Post to : "http://localhost/wwxmmo/addexp.php?username="& UsernameTxt.Text & "&password=" & PasswordTxt.Text (tag "addexp")

Ajax->On "addexp" completed -> Ajax ->Request: "http://localhost/wwxmmo/getstats.php?username="& user

Ajax-> On "getstats" completed -> [Text]stat1 -> Set text to Ajax.Lastdata

Simple as that. The user clicks on an object, our game Posts a command to php. Php updates the database. When the ajax command finishes a request is sent to retrieve the updated stat from the database, we assign that stat to a text object and the new stat is then displayed in the game.

droptank212012-12-08 03:09:16
B
22
S
9
G
3
Posts: 203
Reputation: 3,647

Post » Mon Dec 24, 2012 4:32 am

@droptank21

Good day, thank you for the idea, its really helpful.

I have a question. How to filter the user when they login?
Like for example on your database there is user level which is "admin and user".

When user login it will redirect to user page. And when admin login it will redirect to admin page.
B
16
S
2
Posts: 21
Reputation: 869

Post » Sat Dec 29, 2012 2:29 am

You would create a new column in sql for level. Then much as the stats query you would query the user's level and assign the result to a global variable. Then simply assign an event that will check the user's level and set the system to go to one layout for a user and another seperate layout for admin.
Tinker around with the stats php code and you'll get the hang of it.
B
22
S
9
G
3
Posts: 203
Reputation: 3,647

Post » Tue Jan 01, 2013 1:17 pm

@droptank21

Hi droptank21.

I have tried to get it to work but i am unsuccesfull.
I understand your capx and php codes are correct, and that my knowledge is simply missing on how to integrate this onto the server.

I have tried:
Creating a database. (succesfull)
Adding the database.sql to the phpmyadmin "sql" section (succesfull)
Modding the php files with my database login data. (succesfull)
Uploading the php files to my server. (public_html/wwxmmo)
Uploading the capx to my server. (public_html/Login)

And the result is that i get a register failure and a login failure.
Do u have any idea what i am doing wrong?

Kind regards.
Savvy001

B
56
S
20
G
13
Posts: 778
Reputation: 13,204

Post » Tue Jan 01, 2013 2:51 pm

Did you change the ajax request url's in the C2 capx to match the url's of the php pages on your web server?

Example:

"http://localhost/wwxmmo/login.php?username="& UsernameTxt2.Text & "&password=" & PasswordTxt2.Text

To

"http://savvy001.com/wwxmmo/login.php?username="& UsernameTxt2.Text & "&password=" & PasswordTxt2.Text

Be sure to check the syntax of your ajax code as well. Specifically ensuring there are spaces after the ampersands (&) denoting the data.
(&_UsernameTxt2.Text &_)

droptank212013-01-01 15:16:38
B
22
S
9
G
3
Posts: 203
Reputation: 3,647

Post » Tue Jan 01, 2013 4:59 pm

Il be checking in to that tomorow, and i will report back to u!
Thanx for the help.
B
56
S
20
G
13
Posts: 778
Reputation: 13,204

Post » Thu Jan 03, 2013 3:35 am

@droptank21,

Thanks for the Idea, I made it. I can login with user and admin account.
B
16
S
2
Posts: 21
Reputation: 869

Post » Thu Jan 03, 2013 3:53 am

@droptank21,

I tried to run your loginsystem on my desktop browser. And notice that the error message is not showing when I input wrong account. How to fix this?

edited: What I am trying to say is, the error will not show if I open in localhost/loginsystem but in localhost:50000 it will open.
george2013-01-03 09:28:13
B
11
S
3
G
2
Posts: 40
Reputation: 2,362

Post » Fri Jan 04, 2013 4:39 am

Hi all, I'm a newbie in construct 2. Now, I'm using construct 2 as main project for my thesis, because my thesis is about developing cloud gaming for windows 8. I'm so thankful that I found this article about login system before start the game. I already downloaded the .capx and tried to do register, it worked, but I have to move the "system -> go to [I]login[/I] layout" in ajax "on register completed" event to "mouse -> on object clicked (register)" event to prevent the register error. and when I tried to call the user and pass from database in login page, it didn't work. I don't know how. Do you have any solution? I already changed the URL too. thanks guys :)
B
3
Posts: 5
Reputation: 285

Post » Fri Jan 04, 2013 10:36 am

I think you need to post your event here. So we know what is the problem on your events.
B
11
S
3
G
2
Posts: 40
Reputation: 2,362

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 18 guests