Printable Version of Topic
Click here to view this topic in its original format
DimensioneX Forum > Developers' Pub > Timed Response On The Client Side?


Posted by: HobbyCoder Apr 9 2012, 01:15 AM
I may be willing to pay someone a little via Paypal for help with this.

The Developers Reference, on page 14, describes "Custom Client Behavior." Among other things, it says:

"The important step is to figure out what needs to be modified to produce the desired effect. A little trial and error will help, but you can ask for help at the Developer's Pub forum."

I would like to customize the client behavior a little: As a first step, I would like some characters to be presented to the client for 2 seconds, timed on the client side. I would like the client to have an opportunity to click a button or something during that 2 seconds to acknowledge the characters. Then, I would like to wait a while before showing the characters again, and the process would repeat about 10 times. At the end of the 10 cycles, the client would send a message to the server communicating what percentage was acknowledged.

Does anyone want to make a little money via Paypal by helping me to do this?

Posted by: HobbyCoder Apr 9 2012, 02:21 AM
I just sent a $20 donation to cris@dimensionex.net via PayPal under the name uniquegeek@earthlink.net to show that I am serious about paying for this help.

Posted by: HobbyCoder Apr 9 2012, 02:37 AM
Maybe I'll post this on Elance.com.

Posted by: HobbyCoder Apr 9 2012, 03:07 AM
The job is now listed elance.com for under $500 if anyone wants to bid on it:


(edited the link)
https://www.elance.com/php/bid/main/proposalList.php?jobid=29766475

Posted by: Cris Apr 9 2012, 02:40 PM
Hi HobbyCoder, thanks for your contribution.

Yes it is possible to let client and server interact via Javascripts.

The server can communicate with any external script via the HOOKS feature, which is based on standard HTTP GET/POST communication.

If you're able to build up the skeleton on the game it should be easy to add a timed call to let the game switch the characters.

Please let us know what you already have got running, it will be easier to help you have it working.

Posted by: HobbyCoder Apr 29 2012, 09:09 PM
QUOTE (Cris @ Apr 9 2012, 02:40 PM)
Hi HobbyCoder, thanks for your contribution.

Yes it is possible to let client and server interact via Javascripts.

The server can communicate with any external script via the HOOKS feature, which is based on standard HTTP GET/POST communication.

If you're able to build up the skeleton on the game it should be easy to add a timed call to let the game switch the characters.

Please let us know what you already have got running, it will be easier to help you have it working.

Thanks for the reply.

I've done the following so far to the underworld files:

I added the following code to commons.dxl right above EVENT doFindObj(obj)

EVENT doTestHook(testNum)
Print testNum
End_EVENT


I added the following code to underworld.dxw under GUI

HOOKS findobj=doFindObj,viewitem=doViewItem,expertswitch=doExpertSwitch,testHook=doTestHook

I also have simple we page which interacts with the above hook and times the user's response to the web page:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Web Page</title>
<script language="javascript" type="text/javascript">

var start_program_in_seconds = 10;
var next_op_called_in_seconds = 3;

var opportunitiesGiven = 0
var opportunityKnocks = false
var opportunityTaken = false
var successes = 0




function giveOpportunities() {
setTimeout("oneOfFiveOpportunites()", start_program_in_seconds * 1000);
}

function oneOfFiveOpportunites() {
if (opportunitiesGiven < 5) {
opportunityKnocks = true;
ShowHideX(true);
setTimeout("nextOpportunity()", next_op_called_in_seconds * 1000);
}
else {
//show alert message to see how many times user clicks 'a' key
window.location = "http://(my server address is here
)/dimx/servlet/multiplayer?game=3&cmd=testHook&testNum=" + successes;
}
}
function nextOpportunity() {
ShowHideX(false);

opportunityKnocks = false;
opportunitiesGiven += 1;
if (opportunityTaken == true)
{
successes = successes + 1;
opportunityTaken = false;
}
giveOpportunities();
}

function ShowHideX(flag) {
if(flag)
document.getElementById("divX").innerHTML = "X";
else
document.getElementById("divX").innerHTML = "";
}
function IncrementSuccess(event) {

if (event.keyCode == "65") {
if (opportunityKnocks == true) {
opportunityTaken = true;
}
}
}
</script>
</head>
<body onload='giveOpportunities();' onKeyUp='IncrementSuccess(event);' onKeyDown='IncrementSuccess(event);'>
<div id="divX" style="color:Red; font-size:larger"></div>
</body>
</html>

***************************

This successfully displays an 'X' on the screen for intervals of a few seconds at a time, and counts the number of successful times that the user pressed the 'a' key while the X was showing. At the end of 5 trials, the web page calls the hook with the number of successes. The hook responds right now in a pretty meaningless way. It prints the number of successes.

Here is my first question: How can I integrate that kind of functionality into the game interface? Can I just add another frame or something?

(After that, I would like to make the hook response more meaningful, like changing a particular player's game statistics when the hook is called. I know that there is a security issue. I plan to assign each player a long number ending in 2 zeros. Then, I can add the number of successes to the player number and pass that to the hook. If a player thinks that their number has been compromised, they would hopefully be able to request and enter a new one.)

Posted by: Cris May 1 2012, 01:16 PM
Very clever.

I think you have successfully implemented an asynchronous call to the game engine via the Hook feature. Also, you have good skills in javascript.

Now, it is still hard for me to understand what you're aiming at, and this limits much the chance for me to suggest you good solutions.
Perhaps we can chat via Skype and you could let me understand more (sending my skype contact to you via PM).

Back to your question: I think the better way to implement advanced interactivity is to use Ajax (there is an ajax package incldued in DimensioneX), since you can easily communicate to the game engine with HTTP hooks.
This results in very user friendly behaviour and clean implemetnation.

About security: If any HTTP conversation is initated by the player's browser, the player's ID is reckognized automatically so the responding script "knows" who the player is. You don't actually have to pass anything to reckognize the player.

Hope this helped


Posted by: HobbyCoder May 6 2012, 07:41 PM
QUOTE (Cris @ May 1 2012, 01:16 PM)
Very clever.

I think you have successfully implemented an asynchronous call to the game engine via the Hook feature. Also, you have good skills in javascript.

Now, it is still hard for me to understand what you're aiming at, and this limits much the chance for me to suggest you good solutions.
Perhaps we can chat via Skype and you could let me understand more (sending my skype contact to you via PM).

Back to your question: I think the better way to implement advanced interactivity is to use Ajax (there is an ajax package incldued in DimensioneX), since you can easily communicate to the game engine with HTTP hooks.
This results in very user friendly behaviour and clean implemetnation.

Thanks. I figured it out yesterday, though. All I had to do was set the world to use the bannerized client, set the banner src to little web page above, and replace the key press with a button press.

Now I'd like to figure out how to do something meaningful with the 'testNum' sent to the server with the hooks feature, such as changing the player's strength in the event instead of just printing the testNum.

Thanks again.

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)