Get ready for BLACK FRIDAY shopping starting in

Forums

ASP

This topic is locked

Displaying certain information from chosen.

Posted 13 Jan 2005 18:33:55
1
has voted
13 Jan 2005 18:33:55 jeremy gunn posted:
I made a website for a guild from a game called World of Warcraft. and what i'm trying to do is make it so when they select their Race and go to pick their class (ie warrior, paladin etc..) it doesn't display classes that the race cannot be. What i have right now is the Class/Race residing inside the Users Table in my database.

My general idea on it is this.

<pre id=code><font face=courier size=2 id=code>
' check to see what race the user is.
&lt;% if rsProfile("race" = dwarf then

'display the available classes for the above race.

availableclasses = "warrior, paladin, rogue, hunter, priest"

</font id=code></pre id=code>

then i would want the information to be displayed (ie the classes with their images) elsewhere.

All of the classes amongst all of the races are. Warrior, Druid, Shaman, Paladin, Warlock, Priest, Hunter, Rogue, mage.

All races are Dwarf, Gnome, Night Elf, Human, Orc, Troll, Tauren, Undead

I know i'm very far off on this cause with the commas on the classes i know it's just gonna pull the first class and not the rest. I'm not quite sure on how to do the rest. Any ideas?

One person stated for me to make a Class table with all available classes then a Race table with all available races and then link them?

It just sounds too complicated when I know i've seen it done somewhere with just asp code.

Lemme know if this is just confusing as all can be hehehe.

-Jeremy

Edited by - jeremo on 13 Jan 2005 18:38:07

Replies

Replied 13 Jan 2005 20:51:13
13 Jan 2005 20:51:13 Simon Martin replied:
Jeremy,

From what you've said it sounds like you'd like 2 combo boxes; 1 with available races and the 2nd displaying only classes that are available to those races?

Check out this extension from Kaosweaver www.kaosweaver.com/extensions/details.php?id=25&cid=18
It does exactly that.

However if you're going to run this from a database then I would also suggest that you use a tblClass and tblRace. I would link those tables by posting the primary key of tblRace (raceID) into tblClass, so each item in tblClass has a link to which race it belongs to.
This could get a bit more complex if a class can belong to more than 1 race. But if you need any help designing a relational database give us a shout

Live the life you love
Love the life you live

Simon

[DWMX 2004]|[SQL]|[ASP/VBScript]|[XP-Pro]
Replied 13 Jan 2005 21:09:28
13 Jan 2005 21:09:28 Chris Charlton replied:
For gaming site(s), you might want to look into VortexPortal (www.vortexportal.net), a gaming site CMS with theming features and modules.
Replied 14 Jan 2005 01:43:59
14 Jan 2005 01:43:59 jeremy gunn replied:
Well basically yes, classes can belong to more than one race. However, The way I have my site setup. www.lostsoulsguild.com/ you'll prolly get a better idea of what i'm talking about by actually logging in.

username : lstest
password : lstest1

go ahead and login test stuff out. I'm mainly having bugs with the user profiles but everything else seems to be working fine.

If you'll notice, there is one page dedicated to picking your race. then you pick and save. then you click Change Class. and then thats where you pick a class so basicallly i was wondering if there is code that will work for what I've designed. there are 2 asp pages, changerace.asp and changeclass.asp so I don't think the drop down list thing you posted will work correctly unless i just make it one page. However I like having the images and such.

Is there any code relative to what i'm suggesting below? That would work.

<pre id=code><font face=courier size=2 id=code>
if rsProfile("race" = whatever race they are
then
available choices = whichever ones i assign in this line.
</font id=code></pre id=code>

So basically i would copy and paste the above code 8 times. since there are 8 races and on the available choices line i would change that to fit what classes to pull out of the database for the chosen race. make sense?

It's kinda like on my Changerace page right now I use.

<pre id=code><font face=courier size=2 id=code>
if rsProfile("icon" = "mhuman" then
mhumanchecked = " checked"
end if
if rsProfile("icon" = "mdwarf" then
mdwarfchecked = " checked"
end if
if rsProfile("icon" = "gnome" then
mgnomechecked = " checked"
end if
if rsProfile("icon" = "mnightelf" then
mnightelfchecked = " checked"
end if
if rsProfile("icon" = "fhuman" then
fhumanchecked = " checked"
end if
if rsProfile("icon" = "fdwarf" then
fdwarfchecked = " checked"
end if
if rsProfile("icon" = "fgnome" then
fgnomechecked = " checked"
end if
if rsProfile("icon" = "fnightelf" then
fnightelfchecked = " checked"
end if
if rsProfile("icon" = "morc" then
morcchecked = " checked"
end if
if rsProfile("icon" = "mtauren" then
mtaurenchecked = " checked"
end if
if rsProfile("icon" = "mtroll" then
mtrollchecked = " checked"
end if
if rsProfile("icon" = "mundead" then
mundeadchecked = " checked"
end if
if rsProfile("icon" = "forc" then
forcchecked = " checked"
end if
if rsProfile("icon" = "ftauren" then
ftaurenchecked = " checked"
end if
if rsProfile("icon" = "ftroll" then
ftrollchecked = " checked"
end if
if rsProfile("icon" = "fundead" then
fundeadchecked = " checked"
end if
</font id=code></pre id=code>

Basically thats for the radio buttons on the changerace page so if the user is that race, It automatically selects it when they return.
Replied 14 Jan 2005 02:10:32
14 Jan 2005 02:10:32 Chris Charlton replied:
With that many <i>if</i> statements you might want to invest that code as <i><b>switch</b> case</i> statement(s).

Personally, I agree with linking the databases suggested in the beginning. How familar are you with SQL code and database creation? What's your level of Dreamweaver? If you use a table to link them, you'll save yourself a lot of finger work.
Replied 14 Jan 2005 02:11:00
14 Jan 2005 02:11:00 Chris Charlton replied:
cool game site, by the way. <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>
Replied 14 Jan 2005 02:16:49
14 Jan 2005 02:16:49 jeremy gunn replied:
I currently have Dreamweaver mx6 if thats what you mean. I basically do this asp stuff as a hobby so i'm not real hardcore and technically "understand" everything i'm doing hehe i just basically get the drift of it ie. If such and such does this, then do this. basically with any code. As far as SQL goes.

<pre id=code><font face=courier size=2 id=code>
sql = "SELECT topics.*, forums.*,statusname, statuslevel, moderator, users.posts FROM (status INNER JOIN users ON status.statusid = users.status) INNER JOIN ((forums INNER JOIN moderators ON forums.forumid = moderators.moderatorforum) INNER JOIN topics ON forums.forumid = topics.forum) ON users.username = topics.by WHERE topics.id = " & id
Set rsRoot = Server.CreateObject("ADODB.Recordset"
rsRoot.Open sql, conn, 3, 3
</font id=code></pre id=code>

Thats from my forums, and I understand that it is "inner joining" two tables I think.

Lets just say that I'm really good at taking a bunch of scripts and putting them together without errors and then researching about how to do little stuff. I know i should really learn how to really code hehe but i'm just too impatient

I can do your basic SQL connect scripts though.

SQL = Select * from users order by charname desc
Set rsProfile = Server.CreateObject("ADODB.Recordset"
rsProfile.Open sql, conn, 3, 3
Replied 14 Jan 2005 02:20:30
14 Jan 2005 02:20:30 jeremy gunn replied:
Oh yeah <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle> thanks for the complimet on the site hehe
Replied 14 Jan 2005 02:37:52
14 Jan 2005 02:37:52 Chris Charlton replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>...I can do your basic SQL connect scripts though.

SQL = Select * from users order by charname desc
Set rsProfile = Server.CreateObject("ADODB.Recordset"
rsProfile.Open sql, conn, 3, 3<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Are you connecting to an Access database or SQL Server, or even MySQL?
Replied 14 Jan 2005 02:54:43
14 Jan 2005 02:54:43 jeremy gunn replied:
Access Database

I have an included file i use. conn.asp

<pre id=code><font face=courier size=2 id=code>
Dim ConnectString, conn

ConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("insertdatabase path here heheh"
Set conn = Server.CreateObject("ADODB.Connection"
conn.open ConnectString
</font id=code></pre id=code>


Edited by - jeremo on 14 Jan 2005 02:56:13
Replied 14 Jan 2005 04:14:23
14 Jan 2005 04:14:23 Chris Charlton replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>Access Database<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Oh cool, well, it should be visually easy to generate the middle table which should have RaceID & ClassID (many-many relationship I believe). Then your recordset/query would just look up all RaceID's from what the user picks, and youre middle table allows flexibility to share classes across all races. When a user now goes to the Class page, your Recordset only looks for that race (RaceID), and - <i>boom</i> - small query code, fast loading, and your long <i>if</i> statements aren't needed really, since it would only return classes allowed. Just need a loop to generate the radio buttons/icon images from the records.

Also, this is good because later on when there's expansion packs to the game, you can easily add more races, and more classes and any race can have any class you gave them.

Reply to this topic