
Ragnar
Members-
Posts
150 -
Joined
-
Last visited
Never
Content Type
Profiles
Forums
Events
Everything posted by Ragnar
-
[mccode] Reset your users without deleating them
Ragnar replied to Redeye's topic in Free Modifications
Re: [v1 & v2]Reset your users without deleating them Read my post again, there is no user_level in userstats so that won't work. userid int(11) NOT NULL default '10', strength bigint(25) NOT NULL default '10', agility bigint(25) NOT NULL default '10', guard bigint(25) NOT NULL default '10', labour bigint(25) NOT NULL default '10', IQ bigint(25) NOT NULL default '10' You have to add some $q=$db->query("SELECT userstats.*, users.* FROM blah blah blah...",$c); code if it can be made to work. -
[mccode] Reset your users without deleating them
Ragnar replied to Redeye's topic in Free Modifications
Re: [v1 & v2]Reset your users without deleating them Is there an easy way to do this with out the NPC's geting reset? I'm guessing something like UPDATE users SET hp=100 WHERE user_level=1; though there is no user_level code in the userstats table. -
Re: Steps Market [V2] Is adding $_GET['ID'] = abs(@intval($_GET['ID'])); what makes it safe? Would puting that in header.php help make all scripts more secure?
-
Re: [site tools] auto backup your site Warning: file(backup-2008-04-17.sql.gz) [function.file]: failed to open stream: No such file or directory in /home/virtual/site1/fst/var/www/html/back-ups/back-up-cron.php on line 20 Warning: implode() [function.implode]: Bad arguments. in /home/virtual/site1/fst/var/www/html/back-ups/back-up-cron.php on line 20 which is $data = chunk_split(base64_encode(implode("", file($filename)))); Everything works except the script doing the mySQL command to create the back-up. I've tried the email, ftp, and cron version. I even tried changing $command = "mysqldump -u$dbuser --p$dbpwd $dbname > $filename"; to $command = "mysqldump -uroot -pXXXXXXXX clan > /home/virtual/site1/fst/var/www/html/back-ups/clan-4-16-08.sql"; the exact code I use to manually make back-ups. Does something else need to be done to give permission for the back-up to be made? Files do have 755 permissions. Edit: Duh!!!! Helps to have the directory where the file will be temporarily, be chmod 777!!!!
-
Re: Can't create armor (v2)??!! Thanks! *Hits myself on da head with a hammer!*
-
Am I missing something? I don't see an option to create armor! makes this item show up as a Weapon!
-
Re: Free Starter Pack Is there any way to have the Starter Pack in item form, an item that spits out money, crystals, doner days, items...? Where right when they register, it shows up in their inventory ready to use?
-
Re: [FAQ] Crons Guide * * * * * root curl http://w w.domain.com/cron_minute.php?code=XXXX It needed the root added to it.
-
Re: [FAQ] Crons Guide Yes the code/URL is right. As I said, when I go to the actual URL, it runs and updates!! (That's the minute one, so the * are all correct. On the correct path to the file, it already had 01 * * * * root run-parts /etc/cron.hourly 02 23 * * * root run-parts /etc/cron.daily 22 4 * * 0 root run-parts /etc/cron.weekly 42 4 1 * * root run-parts /etc/cron.monthly which are all empty files. So I think this file is where it goes. For the curl stuff, would that be changing curl to some path? Does apache or the server need to be reset when you add a cron? (I did reset them after adding them.)
-
Re: [FAQ] Crons Guide Is this correct?? * * * * * curl http://w w.domain.com/cron_minute.php?code=XXX Located at /etc/crontab yet it's not doing anything. When I go to the actual URL, it runs!!
-
Any one got tips for a new mccode game creator? (v2)
Ragnar replied to Ragnar's topic in General Discussion
Re: Any one got tips for a new mccode game creator? (v2) Yep, I know what too much money does!! I've been playing these types of games for about a year and a half, and all the games that have massive inflation, spit out or used to spit out, a lot of daily cash via the banks high interest rate. (I have no idea why 7.5% was made the Cyber Bank default!!) The bank seams to be the biggest cause of mass inflation! Compaired to bank interest, on high inflation games, crime spits out pennies!!! It's just the admin area, creating stuff that I need tips on, like the crime Success % Formula, Weapon Power/Armor Defence, and any extra security tips, even though it'll be impossible for players to take money/crystals from players who do mySQL exploits. -
I'm about to start work on my first game, and I'm looking for a few tips, since unlike version 1, version 2 doesn't come with pre-made stuff to use as examples to look at and change. 1. Crime. The default Success % Formula is ((WILL*0.8)/2.5)+(LEVEL/4). Could some one post an example of a just about 100% odds of wining code (For Level 1 newbies.), a say 50% odds of wining formula, and a hard to win crime formula (High level/very nice rewards one.). (Select the 'Don't use smileys.' forum option!) I'm guessing that if they all have the same formula, that getting enough brave will be the only real requirement, that by the time you have enough brave to do a crime, it will be just as easy to win as the one listed above it, since I don't see any BRAVE formula in there. 2. Weapons/Armor. What's the best way to figure out the Weapon Power/Armor Defense so they show a benefit when you first buy them, instead of being close to worthless from doing a lot of training? Any other method than trying to guess how much strength/defense players will have when they get to a new town? Right now I'm looking at something like... Level 1 town: 10 Weapon Power/Armor Defense Level 5 town: 5000 Level 10 town: 25000 Level 25 town: 50000 with the numbers based on how much stats players can gain from training and how easy it is to buy the property. Property will be something like... Name, cost, Will. Name 10,000 100 Name 50,000 200 Name 100,000 250 Name 200,000 450 Name 500,000 750 Name 1,000,000 1,000 Name 5,000,000 1,200 Name 10,000,000 1,600 Name 25,000,000 2,500 Name 50,000,000 4,500 Name 100,000,000 7,500 Name 250,000,000 12,000 Name 500,000,000 16,500 Name 1,000,000,000 25,000 Name 1,500,000,000 40,000 Name 2,000,000,000 50,000 3. Any economy tips? I don't want a slow as a slug economy where you have just a billion bucks after playing in a year, yet I also don't want to see 5,000,000,000,000,000,000 listings on the market for...a long time!!! Right now I'm thinking of giving 2% bank interest in the first bank, with the Cyber Bank 5%, or maybe 1% and 3%, with a doners only 5% bank. 4. Security for the markets (mySQL exploits). I know about $_GET['ID'] = abs(@intval($_GET['ID'])); Any other code I should use? I also got my own mod where if a player ends up over XXX money/crystals, you lose them until I look at the account/logs, and I won't be using the included forums. And if you have any other tips/suggestions, other than ;tldr :-D, let this n00bie know. Is there a n00bie guide some where!! (I'll first spend a while playing the game myself before showing my visitors the game.)
-
Version 2, but shouldn't be hard to convert. Don't like those annoying hard to see verification images or think some one might still be using an auto-refreasher and geting around it? Use logs. mySQL.... CREATE TABLE `trainlogs` ( `tlogID` int(11) NOT NULL auto_increment, `tlogTRAINERID` int(11) NOT NULL default '0', `tlogSTATS` varchar(255) NOT NULL default '0', `tlogAMOUNT` int(11) NOT NULL default '0', `tlogTIME` int(20) NOT NULL default '0', PRIMARY KEY (`tlogID`) ) TYPE=MyISAM AUTO_INCREMENT=1 ; -- -- Dumping data for table `trainlogs` -- CREATE TABLE `crimelogs` ( `crimID` int(11) NOT NULL auto_increment, `crimPLAYERID` int(11) NOT NULL default '0', `crimTIME` int(20) NOT NULL default '0', PRIMARY KEY (`crimID`) ) TYPE=MyISAM AUTO_INCREMENT=1 ; -- -- Dumping data for table `crimelogs` -- In docrime.php replace $_GET['c']=abs((int) $_GET['c']); with $_GET['c']=abs((int) $_GET['c']); $db->query("INSERT INTO crimelogs VALUES('',$userid,unix_timestamp());",$c); In gym.php replace if($ir['jail']) { $gain/=2; } with if($ir['jail']) { $gain/=2; } $db->query("INSERT INTO trainlogs VALUES('',$userid,'$stat',$gain,unix_timestamp());",$c); In staff_logs.php add case 'traininglogs': view_training_logs(); break; case 'crimelogs': view_crime_logs(); break; then at the end of the file right before $h->endpage(); ?> add function view_training_logs() { global $ir,$c,$h,$userid; print "<h3>Train Logs</h3> <table width=75% border=1> <tr> <th>ID</th> <th>Time</th><th>Trainer</th> <th>Amount</th> <th>Stats</th></tr>"; $q=mysql_query("SELECT * FROM trainlogs ORDER BY tlogID ASC",$c); while($r=mysql_fetch_array($q)) { print"<tr><td>{$r['tlogID']}</td> <td>".date('F j, Y, g:i:s a',$r['tlogTIME'])."</td><td>{$r['tlogTRAINERID']}</td><td>{$r['tlogAMOUNT']}</td><td>{$r['tlogSTATS']}</a></td> </tr>"; } } function view_crime_logs() { global $ir,$c,$h,$userid; print "<h3>Crime Logs</h3> <table width=75% border=1> <tr> <th>ID</th> <th>Time</th><th>Player</th></tr>"; $q=mysql_query("SELECT * FROM crimelogs ORDER BY crimID ASC",$c); while($r=mysql_fetch_array($q)) { print"<tr><td>{$r['crimID']}</td> <td>".date('F j, Y, g:i:s a',$r['crimTIME'])."</td><td>{$r['crimPLAYERID']}</td> </tr>"; } } In smenu.php add the links to the logs section. > Training Logs > Crime Logs "; If you get.... Parse error: syntax error, unexpected '&' in /public_html/smenu.php on line 58 Make sure only the last link has the "; at the end. Now, since people use crime and training a *LOT*, the logs will get big *FAST*!! In cron_day.php, add $db->query("DELETE FROM trainlogs WHERE tlogTIME < (unix_timestamp() -864000)",$c); $db->query("DELETE FROM crimelogs WHERE crimTIME < (unix_timestamp() -864000)",$c); Logs older than 10 days will be deleted. For 20 days and older, use 1728000. For 30 days and older, use 2592000.
-
Version 2, but shouldn't be hard to convert. Note: Do a back-up first!! If you're a mySQL n00bie and mess up on this, you're game can be royally screwed up!! If a player ends up with too much money or crystals, from say a mySQL injection, as soon as any one loads any page, he ends up with zero of it until an admin checks it out and edits his profile in the Admin Panel. Until then he will have zero money or crystals. Which ever the player goes over on he loses and can't get any more of to use, until checked out by admin, and if it's not a cheat, admin increases the cap in header.php, and deletes it from his account, using the edit user page, or moves it back to money/crystals *after* updating the cap. The best part about this is, it also keeps players from being able to attack the player for that money or crystals, making it much easier to manage when some one does for example a mySQL injection. mySQL... ALTER TABLE `users` ADD `moneyabuse` bigint(25) NOT NULL default 0; ALTER TABLE `users` ADD `crystalabuse` bigint(25) NOT NULL default 0; In attackwon.php attackwin.php (What ever name your file is if players can take crystals.) attacktake.php attacklost.php attackbeat.php and any other files that let players take money or crystals from players, right below include "globals.php"; add $db->query("UPDATE users SET laston=unix_timestamp(),lastip='$IP' WHERE userid=$userid"); $db->query("UPDATE users SET moneyabuse=money+moneyabuse WHERE money > 9000000000000000000"); $db->query("UPDATE users SET moneyabuse=money+moneyabuse WHERE moneyabuse > 9000000000000000000 AND money < 9000000000000000000"); $db->query("UPDATE users SET money=0 WHERE moneyabuse > 9000000000000000000"); $db->query("UPDATE users SET crystalabuse=crystals+crystalabuse WHERE crystals > 9234567891011121314"); $db->query("UPDATE users SET crystalabuse=crystals+crystalabuse WHERE crystalabuse > 9234567891011121314 AND crystals < 9234567891011121314"); $db->query("UPDATE users SET crystals=0 WHERE crystalabuse > 9234567891011121314"); Depending on the economy, replace the numbers to numbers that no one can get to with out cheating, but that's not too high to catch cheaters. For example, if the richest player has 100 billion in the bank, 1-10 trillion would probably be a good cap, or 500 billion if the economy grows slowly, until the economy get's close to having players get to 1-10 trillion, or 500 billion with out cheating. (By default the numbers are way too high, so n00bies don't destroy their game by not changing the numbers, and instead just make the mod useless!) For example, in the default code, if a player ends up with over $9000000000000000000 or 9234567891011121314 crystals, the players money or crystals, which ever goes over, gets moved to moneyabuse/crystalabuse (Making it unusable.) until you look in to it, increase the numbers in header.php if it's not cheating, *and* then move the money/crystals from moneyabuse/crystalabuse back to money/crystals using the edit user page, or fed them if it is cheating. No cron job required. Any time some one loads a page, it checks the users, making it so no one can get money or crystals before the cron would next run. (If you might have a server load/lag issue, you can put it in one of your cron files.) In staff_users.php Replace House: ".house2_dropdown($c, "maxwill", $itemi['maxwill'])." with House: ".house2_dropdown($c, "maxwill", $itemi['maxwill'])." Money Abuse: \$<input type='text' name='moneyabuse' value='{$itemi['moneyabuse']}' /> Crystal Abuse: <input type='text' name='crystalabuse' value='{$itemi['crystalabuse']}' /> Replace $_POST['forumban']=(int) $_POST['forumban']; with $_POST['forumban']=(int) $_POST['forumban']; $_POST['moneyabuse']=(float) $_POST['moneyabuse']; $_POST['crystalabuse']=(float) $_POST['crystalabuse']; Replace $db->query("UPDATE users SET username='{$_POST['username']}', level={$_POST['level']}, money={$_POST['money']}, crystals={$_POST['crystals']}, energy=$energy, brave=$nerve, maxbrave=$nerve, maxenergy=$energy, hp=$hp, maxhp=$hp, hospital={$_POST['hospital']}, jail={$_POST['jail']}, duties='{$_POST['duties']}', staffnotes='{$_POST['staffnotes']}', mailban={$_POST['mailban']}, mb_reason='{$_POST['mb_reason']}', forumban={$_POST['forumban']}, fb_reason='{$_POST['fb_reason']}', hospreason='{$_POST['hospreason']}', jail_reason='{$_POST['jail_reason']}', login_name='{$_POST['login_name']}', will=$will, maxwill=$maxwill WHERE userid={$_POST['userid']}"); with $db->query("UPDATE users SET username='{$_POST['username']}', level={$_POST['level']}, money={$_POST['money']}, crystals={$_POST['crystals']}, energy=$energy, brave=$nerve, maxbrave=$nerve, maxenergy=$energy, hp=$hp, maxhp=$hp, hospital={$_POST['hospital']}, jail={$_POST['jail']}, duties='{$_POST['duties']}', staffnotes='{$_POST['staffnotes']}', mailban={$_POST['mailban']}, mb_reason='{$_POST['mb_reason']}', forumban={$_POST['forumban']}, fb_reason='{$_POST['fb_reason']}', hospreason='{$_POST['hospreason']}', jail_reason='{$_POST['jail_reason']}', login_name='{$_POST['login_name']}', will=$will, maxwill=$maxwill, moneyabuse={$_POST['moneyabuse']}, crystalabuse={$_POST['crystalabuse']} WHERE userid={$_POST['userid']}"); In staff_logs.php add case 'moneysuspectlogs': view_moneysuspect_logs(); break; case 'crystalsuspectlogs': view_crystalsuspect_logs(); break; then at the end of the file, right before $h->endpage(); ?> add function view_moneysuspect_logs() { global $ir,$c,$h,$userid; print "<h3>Money Suspect Logs</h3> <table width=75% border=1> <tr> <th>Money</th><th>Player</th></tr>"; $q=mysql_query("SELECT * FROM users ORDER BY moneyabuse DESC",$c); while($r=mysql_fetch_array($q)) { print"<tr><td>\${$r['moneyabuse']}</td><td>{$r['username']}</td> </tr>"; } } function view_crystalsuspect_logs() { global $ir,$c,$h,$userid; print "<h3>Money Suspect Logs</h3> <table width=75% border=1> <tr> <th>Crystals</th><th>Player</th></tr>"; $q=mysql_query("SELECT * FROM users ORDER BY crystalabuse DESC",$c); while($r=mysql_fetch_array($q)) { print"<tr><td>{$r['crystalabuse']}</td><td>{$r['username']}</td> </tr>"; } } In smenu.php add the links at the logs section. > Money Suspect Logs > Crystal Suspect Logs "; If you get.... Parse error: syntax error, unexpected '&' in /public_html/smenu.php on line 58 Make sure only the last link has the "; at the end.
-
Re: Little crystal cap thing. The event wouldn't help much. More like it would just annoy us with a ton of events. It would be way more useful being a log and viewing it in the Staff section with the other logs.
-
Re: Secure Your Crons. Why don't you/they simply require something like cron_XXX.php?code=5e76gf8fg6fg1d-die-cheater-die-bc9JH783d28gl89U-p0wned0-Hbb0b in the URL??!! Version 2 already comes with this. Edit it in the database to make it even harder to figure out.
-
Re: Money,crystals cap LOL!! Can (92,4) also be used on money/banks so you can have that much, instead of a 'tiny' cap of 9,223,372,036,854,775,807!! :-D :-D
-
Re: [mccode] Stats Market They would have to be able to have a ton of cash to end up with the best stats in one day. I'm guessing your players don't end up being rich on day 1, unless the game has MASSIVE inflation!! And even if the game has that, all of other active players would be trying to snatch the stats up and have way more cash then the newbie! Only if a newbie can make it to being one of the richest players on day one would they be able to end up with the best stats using this!
-
Re: [mccode] Stats Market Duh! It's not supposed to add stats. Does the Crystal market add crystals to the game? No, 'you buy or take away cryatals you sell'. It's called buying and selling. That's why it has three things to keep that stuff from occuring. It comes with a price cap, a number of listings you can add at a time cap, and the biggest one, if you have 1000 IQ and a bazillion of the other stats, the max you can list of any stat, is 990 points. It also gives players one more reason to increase the almost useless stats like Labour and IQ.
-
Re: [mccode] Stats Market Thanks. Listing cap added.
-
Thanks to killah and Ghetto for helping me knock off a few bugs, and killah adding the 10 listings max, since I'm a mySQL total n00bie. This is the Crystal Market script converted in to a Stats Market, letting players sell their stats to other players. The current price cap is 200 per stat point, and can be increased to where a total listing price can be some where around $9.2 Quintillion, depending on the server. If the price cap is increased too much or removed, it can cause abuse. Players can list the stats on the market, making it easier for their friends to attack them to gain easy experience. Hence the price cap added. The most stats players can add *per listing* for any stat, is -10 of the stat that they have the least of. For example, if the lowest stat they got is IQ with 100 IQ, the most they can list per listing for any stat is 90. This adds one more way to make IQ and Labor useful! And they can't end up with less than 10 of any of the stats. If some one can, edit the script to add a max on the number of listings that a player can have at one time and post it. Edit: Max listing code has been added, with a max of 10 listings per player. Thanks killah. mySQL query.... -- -- Table structure for table `statsmarket` -- CREATE TABLE `statsmarket` ( `smID` int(11) NOT NULL auto_increment, `smQTY` int(11) NOT NULL default '0', `smADDER` int(11) NOT NULL default '0', `smPRICE` bigint(25) NOT NULL default '0', `smSTATS` varchar(255) NOT NULL default '0', PRIMARY KEY (`smID`) ) TYPE=MyISAM AUTO_INCREMENT=1 ; -- -- Dumping data for table `statsmarket` -- statsmarket.php (Version 2, but you got the sticky thread to use to convert it.) <?php include "globals.php"; print "<h3>Stats Market</h3>"; $_GET['ID'] = abs(@intval($_GET['ID'])); switch($_GET['action']) { case "buy": stats_buy(); break; case "remove": stats_remove(); break; case "add": stats_add(); break; default: statsmarket_index(); break; } function statsmarket_index() { global $db,$ir,$c,$userid,$h; print "[url='statsmarket.php?action=add']> Add A Listing[/url] Viewing all listings... <table width=75% cellspacing=1 class='table'> <tr style='background:gray'> <th>Adder</th> <th>Stat</th> <th>Qty</th> <th>Price each</th> <th>Price total</th> <th>Links</th> </tr>"; $q=$db->query("SELECT sm.*, u.* FROM statsmarket sm LEFT JOIN users u ON u.userid=sm.smADDER ORDER BY smPRICE/smQTY ASC"); while($r=$db->fetch_row($q)) { if($r['smADDER'] == $userid) { $link = "[url='statsmarket.php?action=remove&ID={$r[']Remove[/url]"; } else { $link = "[url='statsmarket.php?action=buy&ID={$r[']Buy[/url]"; } $each= (float) $r['smPRICE'] / $r['smQTY']; print "\n<tr> <td>[url='viewuser.php?u={$r[']{$r['username']}[/url] [{$r['userid']}]</td> <td>{$r['smSTATS']}</td> <td>{$r['smQTY']}</td> <td> \$" . number_format($each)."</td> <td>\$".number_format($r['smPRICE'])."</td> <td>[$link]</td> </tr>"; } print "</table>"; } function stats_remove() { global $db,$ir,$c,$userid,$h; $f = mysql_query("SELECT * FROM statsmarket WHERE smID='{$_GET['ID']}'") or die(mysql_error()); $a = mysql_fetch_assoc($f); $q=$db->query("SELECT us.*,sm.* FROM statsmarket sm LEFT JOIN userstats us ON sm.smQTY=us.{$a['smSTATS']} WHERE sm.smID='{$_GET['ID']}' AND sm.smADDER='{$ir['userid']}'"); if(!$db->num_rows($q)) { print "Error, either this listing doesn't exist, or you are not the owner. [url='statsmarket.php']> Back[/url]"; $h->endpage(); exit; } $r=$db->fetch_row($q); //FIXED $db->query("UPDATE userstats SET {$r['smSTATS']}={$r['smSTATS']}+{$r['smQTY']} WHERE userid='{$ir['userid']}'") or die(mysql_error()); $db->query("DELETE FROM statsmarket WHERE smID={$_GET['ID']}"); print "Stats removed from market! [url='statsmarket.php']> Back[/url]"; } function stats_buy() { global $db,$ir,$c,$userid,$h; $q=$db->query("SELECT * FROM statsmarket st WHERE smID={$_GET['ID']}"); if(!$db->num_rows($q)) { print "Error, either this listing doesn't exist, or it has already been bought. [url='statsmarket.php']> Back[/url]"; $h->endpage(); exit; } $r=$db->fetch_row($q); if($r['smPRICE'] > $ir['money']) { print "Error, you do not have the funds to buy these stats. [url='statsmarket.php']> Back[/url]"; $h->endpage(); exit; } $db->query("UPDATE userstats SET {$r['smSTATS']}={$r['smSTATS']}+{$r['smQTY']} WHERE userid=$userid"); $db->query("DELETE FROM statsmarket WHERE smID={$_GET['ID']}"); $db->query("UPDATE `users` SET `money` = `money` - {$r['smPRICE']} WHERE `userid`={$ir['userid']}"); $db->query("UPDATE `users` SET `money`=`money` + {$r['smPRICE']} where `userid`={$r['smADDER']}"); event_add($r['smADDER'],"[url='viewuser.php?u=$userid']{$ir['username']}[/url] bought your {$r['smQTY']} {$r['smSTATS']} from the market for \$".number_format($r['smPRICE']).".",$c); print "You bought the {$r['smQTY']} {$r['smSTATS']} from the market for \$".number_format($r['smPRICE'])."."; print " [url='statsmarket.php']> Back[/url]"; } function stats_add() { global $db,$ir,$c,$userid,$h; $_POST['amnt'] = abs($_POST['amnt']); $_POST['price'] = abs($_POST['price']); if($_POST['amnt']) { if($_POST['amnt'] > $ir['strength']-10 || $_POST['amnt'] > $ir['IQ']-10 || $_POST['amnt'] > $ir['labour']-10 || $_POST['amnt'] > $ir['agility']-10 || $_POST['amnt'] > $ir['guard']-10) { echo "You are trying to add more stats to the market than you can add. Look at the stats, at the stat that you have the least of. Subtract that number by 10. That's the most you can add per listing for any stat. For example, if your lowest stat is IQ with 100 IQ, the most you can list per listing for any stat is 90. You must always have at least 10 of all stats. Strength: {$ir['strength']} Agility: {$ir['agility']} Guard: {$ir['guard']} Labour: {$ir['labour']} IQ: {$ir['IQ']} <a href='statsmarket.php'>> Back"; $h->endpage(); exit; } if($_POST['price'] > 200) { echo "You can only sell stats for up to 200 each. <a href='statsmarket.php'>> Back"; $h->endpage(); exit; } $a = mysql_query("SELECT * FROM statsmarket WHERE smADDER='{$ir['userid']}'") or die(mysql_error()); if(mysql_num_rows($a) > 9) { echo 'You may only add 10 listings.'; $h->endpage(); exit; } $tp=$_POST['amnt']*$_POST['price']; $db->query("INSERT INTO statsmarket VALUES('',{$_POST['amnt']},$userid,$tp,'{$_POST['sellstat']}')"); $db->query("UPDATE userstats SET {$_POST['sellstat']}={$_POST['sellstat']}-{$_POST['amnt']} WHERE userid=$userid"); print "Stats added to market! [url='statsmarket.php']> Back[/url]"; } else { print "[b]Adding a listing...[/b] Look at the stats, at the stat that you have the least of. Subtract that number by 10. That's the most you can add per listing for any stat. For example, if your lowest stat is IQ with 100 IQ, the most you can list per listing for any stat is 90. You must always have at least 10 of all stats. <form action='statsmarket.php?action=add' method='post'><table width=70% border=2><tr><td>Stats to add to market: </td> <td> <select type='dropdown' name='sellstat'> <option value='strength'>Strength (Have {$ir['strength']}) <option value='agility'>Agility (Have {$ir['agility']}) <option value='guard'>Guard (Have {$ir['guard']}) <option value='labour'>Labour (Have {$ir['labour']}) <option value='IQ'>IQ (Have {$ir['IQ']})</select></td></tr><tr> <td>How many stats:</td> <td><input type='text' name='amnt' value='' /></td></tr><tr> <td>Price for each stat:</td> <td><input type='text' name='price' value='200' /></td></tr><tr> <td colspan=2 align=center><input type='submit' value='Add To Market' /></tr></table></form>"; } } $h->endpage(); ?>
-
Re: BANK cap V2 Just doing for example ALTER TABLE `crystalmarket` CHANGE `cmPRICE` `cmPRICE` BIGINT( 25 ) DEFAULT '0' NOT NULL doesn't cut it. It still lists them at 2147...unless in the script you do a few small changes, changing int to float... $each= (float) $r['cmPRICE'] / $r['cmQTY']; $_POST['amnt'] = abs((float) $_POST['amnt']); $_POST['price'] = abs((float) $_POST['price']); Then it's pro massive inflation!
-
I'm making a mod that's an Item Wanted market, where players post listings of items and how much they'll pay for them, instead on mailing every one asking for them. (It's the opposite of the Item Market.) The only trouble I'm having is geting the script to know how many of an item you got (You can post a listing for more than one of an item, like 10 Will Potions.) The bold part of the code is what seams to cause the trouble.... $q=$db->query("SELECT * FROM iwmarket iw LEFT JOIN items i ON iw.iwITEM=i.itmid JOIN users u ON iw.iwADDER=u.userid JOIN inventory iv ON iw.iwQTY=iv.inv_qty WHERE iwID={$_GET['ID']}",$c); if(!$db->num_rows($q)) { print "Error, either this item does not exist, or it has already been bought. > Back"; $h->endpage(); exit; } $r=$db->fetch_row($q); if($r['iwQTY'] < $ir['inv_qty']) { print "Error, you do not have this item to sell, or enough of them to sell. > Back"; Got enough of the item and sell to player --> Error, either this item does not exist, or it has already been bought. Don't have enough and try to sell to player --> Error, either this item does not exist, or it has already been bought. Try to sell just one and you do have it. --> Works. What do you change it to so it knows if you have enough of the item in your inventory to sell the item to the player, even when some one wants to buy more then one of an item?
-
Re: Better than Quantifying You can do Quantifying with out having to edit a bunch of files, and the users still won't have to click any Quantifying link. They will have no idea they did this. For version 2, just rename your current inventory.php to items.php and make inventory.php... <?php include "globals.php"; $used=array(); $q=mysql_query("SELECT * FROM inventory WHERE inv_userid=$userid", $c); while ( $r=mysql_fetch_array($q) ) { if ( ! in_array ( $r['inv_id'], $used ) ) { $currdel=array(); $used[] =$r['inv_id']; $currdel[]=$r['inv_id']; $amount=$r['inv_qty']; //grab sellers others $q2=$db->query("SELECT * FROM inventory WHERE inv_userid=$userid AND inv_itemid = {$r['inv_itemid']} AND inv_id != {$r['inv_id']}", $c); while ( $r2 = mysql_fetch_array($q2) ) { $used[]=$r2['inv_id']; $currdel[]=$r2['inv_id']; $amount+=$r2['inv_qty']; } //if($userid == 1) //print "DEBUG: DELETE FROM inventory WHERE inv_id IN(".implode(",",$currdel).") "; $db->query("DELETE FROM inventory WHERE inv_id IN(".implode(",",$currdel).")", $c); //if($userid == 1) //print "DEBUG: INSERT INTO inventory VALUES('', {$r['inv_itemid']}, $userid, $amount) "; $db->query("INSERT INTO inventory VALUES('', {$r['inv_itemid']}, $userid, $amount)", $c); print "$amount of item id {$r['inv_itemid']} quantified... "; } } header("Location: items.php"); $h->endpage(); ?> Every time a player clicks the Inventory link, they will go to items.php and have no idea they did the Quantify!