Game replay?

Get help using Construct 2

Post » Sun Jan 08, 2012 6:49 pm

@Weishaupt, Did you see the capx.

When I said "Don't Worry I figured it out." I meant the mysql part

I also managed to do the login system, Without mySql, if you wish to see that i'll upload it soon :)
B
8
S
2
G
4
Posts: 55
Reputation: 2,555

Post » Sun Jan 08, 2012 7:06 pm

First - no, you need only ONE log, since all x,y,and z is stored there...
So if you can retreive the LOG for one named user, you should be able to play it back to him...

And Second, if a log for any named user exists on you server, you should be able to load this. maybe you want to generate a second CSV file, that hold all usernames that have been saved, so you can generate a pick list

Sorry, I am also working on the rotary challenge ;-)Weishaupt2012-01-08 19:08:24
B
42
S
19
G
12
Posts: 723
Reputation: 13,911

Post » Sun Jan 08, 2012 7:27 pm

@Weishaupt

Yeah im gonna start work on the rotary comp as soon as i finish this :)

Few more questions if its not too much trouble

Sending the data -

Curretly im sending it like this : "http://blablabla.com/post.php?name=BlaBlaBla&log="&int(tokenat(state,0,","))"

But " log="&int(tokenat(state,0,",")) is only the x.. so how do i send the rest?

Playing it back -

How am i supposed to do this?

sprite.SetX(Ajax.LastData)
sprite.SetY(Ajax.LastData)
sprite.SetAngle(Ajax.LastData)

About the naming thing im obsessed with how do i do this -
were sending a username: [name] in the PHP script, But say I have a scoreboard, how do i then search for the same name?

Would something like this work?
<?php
$username = $HTTP_GET_VARS[name];
$log = $HTTP_GET_VARS[log];
$mystring = $HTTP_GET_VARS[CurrentUser];
$findme   = $mystring;
$pos = strpos($mystring, $findme);

// Note our use of ===. Simply == would not work as expected
// because the position of 'a' was the 0th (first) character.
if ($pos === false) {
    echo "The string '$findme' was not found in the string '$mystring'";
} else {
    echo "The string '$findme' was found in the string '$mystring'";
    echo " and exists at position $pos";
}
?>

But then how would i use this string to display the data of the current user?
B
8
S
2
G
4
Posts: 55
Reputation: 2,555

Post » Sun Jan 08, 2012 7:59 pm

why dont you send the log only once at the end of the race. at this time it shoule hold all the data?
B
42
S
19
G
12
Posts: 723
Reputation: 13,911

Post » Sun Jan 08, 2012 8:14 pm

@Weishaupt
Because the log is not one object is it?

int(tokenat(State,0,","))
int(tokenat(State,1,","))
int(tokenat(State,2,","))

we have to log the data 3 times?

or am i supposed to send something else?
B
8
S
2
G
4
Posts: 55
Reputation: 2,555

Post » Sun Jan 08, 2012 8:22 pm

Also for your "registering" process there a mysql base would come in handy.
You'd make a MYSQL request SELECT to take only $username from the base.
This is why earlier I said you should learn/find documentation for it, because it is a full topic that is beyond the scope of C2's forum as it is highly depending on how you setted up your server.

But this is what you're looking for for the leaderboard/registering, etc...
The server side PHP/Mysql deals with storing/providing/processing datas of all your clients, your client deals with retrieving specific datas for a user and providing new ones (replays).
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,805

Post » Sun Jan 08, 2012 8:40 pm

@Kyatric, I looked into mySql earlier today.
My server was taking too long to download the package so i will try again later. I understand the mysql part quite well. There are lots of example's out there for setting it up.

The table would look like this:
CREATE TABLE `myDB`.`usersystem` (
`userid` INT NOT NULL AUTO_INCREMENT ,
`username` VARCHAR( 50 ) NOT NULL ,
`password` VARCHAR( 32 ) NOT NULL ,
`email` VARCHAR( 50 ) NOT NULL ,
PRIMARY KEY ( `userid` )
)

then the php like this: <?php
session_start();
mysql_connect("localhost", "username of your database", "password of database");
mysql_select_db("myDB");
function user_login ($username, $password)
{
//take the username and prevent SQL injections
$username = mysql_real_escape_string($username);
//begin the query
$sql = mysql_query("SELECT * FROM usersystem WHERE username = '".$username."' AND password = '".$password."' LIMIT 1");
//check to see how many rows were returned
$rows = mysql_num_rows($sql);
if ($rows<=0 )
{
echo "Incorrect username/password";
}
else
{
//have them logged in
$_SESSION['username'] = $username;
}
}
?>


The thing i don't quite understand is then how do i find the users name from the php that saves the replay?
B
8
S
2
G
4
Posts: 55
Reputation: 2,555

Post » Sun Jan 08, 2012 8:56 pm

It's one of the parameter sent in the url you put in your ajax request.

Send ajax request: "http://myurl.ext/myScript.php?myParam1=value&myParam2=value?myParam3=value" etc...

You set "myParamX" as you wish, it is your call, to a script that you made and will retrieve X params from its url in the $HTTP_GET_VARS array.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,805

Post » Sun Jan 08, 2012 9:07 pm

@Kyatric ,
Yeah I know im sending the [name] and log. The problem is finding that name, Im probably really confusing people now.

Essentially I want to be able to show the top 100 people's replays on the scoreboard, And the players own replays.

But thats not important right now.

I need to be able to search through the CSV for a [name] then display the specific data from that [name]

B
8
S
2
G
4
Posts: 55
Reputation: 2,555

Post » Sun Jan 08, 2012 9:16 pm

You should then check PHP references and check the strings functions.
The language has standard functions (in C2 that's system expressions ^^).

str_split can turn your string ot an array.
strpos will return the index of the first character of the search string or a default value if it is not found.
Etc... ^^Kyatric2012-01-08 21:16:41
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,805

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: gamecorpstudio, newt and 25 guests