Sign in to follow this  

[web] A flash 'command prompt'

This topic is 4597 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How simple(or hard), will it be making 'flash command prompt' that allows you to type in commands then pass the entry on to a php file (from the game) for reading and for what to do next. After, it will return the answer back to the command prompt to display what happened. This application will be for a browser-based game that allows the player to 'hack' each other, buildings, etc and earn experiences for levelling up, etc, etc. Each line will be started with '>', 'C:\' (for example), and when the player press enter, it will submit the entry and the result will be displayed on the next line.

Share this post


Link to post
Share on other sites
the flash command prompt will only be used for submitting and displaying... everything will be already done in the php file, then returning the answer back for display

Share this post


Link to post
Share on other sites
Here is my code for doing it in flash



function grantitem() {
send = new LoadVars();
send.playerid = login.User;

send.pword = login.Password;

response = new LoadVars;
response.onLoad = receive;
send.sendAndLoad("http://www.addressofphpfile.com/filename.php",response,"POST");
};

function receive(result) {
if(result) {
error = response.msg;
if (response.userid > 0) {
USERID = response.userid;
hasaplayer(USERID);
}
}
else {
confirm = "ERROR - No database connection";
}
};



This sends a userID and password to PHP and then gets login information back, obviously you could change it however you wanted.

Here is the PHP code for it
DISCLAIMER: I'm not good at php so Im sure there are better ways of doing it.



<?php
mysql_pconnect ("localhost", "username", "password");

mysql_select_db ("databasename");


$Uname = $HTTP_POST_VARS['playerid'];
$Pword = $HTTP_POST_VARS['pword'];


$sql = 'SELECT `userinfo`.`userid`'.' FROM userinfo'
. ' WHERE ((`userinfo`.`username` = "'.$Uname.'") AND (`userinfo`.`password` ="'.$Pword.'")) LIMIT 0, 30';

$sqlquery = mysql_query('SELECT `userinfo`.`userid`'.' FROM userinfo'
. ' WHERE ((`userinfo`.`username` ="'.$Uname.'") AND (`userinfo`.`password` ="'.$Pword.'")) LIMIT 0, 30');



if (!mysql_query ($sql))
{

$success = 0;
$msg = mysql_error();

}
else
{



$nRows = mysql_num_rows($sqlquery);
$rString = $nRows;
if ($nRows < 1)
{
$msg = "&msg=Invalid username and/or Password";
}

for ($i=0; $i< $nRows; $i++)
{
$row = mysql_fetch_array($sqlquery);
$Userid = $row['userid'];

echo "&userid=".$Userid;
$msg = "&msg=Logged in as User ".$Uname;





Share this post


Link to post
Share on other sites

This topic is 4597 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this