Pkillers
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Pkillers

The forum home of Pkillers
 
HomeHome  PortalPortal  SearchSearch  Latest imagesLatest images  RegisterRegister  Log in  

 

 Making a PKillers clone

Go down 
4 posters
AuthorMessage
Shinynew

Shinynew


Number of posts : 32
Registration date : 2007-01-11

Making a PKillers clone Empty
PostSubject: Making a PKillers clone   Making a PKillers clone EmptySun Jan 21, 2007 12:47 am

I have took it upon myself to make a PKillers clone.

Lets start with nothing. First hosting. To really start with nothing you can just host it from my own PC, so if you are behind a router you will have to figure out how to make it direct HTTP requests to your machine. I cant help with that.

Step two: Get a hosting program, what i used is XAMPP This comes with apache, PHP, MYsql and much more easily installed. here: http://www.apachefriends.org/en/xampp.html

Step Three: Either learn how to use ajax/javascript to take commands from a box or whatever and post them interacting with a PHP script or just rip off of PKillers (I did the latter, hopefull syn isnt mad...)
(I made just one javascript file that can do it all just cutting stuff out of both the PKillers scripts)
Easy script:
Code:
   var net = new Object();
var strin;
var box;
var activity;
var update;
var lastcommand;
var allText = "";
var updateOff = false;
function Initialize() {
  strin = document.getElementById("strin");
  box = document.getElementById("box");
  strin.onkeydown = keyCheck;
  strin.focus();
  setInterval(updateCheck, 100);
  }
function displayMessage(str) {
  if(str.replace(" ", "") != "") append(str);
  }
net.interface = function(url, data, callback) {
  var XHR = null;
  if(window.XMLHttpRequest) XHR = new XMLHttpRequest();
  else if (window.ActiveXObject) XHR = new ActiveXObject("MicrosoftXMLHTTP");
  XHR.open("POST", url, true);
  XHR.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  if(callback) {
      XHR.onreadystatechange = function() {
        if(XHR.readyState == 4 && XHR.status == 200) {
            //if(XHR.responseText.replace(" ", "") != "")
            callback.call(null, XHR.responseText);
            }
        }
      }
  XHR.send(data);
  }
net.getKey = function(e) {
  var keyCode = - 1;
  if(window.event) keyCode = event.keyCode;
  else keyCode = e.which;
  return keyCode;
  }
function keyCheck(e) {
  if(net.getKey(e) == 13) {
      sendCommand(strin.value);
      strin.select();
      }
  }
function sendCommand(com) {
  if(!updateOff) net.interface("c.php", "command=" + com, displayMessage);
  activity.style.display = "inline";
  }
function append(str) {
  allText = allText + str;
  http://box.innerHTML = box.innerHTML + str;
  box.innerHTML = allText;
  box.scrollTop = box.scrollHeight;
  stripDisplay(30000);
  }

Checklist:
Web hosting working (try going to 127.0.0.1 and see if its working)
The javascript you need (if you hand code it extra points)
A text editor
Some knowledge of how programing should work.

Ok so now that you can send commands useing ajax to a PHP file, what do you do now?

Setting up the PHP file:

Code:
<?php
// This will import GET and POST vars
// with an "a_" prefix
import_request_variables("gP", "a_");
echo $a_command;
?>
This will now show you whatever text you sent. Major progress.
Useing this you now have the command and now we just have to figure out how to use PHP!

01/02/07 - all I have done so far

Ok Lets get the PHP to write to a log file, then everyone can read from it and see what has happened (including a time stamp)
So i have set up two diffrent php files now:
File one:
Code:
<?php
include 'write.php'; //includes the other php file
import_request_variables("gP", "a_"); //Imports the data from the JS
echo "<br />"; //makes a new line
echo $a_command; //shows then what they typed
write("log.txt",$a_command, $username); //calls a function from the other file
?>
File two:
Code:

<?php
function write($filename, $somecontent, $username){
$t = time();
$somecontent = "$t.$somecontent
";//this adds the time stamp to the content and a line return
if (!$handle = fopen($filename, 'a')) {
        echo "Cannot open file ($filename)";
        exit;
  }

  // Write $somecontent to our opened file.
  if (fwrite($handle, $somecontent) === FALSE) {
      echo "Cannot write to file ($filename)";
      exit;
  }
 
  fclose($handle);
  }

Now we still need to read the file back so everyone can see it, after this we just need to make it grab all the lines that it has not read and interpet them into commands. (at this point it will first branch into a chatroom type thing and later on the Pkillersclone)


Last edited by on Sun Jan 21, 2007 4:17 pm; edited 5 times in total
Back to top Go down
Shinynew

Shinynew


Number of posts : 32
Registration date : 2007-01-11

Making a PKillers clone Empty
PostSubject: Re: Making a PKillers clone   Making a PKillers clone EmptySun Jan 21, 2007 12:48 am

Reserved
Back to top Go down
AcidBurn




Number of posts : 17
Registration date : 2007-01-11

Making a PKillers clone Empty
PostSubject: Re: Making a PKillers clone   Making a PKillers clone EmptySun Jan 21, 2007 8:58 pm

Seems very interesting. I don't have time to read it all now (or try out the code), but tomorrow I can. Keep up the good work.

Do you have any idea on a scope document? What you're version of Pkillers might do that the current on doesn't?
Back to top Go down
Janook

Janook


Number of posts : 34
Age : 40
Localisation : Northern California
Registration date : 2007-01-14

Making a PKillers clone Empty
PostSubject: Re: Making a PKillers clone   Making a PKillers clone EmptyTue Jan 23, 2007 12:01 am

I've been trying to create this:

Write two simple pages with php and mysql:
Page 1) A simple login page with a password. Users create a name/password and can use it to login whenever they want. (so we gotta store the login/password somehow)

Page 2) A simple text field. Users can roll a 3 sided die. If they roll a 1: Their "Brain" gets +1. If they roll a 2, their "Muscles" get a +1. If they roll a 3, Both brain and muscles get a -1. (So each user has a name,pass, brain, and muscle data field. Brain and Muscle are saved, so they are the same the next time the user logs in)

Then i gotta learn ajax / javascript.
Back to top Go down
http://janook.strangled.net
Shinynew

Shinynew


Number of posts : 32
Registration date : 2007-01-11

Making a PKillers clone Empty
PostSubject: Re: Making a PKillers clone   Making a PKillers clone EmptySun Jan 28, 2007 3:03 am

@Janook
tutorial for PHP + MySQL user database (I havent read it) http://www.tutorialized.com/tutorial/Login-Logout-with-a-Session-in-1-file/20041

and useing the javascript file i posted you just have to learn a tiny bit of php + Mysql to do it.
If you want me to I can try and make that site for you (all of this I am learning on the go, and i have lots of other stuff to do, so im a bit slow at it)

and sorry for not updating this, i haven't worked on it in a while, also my router screwed up and now my site isn't accessible, so i may take this time to set up a machine just for web hosting, which will increase the wait alot. If anyone is interested in this, or has any questions please email me @ firstuser29(at)gmail.com because i don't read this forum to much anymore.
Back to top Go down
MariusAgricola




Number of posts : 3
Registration date : 2007-01-20

Making a PKillers clone Empty
PostSubject: Re: Making a PKillers clone   Making a PKillers clone EmptyWed Jan 31, 2007 10:04 am

I was thinking about this more extensively, because I wanted to test this concept out in a Ruby on Rails application to see if it was possible, and I remembered that there is another trick that you could use for something like this. Instead of reinventing the wheel, you could pretty easily grab the code for one of the many MUDs out there (there are some pretty simple ones available, bare bones and all) and just use the web app as a glorified telnet client. Programming a web-based telnet client is much easier than building the entire game, plus you could have extra functionality out of the box. The only down side to this approach is that you sacrifice the simplicity of the game and may have to modify a bunch of alien source code to add and remove functionality.

And anyway, even if you didn't want to take that route fully, I don't see any reason why you couldn't write the back-end yourself and use the same concept otherwise.

Now it's just a matter of determining what languages are best suited to this kind of work (making the back-end). C is undeniably the fastest (most big-name MUDs are written in pure C) and (usually) most resource-efficient, but has the disadvantage of having a higher learning curve than newer languages. On the other end is Java, and I probably don't have to tell you that it's quite a bit heavier than other languages as far as resources go. That leaves the usual suspects: PHP, Perl, and Ruby. Theoretically, as mentioned above, it just doesn't matter what the back-end is written in, as long as it can be made to listen for incoming connections and accept commands in a standard format (such as that provided by telnet ala vt100 and friends).

I hope this doesn't sound hopelessly backward, but after all, those of you who are still playing this game ARE playing a text-based game in your web browsers Razz
Back to top Go down
Sponsored content





Making a PKillers clone Empty
PostSubject: Re: Making a PKillers clone   Making a PKillers clone Empty

Back to top Go down
 
Making a PKillers clone
Back to top 
Page 1 of 1
 Similar topics
-
» About Synapz
» Pkillers down?
» PKillers 2.0 release date
» Ideas for PKillers 2.0 and possible solution to botting

Permissions in this forum:You cannot reply to topics in this forum
Pkillers :: Discussion :: General Specifics-
Jump to: