DragonPrime - LoGD Resource Community
Welcome Guest
  • Good morning, Guest.
    Please log in, or register.
  • May 21, 2013, 08:18:30 AM
Home Forums News Links Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
IRC Channels
Search

Pages: 1 [2]   Go Down
  Print  
Author Topic: Sword in the Stone 1.5  (Read 4062 times)
0 Members and 1 Guest are viewing this topic.
Excalibur
Member
Mod God
*****
Offline Offline

Posts: 573


I'm a newbie, plz forgive me!


View Profile WWW
« Reply #15 on: April 19, 2004, 02:06:59 PM »

That control section yields a blank page with no navs.  for both check and reset.

still not selecting one.

Have you dropped value in 'custom' table ? I had the same problem before, but it works fine right now after writing a row in 'custom' table with those values.

« Last Edit: April 20, 2004, 06:52:07 AM by Excalibur » Logged

Spock: Random chance seems to have operated in our favor.
McCoy: In plain, non-Vulcan English, we've been lucky.
Spock: I believe I said that, Doctor.
sixf00t4
Mod God
*****
Offline Offline

Posts: 1916



View Profile WWW
« Reply #16 on: April 19, 2004, 02:12:55 PM »

yes, i will admit that i already have a table named custom, so i renamed the fields area1 and amount1 and updated the files accordingly.

the custom table from the db:
Code:
 Field       Type                 Null   Default
   area1    varchar(255)     No         swordGuy                
   amount1  int(11)            No               0                
   dTime       time                No         00:00:00                
 

Code:
<?
require_once "common.php";
checkday();

page_header("Sword in the Stone");
output("`c`b`&Sword in the Stone`0`b`c");
$tradeinvalue = round(($session[user][weaponvalue]*.75),0);
if ($HTTP_GET_VARS[op]==""){
if ($session[user][superuser]>2) {
   addnav("Check Choosen","stone.php?op=check");
   addnav("Reset Choosen","stone.php?op=reset");
   }
    output("`@Many brave ".($session[user][gender]?"women":"men")." have tried to retrieve the sword.  None could do it.`n`n");
    output("`2Will you, `4".($session[user][name])." `2 retrieve the sword in the stone?");
    $session[user][specialmisc]=e_rand(1,100);
    addnav("Attempt to pull the sword","stone1.php?op=pull");
    addnav("Return to the village","village.php");
}else if ($HTTP_GET_VARS[op]=="pull"){
        addnav("Return to the village","village.php");
        if ($session[user][turns]<=0){output("`\$`bYou are too tired to try to pull the sword.  It seems futile.`b`0", true);}
             else {
                $session[user][turns]--;
                $sql="SELECT * FROM custom WHERE area1='swordGuy'";
$result = db_query($sql);
$dep = db_fetch_assoc($result);
$userid=$dep['amount1'];
$acctid=$session[user][acctid];
if ($acctid==$userid){
addnav("Daily news","news.php");
                                 output("`!C`@O`#N`5G`3R`^A`4T`1U`2L`2T`4I`6O`5N`7S`3!  `2You've successfully pulled the sword.  You've got one shot on making good use of it though, so use it wisely!",true);
                                 addnews("`%".$session[user][name]."`3 has pulled the sword from the stone!!");
                                 $session[bufflist][101] = array("name"=>"`&Sword in the Stone","rounds"=>1,"wearoff"=>"The sword in the stone crumbles in your hand, damn did that kick ass!","atkmod"=>3,"roundmsg"=>"Prepare to die!!","activate"=>"offense");
       $sql="SELECT * FROM accounts ORDER BY RAND() LIMIT 1";
   $result = db_query($sql);
   $dep = db_fetch_assoc($result);
   $swordguy=$dep['acctid'];
   //update sword account id
$sql="UPDATE `custom` SET `amount1` = $swordguy WHERE `area1` = 'swordGuy'";
   $result=db_query($sql);
//update time sword was goten
   $sql="UPDATE `custom` SET `dTime` = now() WHERE `area1` = 'swordGuy'";
   $result = db_query($sql);
} else {
              output("`3You place both feet on the rock, and prepare to give it a huge tug.  You yank on the sword...",true);
      output("`^Nothing.`n`n", true);
      output("`3I guess you weren't the chosen one today.  `n",true);
      output("`2You lose 1 forrest fight.", true);
     }
}    
}
else if ($HTTP_GET_VARS[op]=="check") {
addnav("`@Back to Village","village.php");
   $sql="SELECT * FROM custom WHERE area1='swordGuy'";
   $result = db_query($sql);
   $dep = db_fetch_assoc($result);
   $userid=$dep['amount1'];
   $sql="SELECT * FROM accounts WHERE acctid = $userid";
   $result = db_query($sql);
   $pippo = db_fetch_assoc($result);
   output("The Choosen for today is : $pippo[name]`n");
   
}else if ($HTTP_GET_VARS[op]=="reset") {
   addnav("`@Back to Village","village.php");
   $sql="UPDATE `custom` SET `amount1` = 0, `dTime` = 0 WHERE `area1` = 'swordGuy'";
   $result = db_query($sql);
   output("The Choosen has been reset`n");

}
page_footer();
?>


and the section in newday
Code:
//sword in the stone code
$sql="SELECT * FROM custom WHERE area1='swordGuy'";
$result=db_query($sql);  
$dep = db_fetch_assoc($result);
$lastchose=strtotime($dep['dTime']);
$now=strtotime(date("H:i:s"));
if (($now-$lastchose)>21600){
$sql="SELECT * FROM accounts ORDER BY RAND() LIMIT 1";
   $result = db_query($sql);
   $dep = db_fetch_assoc($result);
            $swordguy=$dep['acctid'];
   //update sword account id
   $sql="UPDATE `custom` SET `amount1` = $swordguy WHERE `area1` = 'swordGuy'";
   $result=db_query($sql);
       //update time sword was goten
   $sql="UPDATE `custom` SET `dTime` = now() WHERE `area1` = 'swordGuy'";
   $result = db_query($sql);
}
//end sword code
« Last Edit: April 19, 2004, 02:13:43 PM by sixf00t4 » Logged

Excalibur
Member
Mod God
*****
Offline Offline

Posts: 573


I'm a newbie, plz forgive me!


View Profile WWW
« Reply #17 on: April 19, 2004, 02:26:32 PM »

I don't see anything wrong at first look, but I don't understand why you get a blank page with no navs  Huh
I'll compare to mine and I'll tell you if I find anything different.
Logged

Spock: Random chance seems to have operated in our favor.
McCoy: In plain, non-Vulcan English, we've been lucky.
Spock: I believe I said that, Doctor.
Excalibur
Member
Mod God
*****
Offline Offline

Posts: 573


I'm a newbie, plz forgive me!


View Profile WWW
« Reply #18 on: April 19, 2004, 03:06:45 PM »

Quote
addnav("Attempt to pull the sword","stone1.php?op=pull");

Why stone1.php Huh  This could be the reason you get the blank page (you surely have also a file named stone.php Roll Eyes )
If this is the name you use onto your server you should change also into these:

Code:
if ($session[user][superuser]>2) {
  addnav("Check Choosen","stone1.php?op=check");
  addnav("Reset Choosen","stone1.php?op=reset");
  }

and substitute this part of code:
Code:
$sql="SELECT * FROM accounts ORDER BY RAND() LIMIT 1";
$result = db_query($sql);
$dep = db_fetch_assoc($result);
$swordguy=$dep['acctid'];
//update sword account id
$sql="UPDATE `custom` SET `amount1` = $swordguy WHERE `area1` = 'swordGuy'";
$result=db_query($sql);
//update time sword was goten
$sql="UPDATE `custom` SET `dTime` = now() WHERE `area1` = 'swordGuy'";
$result = db_query($sql);
(found between the bufflist and the else) with this:
Code:
$sql="UPDATE `custom` SET `amount1` = 0 WHERE `area1` = 'swordGuy'";
$result=db_query($sql);
$sql="UPDATE `custom` SET `dTime` = now() WHERE `area1` = 'swordGuy'";
$result = db_query($sql);

I've checked onto my server and it has changed the "Choosen One" correctly. Let me know if with these changes still doesn't work.

Excalibur
Logged

Spock: Random chance seems to have operated in our favor.
McCoy: In plain, non-Vulcan English, we've been lucky.
Spock: I believe I said that, Doctor.
sixf00t4
Mod God
*****
Offline Offline

Posts: 1916



View Profile WWW
« Reply #19 on: April 19, 2004, 03:20:53 PM »

Doh!  i was too caught up in making sure i got the db name changes, forgot about the stone name changes...sorry about that.

now i am getting
Code:
SELECT * FROM accounts WHERE acctid =
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

on checking.



resetting says that it has beeen reset.
Logged

Excalibur
Member
Mod God
*****
Offline Offline

Posts: 573


I'm a newbie, plz forgive me!


View Profile WWW
« Reply #20 on: April 19, 2004, 03:48:32 PM »

now i am getting
Code:
SELECT * FROM accounts WHERE acctid =
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
If you have resetted the Choosen, you have 0 (zero) in 'amount' field, and when you try to read from 'accounts' table with these lines:
Code:
$sql="SELECT * FROM custom WHERE area1='swordGuy'";
  $result = db_query($sql);
  $dep = db_fetch_assoc($result);
  $userid=$dep['amount1'];
  $sql="SELECT * FROM accounts WHERE acctid = $userid";
you have acctid equal to zero. Maybe a setting in your MySQL cause the error, on my server it only give a null string.

You can put a check, something like
Code:
if ($userid!=0) {
execute the code to echo the name of the Choosen
}else {
echo "Noone has been choosen yet"
}
Hope this help
Excalibur
Logged

Spock: Random chance seems to have operated in our favor.
McCoy: In plain, non-Vulcan English, we've been lucky.
Spock: I believe I said that, Doctor.
sixf00t4
Mod God
*****
Offline Offline

Posts: 1916



View Profile WWW
« Reply #21 on: April 19, 2004, 04:22:28 PM »

yeah, that fixed that error. but no one is being selected on a new day.  I took out the
      if (($now-$lastchose)>21600){

check, and it still won't do it.
Logged

Excalibur
Member
Mod God
*****
Offline Offline

Posts: 573


I'm a newbie, plz forgive me!


View Profile WWW
« Reply #22 on: April 20, 2004, 05:17:05 AM »

Try to reset and pass throu a newday. That should elect a new Choosen (at least do so onto my server), and you can check it via "Check Choosen".
Logged

Spock: Random chance seems to have operated in our favor.
McCoy: In plain, non-Vulcan English, we've been lucky.
Spock: I believe I said that, Doctor.
bapenguin
Guest
« Reply #23 on: April 20, 2004, 06:04:14 AM »

wow, i was out of the loop on my own mod!  I'm sorry it's been giving you guys so much trouble.  Basiclaly to keep all my "mods" seperate from the main tables i create a new table called custom and created some common fields for it.  In all my custom mods i can reference the custom table and setting accordingly.  The 21600 is 6 hours (in seconds), which is the default game day.  This can be changed  to whatever you like for your current server.  I hope you guys can get it working!
Logged
Excalibur
Member
Mod God
*****
Offline Offline

Posts: 573


I'm a newbie, plz forgive me!


View Profile WWW
« Reply #24 on: April 20, 2004, 06:44:50 AM »

I hope you guys can get it working!

I was trying to help sixf00t4 to keep this mod working on his server.
It works fine on my server ;-)
Logged

Spock: Random chance seems to have operated in our favor.
McCoy: In plain, non-Vulcan English, we've been lucky.
Spock: I believe I said that, Doctor.
sixf00t4
Mod God
*****
Offline Offline

Posts: 1916



View Profile WWW
« Reply #25 on: June 08, 2004, 11:41:29 PM »

i was bored, so i tried to get this working again.  no luck.

i narrowed down the problem.  $swordguy is getting a value, i outputed it in newday.php, but it is not getting passed into the db.  the fields remain blank.  here is what my newday addition looks like now.
Code:
//sword in the stone code
$sql="SELECT * FROM custom WHERE area1='swordGuy'";
$result=db_query($sql);
$dep = db_fetch_assoc($result);
$lastchose=strtotime($dep['dTime']);
$now=strtotime(date("H:i:s"));
      //if (($now-$lastchose)>21600){
         $sql="SELECT * FROM accounts ORDER BY RAND() LIMIT 1";
          $result = db_query($sql);
          $dep = db_fetch_assoc($result);
            $swordguy=$dep['acctid'];
          //update sword account id
          $sql="UPDATE `custom` SET `amount1` = $swordguy WHERE `area1` = 'swordGuy'";
          $result=db_query($sql);
           //update time sword was goten
          $sql="UPDATE `custom` SET `dTime` = now() WHERE `area1` = 'swordGuy'";
          $result = db_query($sql);
          output("$swordguy");
         //}
//end sword code

i commented out the date check so that it will get a new swordguy every time.  anyone know why it isnt being passed to the db?
Logged

Excalibur
Member
Mod God
*****
Offline Offline

Posts: 573


I'm a newbie, plz forgive me!


View Profile WWW
« Reply #26 on: June 09, 2004, 01:00:30 AM »

Well, I post again my swordinthestone code from newday.php. I have no trouble with it, and it works really fine, choosing a different player each day.
Code:
//sword in the stone code
$sql="SELECT * FROM custom WHERE area='swordGuy'";
$result=db_query($sql);  
$dep = db_fetch_assoc($result);
$lastchose=strtotime($dep['dTime']);
$now=strtotime(date("H:i:s"));
$diff=$now-$lastchose;
//if ($diff>21600 OR $dep['dTime']=="00:00:00"){
if ($diff>21600 OR $diff<0){
   output("`n`@The Sword in the Stone has choosen a new Master`n");
    addnews("`%The Sword in the Stone has choosen a new Master");
    $sql="SELECT * FROM accounts ORDER BY RAND() LIMIT 1";
   $result = db_query($sql);
   $dep = db_fetch_assoc($result);
   $swordguy=$dep['acctid'];
   //update sword account id
   $sql="UPDATE `custom` SET `amount` = $swordguy WHERE `area` = 'swordGuy'";
   $result=db_query($sql);
   //update time sword was goten
   $sql="UPDATE `custom` SET `dTime` = now() WHERE `area` = 'swordGuy'";
   $result = db_query($sql);
}
$sql="SELECT * FROM custom WHERE area='swordGuy'";
$result=db_query($sql);  
$dep = db_fetch_assoc($result);
if ($session[user][acctid]==$dep['amount']){output("`n`n`@You feen a strange sensation ... maybe you could check the Sword in the Stone today");}
//sword in the stone code
The last if statement give a clue to player that he is the choosen, you can remove it or comment it out.

Rgds Excalibur
Logged

Spock: Random chance seems to have operated in our favor.
McCoy: In plain, non-Vulcan English, we've been lucky.
Spock: I believe I said that, Doctor.
sixf00t4
Mod God
*****
Offline Offline

Posts: 1916



View Profile WWW
« Reply #27 on: June 09, 2004, 04:18:53 PM »

this is really nerve racking.  Still nothing.  I deleted the fields, and recreated them.

Code:
ALTER TABLE `custom` ADD `area1` VARCHAR( 255 ) NOT NULL ,
ADD `amount1` INT( 11 ) NOT NULL ,
ADD `dtime` TIME NOT NULL ;

and i added a few lines to the newday, and it still isnt going to the db.

Code:
$sql="SELECT * FROM custom WHERE area1='swordGuy'";
$result=db_query($sql);
$dep = db_fetch_assoc($result);
$lastchose=strtotime($dep['dTime']);
$now=strtotime(date("H:i:s"));
$diff=$now-$lastchose;
//if ($diff>21600 OR $dep['dTime']=="00:00:00"){
//if ($diff>21600 OR $diff<0){
 //  output("`n`@The Sword in the Stone has choosen a new Master`n");
 //   addnews("`%The Sword in the Stone has choosen a new Master");
    $sql="SELECT * FROM accounts ORDER BY RAND() LIMIT 1";
   $result = db_query($sql);
   $dep = db_fetch_assoc($result);
   $swordguy=$dep['acctid'];
   //update sword account id
   $sql="UPDATE `custom` SET `amount1` = $swordguy ";
   $result=db_query($sql);
   //update time sword was goten
   $sql="UPDATE `custom` SET `dTime` = now() WHERE `area1` = 'swordGuy'";
   $result = db_query($sql);
//}
$sql="SELECT * FROM custom WHERE area1='swordGuy'";
$result=db_query($sql);
$dep = db_fetch_assoc($result);
$dep[amount1]=$swordguy;
$swordude=$dep[amount1];

output("`n`nThe acctid in custom is $sworddude, but the temp id is $swordguy");
if ($session[user][acctid]==$dep['amount1']){output("`n`n`@You feen a strange sensation ... maybe you could check the Sword in the Stone today");}
//sword in the stone code

with that, i get "The acctid in custom is , but the temp id is 1265" with the temp id changing every time.  perhaps the fields are not set up correctly???
Logged

Pages: 1 [2]   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Play LoGD on Dragonprime

Support Us
$100 raised this year
Your help is greatly appreciated!
Who's Online
23 Guests, 1 User
supermingo
DragonPrime LoGD
Recent Topics
Home Forums News Links Downloads Login Register Advanced Search