Unstoppable Domains

PHP and AJAX

Spacemail by SpaceshipSpacemail by Spaceship
Watch

klavixs

Account Closed
Impact
6
i need some help this one has been my beast for the past month.ive been putting it off cuase i dont know where to start so here it is.

What im trying to do:

I needed a rpg like battle fucntion that is asyncrnous(if spelled right).
what i mean is lets say :
person a is online
and
person b is online

person a click attack button to attack person b
person a waits a few seconds for the result (while)
person b finds out person a wants to fight and confirms the battle
then person a now knows the fight is on and
person a enters battle screen and also person b enters battle screen

--now each person has stats that is the variable for speed but for example lets says a set timer for each player--

{Player a must wait 3 seconds between attacks}
{player b must wait 2 seconds between attacks}

player a hits player b and both players instantly now how much damage was served
--please note this is all instant realtime using ajax(not my specialty)--

so anyways each player will continue hitting each other till one is dead and each must wait there set wait time before next hit

so i hope this part is understood

so what i need from the willing and intelligent programmers here is a example i will edit later for usage with the rest of my code. i would ask it be in php and ajax but others is fine i can at least get the logic of it.

i appreciate any help and if you have any questions please ask
i just need a basic script in php and ajax (others if needed((im using a mysql also)) ) that can do this and is all realtime(ajax).

Thank you all for your help
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Not trying to be mean but if your an expert in javascript and php like your signature says all you need is this bite of code

Code:
function makeRequest(urlgo,next) {
	        
        
        var http_request = false;

        if (window.XMLHttpRequest) { // Mozilla, Safari, ...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
                // See note below about this line
            }
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
		}

        if (!http_request) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }
        http_request.onreadystatechange = function() { alertContents(http_request,urlgo,next); };
        http_request.open('GET', urlgo, true);
        http_request.send(null);

    }

    function alertContents(http_request,url,next) {
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
               //Do something with the returned data							
            } 
			else {
                alert('There was a problem with the request.'+http_request.readyState+' = = = '+next+'==='+http_request.status);
            }
        }

    }

This just sends a get command to a url and returns data based on your php code. I'm not an expert at javascript or anything else but this should help
 
1
•••
Code:
I am Expert in:HTML, PHP, ASP, ASP.NET, JAVASCRIPT, VBSCRIPT, XML, XHTML, CSS, ACTIONSCRIPT, JAVA, FLASH, RUBY, PERL, CGI, MYSQL, MSSQL, PGSQL, and ACCESS. i Specialize in doing whats believed to be impossible in programming. I'm constantly improving my skills and adding new languages to my knowledge.And I Don't cost much
PHP:
i Specialize in doing whats believed to be impossible in programming.
this code will help you.
 
0
•••
haha
 
0
•••
You say your an expert in flash/action script. Use that it would be much better!

Thank
 
0
•••
i am

i am expert in javscript but the ajax framework is very new to me.

o and ironmonkey i am an expert in flash/actionscript but i dont wish to use a language like flash or java in this project the reason i cant tell right now but overall i need this site usable by everybody include kids at school or library computer and flash is an intentional no install on those for just that reason that kids play games online so i wish it to be in languages that dont require install new tools like flash or java

and randyhenson i see youve made a basic ajax beginnings but nevertheless you are the only person that wished to help instead of looking for a way to riducule people.So i aprreciate that.
would you mind helping me make a basic attack funcition with this im not sure how to go about it i understand sending php data using onreadystate and returning data from it but im just wiped out by thi whole project and could use a hand ive been doing this whole thing by myself and its huge and is on its 2 month of development.

I appreciate you help so far randyhenson +rep more to come if your willing to help more
 
0
•••
Alrighty, Mr. Expert:

Set yourself up a mootools package. (Just make sure you choose AJAX, and it should give you the files you need.)

Their AJAX framework is very easy to understand and you should be able to figure it out from their demos. I use an old version, so I can't help too much with the new one, but it is VERY simple.

When the person attacks, you have to add the attack to your MySQL database and have the JS script check for new attacks or whatever every second or however you want to do it. Your PHP file will do all the work; the JS file will just call the PHP file.
 
0
•••
for this to work for more than just a few users at a time, you're going to need a lot of resources...

unfortunately, with AJAX, in order for person A to see results of what person B does, person A needs to continuously poll the server to see if there are any updates from person B. This is called a client-server-client model. The client has to constantly ask the server if there is new information.

If you want instant updates, a JAVA app is much better since the server can send updates to a persistently connected client, and bandwidth and connections don't have to be wasted on constantly asking for info.
 
0
•••
Dynadot โ€” .com Registration $8.99Dynadot โ€” .com Registration $8.99
Appraise.net
Unstoppable Domains
Domain Recover
DomainEasy โ€” Zero Commission
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back