DragonPrime - LoGD Resource Community
Welcome Guest
  • Good evening, Guest.
    Please log in, or register.
  • September 26, 2016, 08:32:19 PM
Home Forums News Links Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
IRC Channels
Search

Pages: [1]   Go Down
  Print  
Author Topic: RatioSitePoints Error  (Read 2535 times)
0 Members and 1 Guest are viewing this topic.
Pffft
Guest
« on: October 25, 2004, 12:55:13 PM »

Hello...  8]
As I had asked in a previous thread, I had a problem with the RatioOfSitePoints line:

-->

INSERT INTO settings (setting,value) VALUES ("RatioOfSitePoints","5")

Duplicate entry 'RatioOfSitePoints' for key 1

<--

So what Gargi had suggested was to hide (damn it, what is the correct term for this "//"?) those two lines in the guildclanfunc.php.  However, once I did that, when I click into the Manage Site Points area, the site loads forever, and then finally gives me this error:

-->

Fatal error: Maximum execution time of 30 seconds exceeded in /drive2/fpgshttpd/azura/lotgd/common.php on line 176

<--

I think even if I can increase the execution time cap to 60 seconds, the point in question is that the file(s) shouldn't even have to take 30 seconds to load up, or am I totally wrong here?  8/
Logged
Excalibur
Member
Mod God
*****
Offline Offline

Posts: 573


I'm a newbie, plz forgive me!


View Profile WWW
« Reply #1 on: October 25, 2004, 02:48:17 PM »

Hello...  8]
As I had asked in a previous thread, I had a problem with the RatioOfSitePoints line:
-->
INSERT INTO settings (setting,value) VALUES ("RatioOfSitePoints","5")
Duplicate entry 'RatioOfSitePoints' for key 1
<--
Basically what happens is that you try to write something in settings array with this SQL command that already exist. The first time you do that the INSERT command will work fine, but the second time it will gives you the error you report, as you should exdcute an UPDATE command (instead of INSERT as the value already exist), so before executing the INSERT command, you need to know if that variable already exists or not. There are 2 ways to do that:

1) Checking if is already set with SQL commands, if it's not there do the INSERT, else do the UPDATE.

2) Using 2 built in functions (you can find them in common.php) that makes life easier  Wink
To write use:
Code:
savesetting("RatioOfSitePoints",5);
To read use:
Code:
getsetting("RatioOfSitePoints",0);
//if the variable is not set will gives you zero
Remember that you can have only one instance[/u] of RatioOfSitePoints, so each time you do savesetting you'll overwrite the previous value.
Quote
What Gargi had suggested was to hide (damn it, what is the correct term for this "//"?) those two lines in the guildclanfunc.php.
Using the 2 functions suggested above you'll not run into an endless loop, as they do the dirty job for you  Wink

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.
Hooptel
Guest
« Reply #2 on: October 25, 2004, 04:12:46 PM »

From the technical side, Excalibur is totally right. But taking the gameplay into account, there should be absolutely NO REASON to insert or update that value, except for the initial install.

The "RatioOfSitePoints" is a general setting for the whole mod. With standard values, 5 SitePoints can be used for 1 percent of various benefits. That rate has to stay constant (or must be changed once during install) - otherwise the conditions are not equal for different guilds or clans.

Well, maybe your updated version is far more away from my piece of code than i thought it was.
If you like, send me your affected files by PM or post a link to it. I will have a closer look then.
Logged
Pffft
Guest
« Reply #3 on: October 25, 2004, 09:15:08 PM »

Excalibur and Gargi - thanx for the help...  8]

Here is the link to the source:

http://www.freepgs.com/azura/lotgd/source.php?url=/azura/lotgd/guildclanfuncs.php

Logged
Excalibur
Member
Mod God
*****
Offline Offline

Posts: 573


I'm a newbie, plz forgive me!


View Profile WWW
« Reply #4 on: October 26, 2004, 01:22:04 AM »

From the technical side, Excalibur is totally right. But taking the gameplay into account, there should be absolutely NO REASON to insert or update that value, except for the initial install.
So why don't use savesetting[/i] function ?
You need to INSERT that value the first time you run that script, and you need to do nothing if the value is already in DB.
As savesetting function write in the DB even if the value is already there and equal to stored value, if you want to optimize your code you can copy the savesetting function removing the UPDATE part.
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 #5 on: October 26, 2004, 01:48:16 AM »

Excalibur and Gargi - thanx for the help...  8]

Here is the link to the source:

http://www.freepgs.com/azura/lotgd/source.php?url=/azura/lotgd/guildclanfuncs.php


I've take a look at the code and I've noticed you have few getsetting (actually in rem) without any savesetting.
If that value will *never* change, why do you need to store it in DB ? I haven't installed that mod on my server, but for what I've seen it's unnecessary to write it in DB. Just put a line at the beginning of the file
Code:
$RatioOfSitePoints = 5;

The endless loop you're getting is probably caused by this for - next:
Code:
for ($i=5; $i<=((int)$ThisGuild['SitePoints']); $i=$i+($RatioOfSitePoints))
as $RatioOfSitePoints is not set (for the remmed getsetting lines).

Rgds Excalibur
« Last Edit: October 26, 2004, 04:31:46 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.
Pffft
Guest
« Reply #6 on: October 27, 2004, 02:03:56 PM »

Okay, I rem'd out --> for ($i=5; $i<=((int)$ThisGuild['SitePoints']); $i=$i+($RatioOfSitePoints)) <-- and placed --> $RatioOfSitePoints = 5; <-- near the top of the file and now it works.  Thanx for all the help...  8]
Logged
Excalibur
Member
Mod God
*****
Offline Offline

Posts: 573


I'm a newbie, plz forgive me!


View Profile WWW
« Reply #7 on: October 27, 2004, 03:23:58 PM »

Okay, I rem'd out --> for ($i=5; $i<=((int)$ThisGuild['SitePoints']); $i=$i+($RatioOfSitePoints))
If you have added the $RatioOfSitePoints = 5; at the top of the file, you shouldn't rem out that line, it should work fine.
If it doesn't ... well I'm totally lost as I haven't installed this mod on my server  Huh

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.
Pages: [1]   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Play LoGD on Dragonprime

Support Us
No funds raised yet this year
Your help is greatly appreciated!
Who's Online
61 Guests, 0 Users
DragonPrime LoGD
Recent Topics
Home Forums News Links Downloads Login Register Advanced Search