Jump to content
MakeWebGames

How to make person say something else after you beat quest?


Recommended Posts

Posted

I developed my first quest, a quest where a pesky kid asks you for crayons, you buy them, and give them to him, and he gives you experience.

However, if you refresh the page, he will ask you for crayons again, and you could just go and buy more of them, to get lots of experience.

How could I make it so after you give him the crayons once, he would say, "Thank you for the crayons!" or something like that, so you can't give him anymore?

This is the crayonquest.php page, if you need the crayonquestbuy.php page, just tell me.

<?

include "globals.php";

if($ir['crayon'] == 0)

{

die("Pesky Kid: Buy me some crayons!");

}

else

{

if($ir['crayon'] == 1)

{

//set $win prize winings

$win=rand(10,170);

$loss=rand(10,276);

if(rand(1,30) <= 14)

{

print "Pesky Kid: Hey, thanks! Here's some experience that I mysteriously have! *You gained $win experience!";

$db->query("UPDATE users SET crayon=0 WHERE userid=$userid",$c);

$db->query("UPDATE users SET exp=exp+$win WHERE userid=$userid",$c);

}

else

{

if(rand(1,30) <= 15)

{

print "Pesky Kid: Hey, thanks! Here's some experience that I mysteriously have! *You gained $win experience!";

$db->query("UPDATE users SET crayon=0 WHERE userid=$userid",$c);

$db->query("UPDATE users SET exp=exp+$win WHERE userid=$userid",$c);

}

else

{

if(rand(1,30) <= 5)

{

print "Pesky Kid: Hey, thanks! Here's some experience that I mysteriously have! *You gained $win experience!";

$db->query("UPDATE users SET crayon=0 WHERE userid=$userid",$c);

$db->query("UPDATE users SET exp=exp+$win WHERE userid=$userid",$c);

Posted

Re: How to make person say something else after you beat quest?

next time please use the code tags please :)

and this should work but i'm not sure

first run this sql

ALTER TABLE `users` ADD `crayonquest` TINYINT NOT NULL DEFAULT '0';

then use this code

<?
include "globals.php";
if($ir['crayonquest'] == 1)
{
die("you've already done this quest");
}
else
{
if($ir['crayon'] == 0)
{
die("Pesky Kid: Buy me some crayons!");
}
else
{
if($ir['crayon'] == 1)
{
//set $win prize winings
$win=rand(10,170);
$loss=rand(10,276);
if(rand(1,30) <= 14)
{
print "Pesky Kid: Hey, thanks! Here's some experience that I mysteriously have! *You gained $win experience!";

$db->query("UPDATE users SET crayon=0 WHERE userid=$userid",$c);
$db->query("UPDATE users SET exp=exp+$win WHERE userid=$userid",$c);
$db->query("UPDATE users SET crayonquest=1 WHERE userid=$userid",$c);
}
else
{
if(rand(1,30) <= 15)
{
print "Pesky Kid: Hey, thanks! Here's some experience that I mysteriously have! *You gained $win experience!";

$db->query("UPDATE users SET crayon=0 WHERE userid=$userid",$c);
$db->query("UPDATE users SET exp=exp+$win WHERE userid=$userid",$c);
$db->query("UPDATE users SET crayonquest=1 WHERE userid=$userid",$c);
}
else
{
if(rand(1,30) <= 5)
{
print "Pesky Kid: Hey, thanks! Here's some experience that I mysteriously have! *You gained $win experience!";

$db->query("UPDATE users SET crayon=0 WHERE userid=$userid",$c);
$db->query("UPDATE users SET exp=exp+$win WHERE userid=$userid",$c);
$db->query("UPDATE users SET crayonquest=1 WHERE userid=$userid",$c); 

 

not tested. also it's not super effecient but i believe that it will work

Posted

Re: How to make person say something else after you beat quest?

Didn't work...here are both codes as of right now:

Crayonquestbuy.php

<?php
include "globals.php";
print "<h3>Buy some crayons for that pesky kid, or visit him [url='crayonquest.php'][<u>here!</u>][/url]</h3>";
print "
<table border=2><th>Item</th><th>Price</th><th>Purchase</th>
<tr>
<td>Crayons</td><td>$30</td><td>[url='crayonquestbuy.php?spend=crayon']Buy[/url]</td></table>";
if($_GET['spend'] == 'crayon') 
{ 
if($ir['money'] <30) 
{ 
print "You don't have enough money!"; 
} 
else 
{ 
if($ir['money'] >30) 
{ 
print "You bought the crayons! Yippie!

[url='index.php']Go Home[/url]

[url='crayonquest.php']Go to the pesky kid[/url]"; 
$db->query("UPDATE users SET money=money-30,crayon=1 WHERE userid=$userid",$c); 
} 
} 
}
$h->endpage(); 
?>

 

Crayonquest.php

<?
include "globals.php";
if($ir['crayonquest'] == 1)
{
die("you've already done this quest");
}
else
{
if($ir['crayon'] == 0)
{
die("Pesky Kid: Buy me some crayons!");
}
else
{
if($ir['crayon'] == 1)
{
//set $win prize winings
$win=rand(10,170);
$loss=rand(10,276);
if(rand(1,30) <= 14)
{
print "Pesky Kid: Hey, thanks! Here's some experience that I mysteriously have! *You gained $win experience!";

$db->query("UPDATE users SET crayon=0 WHERE userid=$userid",$c);
$db->query("UPDATE users SET exp=exp+$win WHERE userid=$userid",$c);
$db->query("UPDATE users SET crayonquest=1 WHERE userid=$userid",$c);
}
else
{
if(rand(1,30) <= 15)
{
print "Pesky Kid: Hey, thanks! Here's some experience that I mysteriously have! *You gained $win experience!";

$db->query("UPDATE users SET crayon=0 WHERE userid=$userid",$c);
$db->query("UPDATE users SET exp=exp+$win WHERE userid=$userid",$c);
$db->query("UPDATE users SET crayonquest=1 WHERE userid=$userid",$c);
}
else
{
if(rand(1,30) <= 5)
{
print "Pesky Kid: Hey, thanks! Here's some experience that I mysteriously have! *You gained $win experience!";

$db->query("UPDATE users SET crayon=0 WHERE userid=$userid",$c);
$db->query("UPDATE users SET exp=exp+$win WHERE userid=$userid",$c);
$db->query("UPDATE users SET crayonquest=1 WHERE userid=$userid",$c); 
Posted

Re: How to make person say something else after you beat quest?

your layout should be more liike this..

 

include "globals.php";

if($ir['crayonquest'] == 1)
{
die("you've already done this quest");
}

if($ir['crayon'] == 0)
{
die("Pesky Kid: Buy me some crayons!");
}

//set $win prize winings
$win=rand(10,170);
$loss=rand(10,276);
$bama = mt_rand(1,20);
if($bama == 20 )
{
print "Pesky Kid: Hey, thanks! Here's some experience that I mysteriously have! *You gained $win experience!";
$do = sprintf("UPDATE users SET crayon = 0, exp = exp + %u, crayonquest =1 WHERE userid = %u",($win),($userid));
$db->query($do);
}
else if($bama == 19)
{
print "Pesky Kid: Hey, thanks! Here's some experience that I mysteriously have! *You gained $win experience!";
$do = sprintf("UPDATE users SET crayon = 0, exp = exp + %u, crayonquest =1 WHERE userid = %u",($win),($userid));
$db->query($do);
}

else if($bama == 18)
{
print "Pesky Kid: Hey, thanks! Here's some experience that I mysteriously have! *You gained $win experience!";
$do = sprintf("UPDATE users SET crayon = 0, exp = exp + %u, crayonquest =1 WHERE userid = %u",($win),($userid));
$db->query($do);

 

now their is some problems with that....i didn't fix...just pointing you the right direction. Cuase i'm unsure what your trying to accomplish here.

Now your other page...if your on same page use POST much better.

 

<?php

include_once("globals.php");

if(!isset($_POST['buy']))
{
echo "Buy some crayons for that pesky kid, or visit him [url='crayonquest.php'][<u>here!</u>][/url]
";
echo "They cost $30 each.
";
echo "<form action='crayonquestbuy.php' method='post'>";
echo "<input type='hidden' name='buy' />";
echo "<input type='submit' value='Buy It' />";
echo "</form>";
}
else
{
if($ir['money'] < 30) 
{ 
	echo "You don't have enough money.

";
	echo "[url='crayonquestbuy.php']> Back[/url]";
	$h->endpage();
	exit;
}
if($ir['crayon'] == 1) 
{ 
	echo "You already have a crayon.

";
	echo "[url='crayonquestbuy.php']> Back[/url]";
	$h->endpage();
	exit;
}	
$do = sprintf("UPDATE users SET money = money - 30, crayon = 1 WHERE userid = %u",($userid));
$db->query($do);

echo "You bought the crayons! Yippie!
";
echo "[url='index.php']Go Home[/url]
";
echo "[url='crayonquest.php']Go to the pesky kid[/url]";
} 

$h->endpage(); 
?>
Posted

Re: How to make person say something else after you beat quest?

If you looked at first code i showed. You should see why yours is not working.

your going.

else

{

if(somethign)

{

Thats wrong.

else if(somethign)

{

thats how. with all the looping how you have it..I cant say how to fix it. cause you have th page wrong...If you want you could post the whole page. ill redo it for you. and you can use that. and the 2nd code i gave a minute ago and it will work fine...

Posted

Re: How to make person say something else after you beat quest?

MYSQL:

ALTER TABLE `users` ADD `crayonquest` TINYINT NOT NULL DEFAULT '0';

 

crayonquestbuy.php

<?php
include "globals.php";
print "<h3>Buy some crayons for that pesky kid, or visit him [url='crayonquest.php'][<u>here!</u>][/url]</h3>";
print "
<table border=2><th>Item</th><th>Price</th><th>Purchase</th>
<tr>
<td>Crayons</td><td>$30</td><td>[url='crayonquestbuy.php?spend=crayon']Buy[/url]</td></table>";
if($_GET['spend'] == 'crayon') 
{ 
if($ir['money'] <30) 
{ 
print "You don't have enough money!"; 
} 
else 
{ 
if($ir['money'] >30) 
{ 
print "You bought the crayons! Yippie!

[url='index.php']Go Home[/url]

[url='crayonquest.php']Go to the pesky kid[/url]"; 
$db->query("UPDATE users SET money=money-30,crayon=1 WHERE userid=$userid",$c); 
} 
} 
}
$h->endpage(); 
?>

 

Crayonquest.php

<?php
include "globals.php";
print "<h3>Buy some crayons for that pesky kid, or visit him [url='crayonquest.php'][<u>here!</u>][/url]</h3>";
print "
<table border=2><th>Item</th><th>Price</th><th>Purchase</th>
<tr>
<td>Crayons</td><td>$30</td><td>[url='crayonquestbuy.php?spend=crayon']Buy[/url]</td></table>";
if($_GET['spend'] == 'crayon') 
{ 
if($ir['money'] <30) 
{ 
print "You don't have enough money!"; 
} 
else 
{ 
if($ir['money'] >30) 
{ 
print "You bought the crayons! Yippie!

[url='index.php']Go Home[/url]

[url='crayonquest.php']Go to the pesky kid[/url]"; 
$db->query("UPDATE users SET money=money-30,crayon=1 WHERE userid=$userid",$c); 
} 
} 
}
$h->endpage(); 
?>
  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...