Jump to content
  • Advertisement
Sign in to follow this  
ENEX

[web] A flash 'command prompt'

This topic is 4843 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
Advertisement
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
your just sending and geting variables then, its basicly a flash/php chat thing...

Preaty easy to make.

Share this post


Link to post
Share on other sites
If the PHP handles everything, then all you have to do is send the messages you want to display to the swf file and then append it to a variable in the flash and then display the string.

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!