Hello,
I'm creating an browser based RPG game. I think you've played them at least once and you know there are things like spells, sometimes various abilities and professions. Here's my problem:
I'm going to create lots of spells and all of them will do something different than others. I want to make them very flexible. I've decided to write a block of PHP code about what each spell will have to do and put these block into MySQL database, so it's easier to edit them later in Admin panel of the game (won't have to edit php files and upload them, saves lots of time). Now what I need to do is to take that code block from mysql database and execute it so it does what's written in the block. How can I do that?
If I add more than 100 spells (many classes to choose from with lots of spells) to a php file with code blocks for each spell, the file would be huge and I want to add a spell I would need to edit that file and then upload it.
I just want to make my script flexible so that spells, professions and abilities could be customizable by php language. You're very welcome to offer any ideas how can I do that even if it's not like I thought. Maybe making a big file with functions for each spell is a better idea, I don't know... I don't have much experience with PHP (about a half a year) so I'm asking for your help.
Thanks for any suggestions!
game - adding items with high customization possibilities
Moderator: General Moderators
feyd | Please use
Something like that. 
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Well lets say your a member picks a HP-Boost potion (like what is going to be in my online RPG game ), then you'd simply select it from the database (using MySQL SELECT Query) then add a MySQL UPDATE Query in the equation too. For example:Code: Select all
<?php
$sql = "SELECT * FROM items WHERE item = 'HPBoost'";
$result = mysql_query($sql, $conn) or die(mysql_error());
while($it = mysql_fetch_array($result)) {
$sql1 = "UPDATE members SET hp = hp + '$it[upup]' WHERE userid = '$_COOKIE[userid]'";
$result1 = mysql_query($sql1, $conn) or die(mysql_error());
}
?>feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]