[wap] Rock-paper-scissors For Lavalair

Started on the old forum in July 2008 · view the original in the archive · old links redirect here

22 replies · 2,769 views · started 18 years ago · 3 min read

TL;DR · summary of 22 replies
  • The code did not work due to a missing file named "rps.php".
  • The file needed to be uploaded to the web folder.
  • To resolve, the file should be renamed from whatever name it was given to "rps.php".

Written automatically from the replies by a language model on our own server. It can be wrong; the posts below are the source.

12 participants
wizard Senior · 493 posts #1
<?php
/**
* @Copyright wizard <mc_jayrulez@yahoo.com.au>
* @File: rps.php
* @param: $sid
*/
session_start();
header('Content-type: text/vnd.wap.wml');

echo '<?xml version="1.0" encoding="utf-8"?>';
echo '<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">';

echo '<wml>';

include("config.php");

include("core.php");

$bcon   = connectdb();
$sid    = $_GET['sid'];
$uid    = getuid_sid($sid);

$action = $_GET['action'];

function canplay_rps($uid)
{
    $sql = mysql_fetch_array(mysql_query("SELECT plusses FROM ibwf_users WHERE id='".$uid."'"));
    if($sql[0]>=15)
    {
        return true;
    }else{
        return false;
    }
}

function gup($uid)
{
    $sql = mysql_fetch_array(mysql_query("SELECT plusses FROM ibwf_users WHERE id='".$uid."'"));
    return $sql[0];
}

function get_winner($x,$y)
{
    if($x==1&&$y==2)
    {
        $win = 2;
    }else if($x==1&&$y==3)
    {
        $win = 1;
    }else if($x==2&&$y==1)
    {
        $win = 1;
    }else if($x==3&&$y==1)
    {
        $win = 2;
    }else if($x==2&&$y==3)
    {
        $win = 2;
    }else if($x==3&&$y==2)
    {
        $win = 1;
    }else{
        $win = 0;
    }
    
    return $win;
}

function get_left($x)
{
    switch($x)
    {
        case 1:
            $ret = 'rock_l';
        break;
        case 2:
            $ret = 'paper_l';
        break;
        case 3:
            $ret = 'scissor_l';
        break;
    }
    return $ret;
}

function get_right($x)
{
    switch($x)
    {
        case 1:
            $ret = 'rock_r';
        break;
        case 2:
            $ret = 'paper_r';
        break;
        case 3:
            $ret = 'scissor_r';
        break;
    }
    return $ret;
}

if(!$bcon)
{
    echo '<card id="main" title="Database Error">';
    echo '<p align="center">';
    echo '[img]images/notok.gif[/img]';
    echo '
';
    echo 'Database Connection Error, please try again later!';
    echo '</p>';
    echo '<p align="center">';
    echo '<a href="index.php?action=funm&sid='.$sid.'">[img]images/roll.gif[/img]';
    echo 'Fun Menu</a>';
    echo '
';
    echo '<a href="index.php?action=main&sid='.$sid.'">[img]images/home.gif[/img]';
    echo 'Home</a>';
    echo '</p>';
    echo '</card>';
    echo '</wml>';
    exit();
}

if(!islogged($sid))
{
    echo '<card id="main" title="Login Error">';
    echo '<p align="center">';
    echo '[img]images/notok.gif[/img]';
    echo '
';
    echo 'You are not logged in or your session has expired!';
    echo '
';
    echo 'Login';
    echo '</p>';
    echo '<p align="center">';
    echo '<a href="index.php?action=main&sid='.$sid.'">[img]images/home.gif[/img]';
    echo 'Home</a>';
    echo '</p>';
    echo '</card>';
    echo '</wml>';
    exit();
}

if(isbanned($uid))
{
    echo '<card id="main" title="Login Error">';
    echo '<p align="center">';
    echo '[img]images/notok.gif[/img]';
    echo '
';
    echo '';
    echo 'You are Banned
';
    echo '
';
    $sql    = "SELECT timeto, pnreas, exid 
               FROM ibwf_parusa 
               WHERE uid='".$uid."' 
               AND penalty='1' OR uid='".$uid."' 
               AND penalty='2'
              ";
    $banto  = mysql_fetch_array(mysql_query($sql));
    $banres = mysql_fetch_array(mysql_query("SELECT lastpnreas FROM ibwf_users WHERE id='".$uid."'"));
    $remain = $banto[0] - time();
    $rmsg   = gettimemsg($remain);
    echo 'Time Left: '.$rmsg.'';
    echo '
';
    $nick = getnick_uid($banto[2]);
    echo 'By: '.$nick.'';
    echo '
';
    echo 'Reason: '.$banto[1].'';
    echo '';
    echo '</p>';
    echo '<p align="center">';
    echo '<a href="index.php?action=main&sid='.$sid.'">[img]images/home.gif[/img]';
    echo 'Home</a>';
    echo '</p>';
    echo '</card>';
    echo '</wml>';
    exit();
}

if(!canplay_rps($uid))
{
    echo '<card id="main" title="Error">';
    echo '<p align="center">';
    echo '[img]images/notok.gif[/img]';
    echo '
';
    echo 'You must have atleast 15 plusses to play Rock-Paper-Scissors!';
    echo '
';
    echo '</p>';
    echo '<p align="center">';
    echo '<a href="index.php?action=funm&sid='.$sid.'">[img]images/roll.gif[/img]';
    echo 'Fun Menu</a>';
    echo '
';
    echo '<a href="index.php?action=main&sid='.$sid.'">[img]images/home.gif[/img]';
    echo 'Home</a>';
    echo '</p>';
    echo '</card>';
    echo '</wml>';
    exit();
}

if($action=='play')
{
    echo '<card id="main" title="Rock-Paper-Scissors">';
    echo '<p align="center">';
    echo '[img]images/rockps.gif[/img]';
    echo '
';
    echo 'Call: ';
    echo '<select name="op">';
    echo '<option value="1">Rock</option>';
    echo '<option value="2">Paper</option>';
    echo '<option value="3">Scissors</option>';
    echo '</select>';
    echo '
';
    echo '<anchor>[Shoot]<go href="rps.php?action=go&sid='.$sid.'" method="post">';
    echo '<postfield name="op" value="$(op)"/>';
    echo '<postfield name="init" value="1"/>';
    echo '</go></anchor>';
    echo '</p>';
    echo '<p align="center">';
    echo '<a href="index.php?action=funm&sid='.$sid.'">[img]images/roll.gif[/img]';
    echo 'Fun Menu</a>';
    echo '
';
    echo '<a href="index.php?action=main&sid='.$sid.'">[img]images/home.gif[/img]';
    echo 'Home</a>';
    echo '</p>';
    echo '</card>';
}else if($action=='go')
{
    if(isset($_POST['init'])&&$_POST['init']==1)
    {
        $op               = $_POST['op'];
        $ac               = rand(1,3);
        $res              = get_winner($op,$ac);
        $_SESSION['turn'] = isset($_SESSION['turn']) ? $_SESSION['turn'] : 1;
        $turn             = $_SESSION['turn'];
        $imgl             = get_left($op);
        $imgr             = get_right($ac);        
        $_SESSION['w']    = isset($_SESSION['w']) ? $_SESSION['w'] : 0;
        $_SESSION['l']    = isset($_SESSION['l']) ? $_SESSION['l'] : 0;
        $_SESSION['d']    = isset($_SESSION['d']) ? $_SESSION['d'] : 0;
        

        echo '<card id="main" title="Rock-Paper-Scissors">';
        echo '<p align="center">';
        echo '[img]images/rockps.gif[/img]';
        echo '
';
        echo '[img]images/'.$imgl.'.png[/img][img]images/vs.png[/img][img]images/'.$imgr.'.png[/img]';
        echo '
';
        if($res==1)
        {
            $_SESSION['w']++;
            echo 'You Won!';
            echo '
';
        }else if($res==2)
        {
            $_SESSION['l']++;
            echo 'You Lost!';
            echo '
';
        }else{
            $_SESSION['d']++;
            $_SESSION['turn']--;
            echo 'Draw!';
            echo '
';
        }
        echo '
';
        if($_SESSION['turn']<3)
        {
            echo 'Call: ';
            echo '<select name="op">';
            echo '<option value="1">Rock</option>';
            echo '<option value="2">Paper</option>';
            echo '<option value="3">Scissors</option>';
            echo '</select>';
            echo '
';
            echo '<anchor>[Shoot]<go href="rps.php?action=go&sid='.$sid.'" method="post">';
            echo '<postfield name="op" value="$(op)"/>';
            echo '<postfield name="init" value="1"/>';
            echo '</go></anchor>';
            $_SESSION['turn']++;
        }else{
            echo ''.$_SESSION['w'].':'.$_SESSION['l'].'';
            echo '
';
            echo '
';
            $xup = gup($uid);
            if($_SESSION['w']>$_SESSION['l'])
            {
                $plus = $xup + 15;
                $add = mysql_query("UPDATE ibwf_users SET plusses='".$plus."' WHERE id='".$uid."'");
                if($add)
                {
                    echo 'You Won: $15';
                    echo '
';
                    echo 'You Plusses: '.$plus.'';
                }
            }
            if($_SESSION['w']<$_SESSION['l']){
                $plus = $xup - 15;
                if($plus<0)
                {
                    $plus = 0;
                }
                $min = mysql_query("UPDATE ibwf_users SET plusses='".$plus."' WHERE id='".$uid."'");
                if($min)
                {
                    echo 'You Lost: $15';
                    echo '
';
                    echo 'You Plusses: '.$plus.'';
                }
            }
            
            unset($_SESSION['turn']);
            unset($_SESSION['w']);
            unset($_SESSION['l']);
            unset($_SESSION['d']);
            
            echo '
';
            echo '
';
            echo 'Play Again';
            echo '
';
            
        }
        echo '</p>';
        echo '<p align="center">';
        echo '<a href="index.php?action=funm&sid='.$sid.'">[img]images/roll.gif[/img]';
        echo 'Fun Menu</a>';
        echo '
';
        echo '<a href="index.php?action=main&sid='.$sid.'">[img]images/home.gif[/img]';
        echo 'Home</a>';
        echo '</p>';
        echo '</card>';
        
    }else{
        echo '<card id="main" title="Rock-Paper-Scissors">';
        echo '<p align="center">';
        echo '[img]images/rockps.gif[/img]';
        echo '
';
        echo 'Do not try to cheat here!!!';
        echo '</p>';
        echo '<p align="center">';
        echo '<a href="index.php?action=funm&sid='.$sid.'">[img]images/roll.gif[/img]';
        echo 'Fun Menu</a>';
        echo '
';
        echo '<a href="index.php?action=main&sid='.$sid.'">[img]images/home.gif[/img]';
        echo 'Home</a>';
        echo '</p>';
        echo '</card>';
    }
}else{
    echo '<card id="main" title="Rock-Paper-Scissors">';
    echo '<p align="center">';
    echo '[img]images/rockps.gif[/img]';
    echo '
';
    echo 'Think you can outmatch [bot name] at Rock Paper Scissors? Well wage 15 plusses with a payout to match to find out. The best 2 out of 3 wins!!';
    echo '
';
    echo 'If you think you got what it takes, click below:';
    echo '
';
    echo 'Play Now';
    echo '</p>';
    echo '<p align="center">';
    echo '<a href="index.php?action=funm&sid='.$sid.'">[img]images/roll.gif[/img]';
    echo 'Fun Menu</a>';
    echo '
';
    echo '<a href="index.php?action=main&sid='.$sid.'">[img]images/home.gif[/img]';
    echo 'Home</a>';
    echo '</p>';
    echo '</card>';
}

echo '</wml>';

?>
Attachments: images.zip
subzero Super moderator Fellow · 3,954 posts #2

Nice share dont mind i use it 😉

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

bluebell Junior · 15 posts #5

hi it dont work l get 

The requested URL /web/rps.php was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

subzero Super moderator Fellow · 3,954 posts #6

pls name that game to rps.php

so it will work

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

bluebell Junior · 15 posts #7

pls name that game to rps.php

so it will work

echo "<a href="rps.php?action=rps&sid=$sid">»paper game</a> ";

still dnt work subz

WhiteWarrior Principal · 1,419 posts #9

echo "<a href="rps.php?action=rps&sid=$sid">»paper game</a> ";

still dnt work subz

When you copyed the coding to notpad and then clicked save as.. what did you name it? because it has to be named rps.php

// thanks for the share Wizard 🙂

laro696 Developer · 205 posts #10

hi it dont work l get 

The requested URL /web/rps.php was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

From the looks of it, you didn't copy the file into your web folder

bluebell Junior · 15 posts #11

From the looks of it, you didn't copy the file into your web folder

sortd now oopz l didnt rename the file sorry guys itz workin now

metulj Super moderator Principal · 1,726 posts #12

wow nice update for lava script 🙂 thanks wizard 😀

It's better to keep your mouth shut and give the impression that you're stupid, than to open it and remove all doubt. ⓣⓗⓔ ⓠⓤⓘⓔⓣⓔⓡ ⓨⓞⓤ ⓑⓔ©ⓞⓜⓔ, ⓣⓗⓔ ⓜⓞⓡⓔ ⓨⓞⓤ ⓐⓡⓔ ⓐⓑⓛⓔ ⓣⓞ ⓗⓔⓐⓡ ! ιη тнєσяу, тнє ρяα¢тι¢є ιѕ α яєѕυℓт σƒ тнє тнєσяу, вυт ιη ρяα¢тι¢є ιѕ тнє σρρσѕιтє.

キノgんイノ刀g 4 ア乇ムc乇 ノ丂 レノズ乇 キucズノ刀g 4 √ノ尺gノ刀ノイリ!

Guest #13

Nice Tanx bro 😛

Guest #14

Good game. x)

johnny Junior · 47 posts #16

😮 its cool game but anyone having it in html version

Learner lolz

metulj Super moderator Principal · 1,726 posts #17

QUOTE (johnny @ Jan 10 2009, 10:03 AM) <{POST_SNAPBACK}>

😮 its cool game but anyone having it in html version

if you mean Xhtml.. it takes MAX 10 minutes to convert it... if you got smoke brake inbetween... 🤔

It's better to keep your mouth shut and give the impression that you're stupid, than to open it and remove all doubt. ⓣⓗⓔ ⓠⓤⓘⓔⓣⓔⓡ ⓨⓞⓤ ⓑⓔ©ⓞⓜⓔ, ⓣⓗⓔ ⓜⓞⓡⓔ ⓨⓞⓤ ⓐⓡⓔ ⓐⓑⓛⓔ ⓣⓞ ⓗⓔⓐⓡ ! ιη тнєσяу, тнє ρяα¢тι¢є ιѕ α яєѕυℓт σƒ тнє тнєσяу, вυт ιη ρяα¢тι¢є ιѕ тнє σρρσѕιтє.

キノgんイノ刀g 4 ア乇ムc乇 ノ丂 レノズ乇 キucズノ刀g 4 √ノ尺gノ刀ノイリ!

johnny Junior · 47 posts #18

i added this for xhtml but in this shoot option dont work in xhtml so need a bit help n hoow must i add game in fun menu</br>CODE<?php include("config.php"); include("core.php"); connectdb(); $action=$_GET["action"]; $id=$_GET["id"]; $sid = $_GET["sid"]; $rid=$_GET["rid"]; $rpw=$_GET["rpw"]; $brws = explode(" ",$HTTP_USER_AGENT); $ubr = $brws[0]; $uip = getip(); $who = $_GET["who"];

$uid = getuid_sid($sid);

echo "<html xmlns="http://www.w3.org/1999/xhtml">\n"; echo "<head>\n"; echo "<title>FriendsZone</title>"; echo "<meta http-equiv="Cache-Control" content="max-age=0">\n";

$thid = mysql_fetch_array(mysql_query("SELECT thid FROM ibwf_mypage WHERE uid='".$uid."'")); if($thid[0]==""||$thid[0]==0)$thid[0]=1; $thinfo = mysql_fetch_array(mysql_query("SELECT bgc, txc, lnk, hdc, hbg FROM ibwf_themes WHERE id='".$thid[0]."'")); echo "<style type="text/css">"; echo "body {background-color:#$thinfo[0]; color:#$thinfo[1]}"; echo "h3 {background-color:#$thinfo[4]; color:#$thinfo[3]}"; echo "a:link {color:#$thinfo[2]}"; echo "a:visited {color:#$thinfo[2]}"; echo "</style>";

echo "</head>\n"; echo "<body>\n";

$bcon = connectdb(); if (!$bcon) { echo "<img src="../images/exit.gif" alt="*"/> "; echo "ERROR! cannot connect to database

"; echo "This error happens usually when backing up the database, please be patient, The site will be up any minute

"; echo "you can temperoray be in this site <a href="http://chatheaven.wen.ru">$site_name</a> while $site_name is offline "; echo "THANK YOU VERY MUCH"; echo " "; echo "</html>"; echo "</body>"; exit(); } $brws = explode(" ",$_SERVER[HTTP_USER_AGENT] ); $ubr = $brws[0]; $uip = getip(); $action = $_GET["action"]; $sid = $_GET["sid"]; $page = $_GET["page"]; $who = $_GET["who"];

$uid = getuid_sid($sid);

connectdb();

//clearnc(); $action=$_GET["action"]; $id=$_GET["id"]; $sid = $_GET["sid"]; $botid = "eeb070e74e366473"; $input = $_POST["input"]; $custid=$_POST["custid"]; $hostname = "www.pandorabots.com"; $hostpath = "/pandora/talk-xml"; if(islogged($sid)==false) { echo " "; echo "You are not logged in "; echo "Or Your session has been expired

"; echo "<a href="index.php">Login</a>"; echo " "; echo "</body>"; echo "</html>"; exit(); } $uid = getuid_sid($sid); if(isbanned($uid)) { echo " "; echo "<img src="images/notok.gif" alt="x"/> "; echo "You are Banned "; $banto = mysql_fetch_array(mysql_query("SELECT timeto FROM ibwf_penalties WHERE uid='".$uid."' AND penalty='1'")); $remain = $banto[0]- time(); $rmsg = gettimemsg($remain); echo "Time to finish your penalty: $rmsg

"; //echo "<a href="index.php">Login</a>"; echo " "; echo "</body>"; echo "</html>"; exit(); } function canplay_rps($uid) {

$sql = mysql_fetch_array(mysql_query("SELECT plusses FROM ibwf_users WHERE id='".$uid."'"));
if($sql[0]>=15)
{
	return true;
}else{
	return false;
}

}

function gup($uid) { $sql = mysql_fetch_array(mysql_query("SELECT plusses FROM ibwf_users WHERE id='".$uid."'")); return $sql[0]; }

function get_winner($x,$y) { if($x==1&&$y==2) { $win = 2; }else if($x==1&&$y==3) { $win = 1; }else if($x==2&&$y==1) { $win = 1; }else if($x==3&&$y==1) { $win = 2; }else if($x==2&&$y==3) { $win = 2; }else if($x==3&&$y==2) { $win = 1; }else{ $win = 0; }

return $win;

}

function get_left($x) { switch($x) { case 1: $ret = 'rock_l'; break; case 2: $ret = 'paper_l'; break; case 3: $ret = 'scissor_l'; break; } return $ret; }

function get_right($x) { switch($x) { case 1: $ret = 'rock_r'; break; case 2: $ret = 'paper_r'; break; case 3: $ret = 'scissor_r'; break; } return $ret; }

if(!$bcon) { echo '<card id="main" title="Database Error">'; echo ' '; echo 'External image (may be gone)'; echo ' '; echo 'Database Connection Error, please try again later!'; echo ' '; echo ' '; echo 'External image (may be gone)'; echo 'Fun Menu'; echo ' '; echo 'External image (may be gone)'; echo 'Home'; echo ' '; echo '</card>'; echo '</html>'; exit(); }

if(!islogged($sid)) { echo '<card id="main" title="Login Error">'; echo ' '; echo 'External image (may be gone)'; echo ' '; echo 'You are not logged in or your session has expired!'; echo ' '; echo 'Login'; echo ' '; echo ' '; echo 'External image (may be gone)'; echo 'Home'; echo ' '; echo '</card>'; echo '</html>'; exit(); }

if(isbanned($uid)) { echo '<card id="main" title="Login Error">'; echo ' '; echo 'External image (may be gone)'; echo ' '; echo ''; echo 'You are Banned '; echo ' '; $sql = "SELECT timeto, pnreas, exid FROM ibwf_parusa WHERE uid='".$uid."' AND penalty='1' OR uid='".$uid."' AND penalty='2' "; $banto = mysql_fetch_array(mysql_query($sql)); $banres = mysql_fetch_array(mysql_query("SELECT lastpnreas FROM ibwf_users WHERE id='".$uid."'")); $remain = $banto[0] - time(); $rmsg = gettimemsg($remain); echo 'Time Left:'.$rmsg.''; echo ' '; $nick = getnick_uid($banto[2]); echo 'By:'.$nick.''; echo ' '; echo 'Reason:'.$banto[1].''; echo ''; echo ' '; echo ' '; echo 'External image (may be gone)'; echo 'Home'; echo ' '; echo '</card>'; echo '</html>'; exit(); }

if(!canplay_rps($uid)) { echo '<card id="main" title="Error">'; echo ' '; echo 'External image (may be gone)'; echo ' '; echo 'You must have atleast 15 plusses to play Rock-Paper-Scissors!'; echo ' '; echo ' '; echo ' '; echo 'External image (may be gone)'; echo 'Fun Menu'; echo ' '; echo 'External image (may be gone)'; echo 'Home'; echo ' '; echo '</card>'; echo '</html>'; exit(); }

if($action=='play') { echo '<card id="main" title="Rock-Paper-Scissors">'; echo ' '; echo 'External image (may be gone)'; echo ' '; echo 'Call: '; echo '<select name="op">'; echo '<option value="1">Rock</option>'; echo '<option value="2">Paper</option>'; echo '<option value="3">Scissors</option>'; echo '</select>'; echo ' '; echo '<anchor>[Shoot]<go href="rps.php?action=go&amp;sid='.$sid.'" method="post">'; echo '<postfield name="op" value="$(op)"/>'; echo '<postfield name="init" value="1"/>'; echo '</go></anchor>'; echo ' '; echo ' '; echo 'External image (may be gone)'; echo 'Fun Menu'; echo ' '; echo 'External image (may be gone)'; echo 'Home'; echo ' '; echo '</card>'; }else if($action=='go') { if(isset($_POST['init'])&&$_POST['init']==1) { $op = $_POST['op']; $ac = rand(1,3); $res = get_winner($op,$ac); $_SESSION['turn'] = isset($_SESSION['turn']) ? $_SESSION['turn'] : 1; $turn = $_SESSION['turn']; $imgl = get_left($op); $imgr = get_right($ac); $_SESSION['w'] = isset($_SESSION['w']) ? $_SESSION['w'] : 0; $_SESSION['l'] = isset($_SESSION['l']) ? $_SESSION['l'] : 0; $_SESSION['d'] = isset($_SESSION['d']) ? $_SESSION['d'] : 0;

	echo '<card id="main" title="Rock-Paper-Scissors">';
	echo '

'; echo 'External image (may be gone)'; echo ' '; echo 'External image (may be gone)External image (may be gone)External image (may be gone)'; echo ' '; if($res==1) { $_SESSION['w']++; echo 'You Won!'; echo ' '; }else if($res==2) { $_SESSION['l']++; echo 'You Lost!'; echo ' '; }else{ $_SESSION['d']++; $_SESSION['turn']--; echo 'Draw!'; echo ' '; } echo ' '; if($_SESSION['turn']<3) { echo 'Call: '; echo '<select name="op">'; echo '<option value="1">Rock</option>'; echo '<option value="2">Paper</option>'; echo '<option value="3">Scissors</option>'; echo '</select>'; echo ' '; echo '<anchor>[Shoot]['; echo '<postfield name="op" value="$(op)"/>'; echo '<postfield name="init" value="1"/>'; echo '</go></anchor>'; $_SESSION['turn']++; }else{ echo ''.$_SESSION['w'].':'.$_SESSION['l'].''; echo ' '; echo ' '; $xup = gup($uid); if($_SESSION['w']>$_SESSION['l']) { $plus = $xup + 15; $add = mysql_query("UPDATE ibwf_users SET plusses='".$plus."' WHERE id='".$uid."'"); if($add) { echo 'You Won: $15'; echo ' '; echo 'You Plusses: '.$plus.''; } } if($_SESSION['w']<$_SESSION['l']){ $plus = $xup - 15; if($plus<0) { $plus = 0; } $min = mysql_query("UPDATE ibwf_users SET plusses='".$plus."' WHERE id='".$uid."'"); if($min) { echo 'You Lost: $15'; echo ' '; echo 'You Plusses: '.$plus.''; } }

		unset($_SESSION['turn']);
		unset($_SESSION['w']);
		unset($_SESSION['l']);
		unset($_SESSION['d']);
		
		echo '

'; echo ' '; echo '[url="rps.php?action=play&sid='.$sid.'"]Play Again](#)'; echo ' ';

	}
	echo '

'; echo ' '; echo '<a href="index.php?action=funm&amp;sid='.$sid.'">External image (may be gone)'; echo 'Fun Menu'; echo ' '; echo 'External image (may be gone)'; echo 'Home'; echo ' '; echo '</card>';

}else{
	echo '<card id="main" title="Rock-Paper-Scissors">';
	echo '

'; echo 'External image (may be gone)'; echo ' '; echo 'Do not try to cheat here!!!'; echo ' '; echo ' '; echo 'External image (may be gone)'; echo 'Fun Menu'; echo ' '; echo 'External image (may be gone)'; echo 'Home'; echo ' '; echo '</card>'; } }else{ echo '<card id="main" title="Rock-Paper-Scissors">'; echo ' '; echo 'External image (may be gone)'; echo ' '; echo 'Think you can outmatch [bot name] at Rock Paper Scissors? Well wage 15 plusses with a payout to match to find out. The best 2 out of 3 wins!!'; echo ' '; echo 'If you think you got what it takes, click below:'; echo ' '; echo 'Play Now'; echo ' '; echo ' '; echo 'External image (may be gone)'; echo 'Fun Menu'; echo ' '; echo 'External image (may be gone)'; echo 'Home'; echo ' '; echo '</card>'; }

echo '</html>';

?>

Learner lolz

wizard Senior · 493 posts #19

For the ppl asking for xhtml version. u need to add ur own stylesheet though

<?php

/**
* @Copyright wizard <mc_jayrulez@yahoo.com.au>
* @File: rps.php
* @param: $sid
*/
session_start();
header('Content-type: text/html');

echo '<?xml version="1.0" encoding="utf-8"?>';
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
echo '<html xmlns="http://www.w3.org/1999/xhtml">';

function head($title='Rock-Paper-Scissors')
{
    echo '
    <head>
        <title>'.$title.'</title>
        <meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
        <link rel="stylesheet" href="style.css" type="text/css"/>
    </head>
    <body>
        ';
}

include("config.php");

include("core.php");

$bcon   = connectdb();
$sid    = $_GET['sid'];
$uid    = getuid_sid($sid);

$action = $_GET['action'];

function canplay_rps($uid)
{
    $sql = mysql_fetch_array(mysql_query("SELECT plusses FROM ibwf_users WHERE id='".$uid."'"));
    if($sql[0]>=15)
    {
        return true;
    }else{
        return false;
    }
}

function gup($uid)
{
    $sql = mysql_fetch_array(mysql_query("SELECT plusses FROM ibwf_users WHERE id='".$uid."'"));
    return $sql[0];
}

function get_winner($x,$y)
{
    if($x==1&&$y==2)
    {
        $win = 2;
    }else if($x==1&&$y==3)
    {
        $win = 1;
    }else if($x==2&&$y==1)
    {
        $win = 1;
    }else if($x==3&&$y==1)
    {
        $win = 2;
    }else if($x==2&&$y==3)
    {
        $win = 2;
    }else if($x==3&&$y==2)
    {
        $win = 1;
    }else{
        $win = 0;
    }
    
    return $win;
}

function get_left($x)
{
    switch($x)
    {
        case 1:
            $ret = 'rock_l';
        break;
        case 2:
            $ret = 'paper_l';
        break;
        case 3:
            $ret = 'scissor_l';
        break;
    }
    return $ret;
}

function get_right($x)
{
    switch($x)
    {
        case 1:
            $ret = 'rock_r';
        break;
        case 2:
            $ret = 'paper_r';
        break;
        case 3:
            $ret = 'scissor_r';
        break;
    }
    return $ret;
}

if(!$bcon)
{
    head('Database Error');
    echo '<p align="center">';
    echo '[img]images/notok.gif[/img]';
    echo '
';
    echo 'Database Connection Error, please try again later!';
    echo '</p>';
    echo '<p align="center">';
    echo '<a href="index.php?action=funm&sid='.$sid.'">[img]images/roll.gif[/img]';
    echo 'Fun Menu</a>';
    echo '
';
    echo '<a href="index.php?action=main&sid='.$sid.'">[img]images/home.gif[/img]';
    echo 'Home</a>';
    echo '</p>';
    echo '</body>';
    echo '</html>';
    exit();
}

if(!islogged($sid))
{
    head('Login Error');
    echo '<p align="center">';
    echo '[img]images/notok.gif[/img]';
    echo '
';
    echo 'You are not logged in or your session has expired!';
    echo '
';
    echo 'Login';
    echo '</p>';
    echo '<p align="center">';
    echo '<a href="index.php?action=main&sid='.$sid.'">[img]images/home.gif[/img]';
    echo 'Home</a>';
    echo '</p>';
    echo '</body>';
    echo '</html>';
    exit();
}

if(isbanned($uid))
{
    head('Login Error');
    echo '<p align="center">';
    echo '[img]images/notok.gif[/img]';
    echo '
';
    echo '';
    echo 'You are Banned
';
    echo '
';
    $sql    = "SELECT timeto, pnreas, exid 
               FROM ibwf_parusa 
               WHERE uid='".$uid."' 
               AND penalty='1' OR uid='".$uid."' 
               AND penalty='2'
              ";
    $banto  = mysql_fetch_array(mysql_query($sql));
    $banres = mysql_fetch_array(mysql_query("SELECT lastpnreas FROM ibwf_users WHERE id='".$uid."'"));
    $remain = $banto[0] - time();
    $rmsg   = gettimemsg($remain);
    echo 'Time Left: '.$rmsg.'';
    echo '
';
    $nick = getnick_uid($banto[2]);
    echo 'By: '.$nick.'';
    echo '
';
    echo 'Reason: '.$banto[1].'';
    echo '';
    echo '</p>';
    echo '<p align="center">';
    echo '<a href="index.php?action=main&sid='.$sid.'">[img]images/home.gif[/img]';
    echo 'Home</a>';
    echo '</p>';
    echo '</body>';
    echo '</html>';
    exit();
}

if(!canplay_rps($uid))
{
    head('Error');
    echo '<p align="center">';
    echo '[img]images/notok.gif[/img]';
    echo '
';
    echo 'You must have atleast 15 plusses to play Rock-Paper-Scissors!';
    echo '
';
    echo '</p>';
    echo '<p align="center">';
    echo '<a href="index.php?action=funm&sid='.$sid.'">[img]images/roll.gif[/img]';
    echo 'Fun Menu</a>';
    echo '
';
    echo '<a href="index.php?action=main&sid='.$sid.'">[img]images/home.gif[/img]';
    echo 'Home</a>';
    echo '</p>';
    echo '</body>';
    echo '</html>';
    exit();
}

if($action=='play')
{
    head();
    echo '<p align="center">';
    echo '[img]images/rockps.gif[/img]';
    echo '
';
    echo '<form action="rps.php?action=go&sid='.$sid.'" method="post">';
    echo 'Call: ';
    echo '<select name="op">';
    echo '<option value="1">Rock</option>';
    echo '<option value="2">Paper</option>';
    echo '<option value="3">Scissors</option>';
    echo '</select>';
    echo '
';
    echo '<input type="hidden" name="init" value="1"/>';
    echo '<input type="submit" value="Shoot"/>';
    echo '</form>';
    echo '</p>';
    echo '<p align="center">';
    echo '<a href="index.php?action=funm&sid='.$sid.'">[img]images/roll.gif[/img]';
    echo 'Fun Menu</a>';
    echo '
';
    echo '<a href="index.php?action=main&sid='.$sid.'">[img]images/home.gif[/img]';
    echo 'Home</a>';
    echo '</p>';
    echo '</body>';
}else if($action=='go')
{
    if(isset($_POST['init'])&&$_POST['init']==1)
    {
        $op               = $_POST['op'];
        $ac               = rand(1,3);
        $res              = get_winner($op,$ac);
        $_SESSION['turn'] = isset($_SESSION['turn']) ? $_SESSION['turn'] : 1;
        $turn             = $_SESSION['turn'];
        $imgl             = get_left($op);
        $imgr             = get_right($ac);        
        $_SESSION['w']    = isset($_SESSION['w']) ? $_SESSION['w'] : 0;
        $_SESSION['l']    = isset($_SESSION['l']) ? $_SESSION['l'] : 0;
        $_SESSION['d']    = isset($_SESSION['d']) ? $_SESSION['d'] : 0;
        

        head();
        echo '<p align="center">';
        echo '[img]images/rockps.gif[/img]';
        echo '
';
        echo '[img]images/'.$imgl.'.png[/img][img]images/vs.png[/img][img]images/'.$imgr.'.png[/img]';
        echo '
';
        if($res==1)
        {
            $_SESSION['w']++;
            echo 'You Won!';
            echo '
';
        }else if($res==2)
        {
            $_SESSION['l']++;
            echo 'You Lost!';
            echo '
';
        }else{
            $_SESSION['d']++;
            $_SESSION['turn']--;
            echo 'Draw!';
            echo '
';
        }
        echo '
';
        if($_SESSION['turn']<3)
        {
            echo '<form action="rps.php?action=go&sid='.$sid.'" method="post">';
            echo 'Call: ';
            echo '<select name="op">';
            echo '<option value="1">Rock</option>';
            echo '<option value="2">Paper</option>';
            echo '<option value="3">Scissors</option>';
            echo '</select>';
            echo '
';
            echo '<input type="hidden" name="init" value="1"/>';
            echo '<input type="submit" value="Shoot"/>';
            echo '</form>';
            $_SESSION['turn']++;
        }else{
            echo ''.$_SESSION['w'].':'.$_SESSION['l'].'';
            echo '
';
            echo '
';
            $xup = gup($uid);
            if($_SESSION['w']>$_SESSION['l'])
            {
                $plus = $xup + 15;
                $add = mysql_query("UPDATE ibwf_users SET plusses='".$plus."' WHERE id='".$uid."'");
                if($add)
                {
                    echo 'You Won: $15';
                    echo '
';
                    echo 'You Plusses: '.$plus.'';
                }
            }
            if($_SESSION['w']<$_SESSION['l']){
                $plus = $xup - 15;
                if($plus<0)
                {
                    $plus = 0;
                }
                $min = mysql_query("UPDATE ibwf_users SET plusses='".$plus."' WHERE id='".$uid."'");
                if($min)
                {
                    echo 'You Lost: $15';
                    echo '
';
                    echo 'You Plusses: '.$plus.'';
                }
            }
            
            unset($_SESSION['turn']);
            unset($_SESSION['w']);
            unset($_SESSION['l']);
            unset($_SESSION['d']);
            
            echo '
';
            echo '
';
            echo 'Play Again';
            echo '
';
            
        }
        echo '</p>';
        echo '<p align="center">';
        echo '<a href="index.php?action=funm&sid='.$sid.'">[img]images/roll.gif[/img]';
        echo 'Fun Menu</a>';
        echo '
';
        echo '<a href="index.php?action=main&sid='.$sid.'">[img]images/home.gif[/img]';
        echo 'Home</a>';
        echo '</p>';
        echo '</body>';
        
    }else{
        head();
        echo '<p align="center">';
        echo '[img]images/rockps.gif[/img]';
        echo '
';
        echo 'Do not try to cheat here!!!';
        echo '</p>';
        echo '<p align="center">';
        echo '<a href="index.php?action=funm&sid='.$sid.'">[img]images/roll.gif[/img]';
        echo 'Fun Menu</a>';
        echo '
';
        echo '<a href="index.php?action=main&sid='.$sid.'">[img]images/home.gif[/img]';
        echo 'Home</a>';
        echo '</p>';
        echo '</body>';
    }
}else{
    head();
    echo '<p align="center">';
    echo '[img]images/rockps.gif[/img]';
    echo '
';
    echo 'Think you can outmatch [bot name] at Rock Paper Scissors? Well wage 15 plusses with a payout to match to find out. The best 2 out of 3 wins!!';
    echo '
';
    echo 'If you think you got what it takes, click below:';
    echo '
';
    echo 'Play Now';
    echo '</p>';
    echo '<p align="center">';
    echo '<a href="index.php?action=funm&sid='.$sid.'">[img]images/roll.gif[/img]';
    echo 'Fun Menu</a>';
    echo '
';
    echo '<a href="index.php?action=main&sid='.$sid.'">[img]images/home.gif[/img]';
    echo 'Home</a>';
    echo '</p>';
    echo '</body>';
}

echo '</html>';

?>
rukiya Lead · 569 posts #20

It can be coded in short by applying some maths in it like

<?php
/*****************
Rock , Paper , Scissors Game
By
DNS
[url]http://forum.wapfuns.com[/url]
******************/
$choice = $_POST["choice"];
if($choice!="")
{
$select = array ("Rock" , "Paper" , "Scissors");
$computer = rand(0,2);
echo "You chose $select[$choice] .
";
echo "Computer chose $select[$computer] .
";
$result = $choice - $computer;

if($result == 1 || $result == -2)
{
echo "You Win :)";
}
else if($result==0)
{
echo "Draw !";
}
else
{
echo "You lose :(";
}
exit();
}
?>
<html>
<head><title> Rock Paper Scissors Game By DNS</title></head>
<body>
Choose

<form action ="<?php $PHP_SELF;?>" method="post">
<select name ="choice">
<option value ="0" selected>Rock</option>
<option value ="1">Paper</option>
<option value ="2">Scissors</option>
</select>
<input type="submit" value="Play">
</form>
</body>
</html>

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close