DragonPrime - LoGD Resource Community
Welcome Guest
  • Good morning, Guest.
    Please log in, or register.
  • November 12, 2018, 09:36:33 AM
Home Forums News Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
Search

Pages: [1]   Go Down
  Print  
Author Topic: Character Limit  (Read 6177 times)
0 Members and 1 Guest are viewing this topic.
Interloper
Guest
« on: October 20, 2004, 07:36:47 PM »


What would be the easiest way to limit the total number of characters able to be created in your game?

What I mean is, would it be possible to make it so that only a maximum number of accounts can be created?

I've had a slightly modified version of my game available for a while now to only certain members of my website community, but am interested in opening it up to more players. The main thing holding me back from doing this is bandiwidth concerns, so I'd really like to be able to set a limit as to the amount of accounts that can be created (perhaps 30 or something initially and increase it dependending on how much bandwidth is being chewed up by the game). Of course this would mean that if  characters expired or were deleted spots would open up for new players to join in.

Anyway, if anyone can decipher my ramblings and offer some advice I'd appreciate it.

 Smiley
Logged
lonnyl
Guest
« Reply #1 on: October 20, 2004, 08:18:14 PM »

I believe that Anpera has a modification here somewhere that will limit the number of players online at a time..... this may fit your needs...  (sorry for not giving you a link... I can never find what I want using the search)
Logged
Interloper
Guest
« Reply #2 on: October 20, 2004, 10:12:24 PM »

yeah I did find something along those lines when I searched before making this thread. But I'm more interested in limiting the total amount of player accounts that can be created rather than how many people are online at once.

I don't really mind if most of my players are online at the same time, I'd just like to be able to limit how many of those players tehre actually are.  Wink
Logged
Excalibur
Member
Mod God
*****
Offline Offline

Posts: 573


I'm a newbie, plz forgive me!


View Profile WWW
« Reply #3 on: October 20, 2004, 10:17:58 PM »

Just off my head:
in index.php you could do something like this:
Code:
$sql = "SELECT COUNT(*) FROM accounts";
db_query($sql);

if (try to figure out what you need here) {
   addnav("Create new char","create.php");
}

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.
robert
Old Dog
Mod God
*****
Offline Offline

Posts: 1047


LoGD Buff!


View Profile WWW
« Reply #4 on: October 20, 2004, 11:32:31 PM »

RE: concerned with bandwidth

Besides limiting the amount of players on at one time.

Another thing you may consider is reducing files sizes.
I have successfully reduced every file in size by hundreds and in some cases thousands of bytes. By eliminating the tons of whitespace, reconfiguring the code and streamlining repetitive code - you could reduce some of your bandwidth used.

I'll be the first to admit - this is very time consuming work but if you have great concern for bandwidth used - it may help.

ALSO - Once your player limit is reached - you can remove the create character link on the index page.
« Last Edit: October 20, 2004, 11:38:39 PM by robert » Logged

XChrisX
Global Moderator
Mod God
*****
Offline Offline

Posts: 4647

Be aware of the squirrel!


View Profile WWW
« Reply #5 on: October 20, 2004, 11:46:39 PM »

We are using something like this:

Code:
//USERLIMIT
$maxuser = 5000;
$result = db_fetch_assoc(db_query("SELECT COUNT(acctid) AS anzahl FROM accounts"));
$anzahl = $result['anzahl'];
if ($anzahl > $maxuser) output ("`b`\$Leider sind zur Zeit keine Neuanmeldungen mehr mglich`b`0`n`n");
if ($anzahl <= $maxuser) addnav("Einen Charakter erstellen","create.php");
//USERLIMIT

replace addnav("Create Account","create.php"); in home.php by the code above and it works fine... I'm sure, it can be done as a module, too... But by now I've been too lazy to do this...  Smiley
Logged

Running for more than three years now:
Interloper
Guest
« Reply #6 on: October 21, 2004, 12:05:39 AM »

Thanks for the replies everyone.

I've managed to get both versions working and have one further question that should hopefully be very simple.

Using Excalibur's as an example, I added this code:

Code:
$sql = "SELECT COUNT(*) FROM accounts";
$result = db_query($sql);

if ($result = <=30) {
  addnav("Create new char","create.php");
}

It works perfectly but I was wondering how I could get it to show a message saying the game is currently full . I added an else statement after the if, and tried both "addnav" (which resulted in horrible bold blue writing with - at each end like the "New to Logd?" text) and "output" which put the text on the bottom of the page underneath the game version (I also notice this is what happens in the XChrisX posted version).

Is there any way I can get nice normal text to appear under the New to Logd heading in the event the game is full?

Hmm. I hope that made sense to someone.

Anyway, thanks again! Cheesy
« Last Edit: October 21, 2004, 12:09:11 AM by Interloper » Logged
XChrisX
Global Moderator
Mod God
*****
Offline Offline

Posts: 4647

Be aware of the squirrel!


View Profile WWW
« Reply #7 on: October 21, 2004, 12:25:11 AM »

You could add

addnav("`\$No New accounts", "home.php");

This would create a red link to the login-page again...

I think that's what you are looking for...

Btw: You need to use "db_fetch_assoc($result);" and another variable to get the correct number of players...

Try using " Debug("Registered Players: " . $result); " to see, what the content of $result is Wink
Logged

Running for more than three years now:
Excalibur
Member
Mod God
*****
Offline Offline

Posts: 573


I'm a newbie, plz forgive me!


View Profile WWW
« Reply #8 on: October 21, 2004, 12:46:29 AM »

You can do this.
At the beginning of index.php, right after require_once "common.php";, add:
Code:
$sql = "SELECT COUNT(*) FROM accounts";
$actualplayer = db_query($sql);
$maxallowedplayer = 30;
After the "Enter your name and password to enter the realm." output statement add:
Code:
if ($actualplayer >= $maxallowedplayer) {
   output("`n`2We have already reached the max number of players allowed of $actualplayer. You can't create a new char.`n");
}
and again substitute addnav("Create a character","create.php"); with:
Code:
if ($actualplayer < $maxallowedplayer) {
  addnav("Create new char","create.php");
}

Hope this help  Smiley
Rgds Excalibur
« Last Edit: October 21, 2004, 12:48:25 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.
Interloper
Guest
« Reply #9 on: October 21, 2004, 06:32:14 AM »


Okay I've spent the last little while playing around with the code in here and trying different things out. The most recent code posted by you seems to work well Excalibur, except there's one strange thign that happens with it that might just be because of my lack of understanding when it comes to php and sql.

Basically when I put in a "maxallowedplayer" number, it actually seems to count it a number higher than that.

For testing purposes (and since my game currently has only 12 players), I set maxallowedplayers to 12, but it still let me create a new character. TO have the limit actually set to 12 I had to put maxallowedplayers to 11.

Obviously this isn't really a problem, just something strange I noticed and wondered if there was an explanation for. Smiley

Thanks again for your help everyone. I really appreciate people taking the time to help me learn.  Cheesy
Logged
Excalibur
Member
Mod God
*****
Offline Offline

Posts: 573


I'm a newbie, plz forgive me!


View Profile WWW
« Reply #10 on: October 21, 2004, 07:13:39 AM »

For testing purposes (and since my game currently has only 12 players), I set maxallowedplayers to 12, but it still let me create a new character. TO have the limit actually set to 12 I had to put maxallowedplayers to 11.
It sound strange to me  Huh
The only reason that comes to my mind is that SQL command COUNT(*) returns a X-1 number of rows.

Try inserting:
Code:
echo "COUNT(*) command has returned: ".$actualplayer." existing player";
right after the SQL query. This will output a line out of the LoGD window, in the upper part of the screen. If it will appear 12 I really don't understand why that happens, as the if ($actualplayer < $maxallowedplayer) line will compare 12 with 12, and the condition if (12 < 12) won't be verified and the addnav to create a new char won't appear.
The only possibilities is that SQL query gives you 11, but as you said there are 12 players, it sound very strange to me.

Let me know what happens
Excalibur

*** EDIT ***
In PHPMyAdmin if you move the cursor over accounts table (on the left side of the screen), you'll see a window appears with the number of rows.
« Last Edit: October 21, 2004, 07:20:16 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.
XChrisX
Global Moderator
Mod God
*****
Offline Offline

Posts: 4647

Be aware of the squirrel!


View Profile WWW
« Reply #11 on: October 21, 2004, 09:48:08 AM »

I have encountered a strange problem with comparison, too...

Code:
if (get_module_pref("XXX", "XXX") != true)

leads to a different result compared to

Code:
if (get_module_pref("XXX", "XXX") == false)

why is that!?
Logged

Running for more than three years now:
Excalibur
Member
Mod God
*****
Offline Offline

Posts: 573


I'm a newbie, plz forgive me!


View Profile WWW
« Reply #12 on: October 21, 2004, 02:16:20 PM »

Check here.
The only reason I see is that maybe the variable hasn't been set.
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.
Interloper
Guest
« Reply #13 on: October 21, 2004, 05:20:57 PM »

Hmm... When I put:

Code:
echo "COUNT(*) command has returned: ".$actualplayer." existing player";

It returns:

Code:
COUNT(*) command has returned: existing player

So... Obviously it's not returning $actualplayer at all.

I tried calling $actualplayer just in the part saying the game has reached its limit of players and it showed up not a number but "Resource id #11".

Checking in PHPMyAdmin now, will edit this post after.  Smiley

Edit:When checking the rows in PHPMyAdmin there appears to be the correct number (12).

« Last Edit: October 21, 2004, 05:23:26 PM by Interloper » Logged
Kendaer
Guest
« Reply #14 on: October 21, 2004, 07:13:42 PM »

Quote
Code:
$sql = "SELECT COUNT(*) FROM accounts";
$actualplayer = db_query($sql);
$maxallowedplayer = 30;

The above is buggy
Try the following
Code:
$sql = "SELECT COUNT(*) as count FROM accounts";
$res = db_query($sql);
$row = db_fetch_assoc($res);
$actualplayer = $row['count'];
$maxallowedplayer = 30;

The reason it was showing up as a resource is that it WAS a resource.  You needed to actually fetch the data rather than the SQL result object.
Logged
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!
Recent Topics
DragonPrime LoGD
Who's Online
35 Guests, 0 Users
Home Forums News Downloads Login Register Advanced Search