
gurpreet
Members-
Posts
834 -
Joined
-
Last visited
-
Days Won
1
Content Type
Profiles
Forums
Events
Everything posted by gurpreet
-
Paid mod. Limit donator and normal bank account interest
gurpreet replied to Hendrickson's topic in Requests & In Production
Wouldn't he also need to add some checks in the bank.php file to check if the deposit amount exceeds the cap he set? -
Do you mean creating a new $ir? For example like this (I will use the users table, just for an example) $users['username']? If so, you're looking for a mysql_fetch_array, or a mysql_fetch_object mysql_fetch_ array is basically the format you're looking for. It gets information from the DB and stored it as an array into the var you provide. So something like this: $q = mysql_query("SELECT userid, username, money FROM users WHERE userid = {$ir['userid']}"); while($users = mysql_fetch_array($q)) // This basically stores the info from $q into an array called $users. { echo "You are $users['username'] ($users['username']) and you have a total of \$" . number_format($users['money']) . " "; } Mysql_fetch_object I don't know too much about, but it's used in a different way. Instead of being $users['username'] it would be $users->username If anyone would care to elaborate more as I think I provide a basic explanation it would be great. Any questions newttster post them here and I'll try to help :)
-
accept goods sent instead of just auto accept
gurpreet replied to marvin's topic in General Discussion
Oops sorry missed that bracket. Try this: $db->query("UPDATE inventory SET pending={$_GET['user']}, pending_amount={$_GET['qty']} WHERE inv_itemid={$r['inv_itemid']}"); -
accept goods sent instead of just auto accept
gurpreet replied to marvin's topic in General Discussion
Change: $db->query("UPDATE inventory SET pending={$_GET['user']}, pending_amount={$_GET['qty']} WHERE inv_itemid={$r['inv_itemid']}')"); To: $db->query("UPDATE inventory SET pending={$_GET['user']}, pending_amount={$_GET['qty']} WHERE inv_itemid={$r['inv_itemid']})"); -
accept goods sent instead of just auto accept
gurpreet replied to marvin's topic in General Discussion
You would put John's ID. This can be changed but it would take a while -
accept goods sent instead of just auto accept
gurpreet replied to marvin's topic in General Discussion
Ah ok I'm not too sure to be honest, they have the correct format and the values are all correct if i echo each one out. -
accept goods sent instead of just auto accept
gurpreet replied to marvin's topic in General Discussion
Ah ok I'm not too sure to be honest, they have the correct format and the values are all correct if i echo each one out. -
accept goods sent instead of just auto accept
gurpreet replied to marvin's topic in General Discussion
Heh I did, but they messed up. If you're referring to the UPDATE inventory part in itemsend, then it's necessary. The pending and pending_amount columns are NULL, but when someone sends an item, the null fields get filled. Then once accepted, the original record deletes but the item_add doesn't work (the accept and decline functions are buggeed and I couldn't fix them) -
accept goods sent instead of just auto accept
gurpreet replied to marvin's topic in General Discussion
You need to enter the user ID, not the username. As you can see it says "where USERID = xx" -
As Dominion said, attempt to do this then ask around for help with errors and such. If you can't do this, then read up on php.net and tizag, maybe even w3schools
-
accept goods sent instead of just auto accept
gurpreet replied to marvin's topic in General Discussion
I've done what Pitch Black suggested and created 2 new columns in the inventory table - pending, pending_amount. Here's what I got so far, it works fine for the index(), but the accept is bugged. 1) It doesn't accept the correct item, it accepts 1 item above. 2) It doesn't add the item to the receiver (me)'s inventory. Same with the decline. If someone could work on it and finish it, it would be great. P.S - Thanks very much Pitch Black for your help on IRC and putting up with me! I came across a lot of bugs when making this and Pitch Black helped me fix them all! itemsend.php: <?php include "globals.php"; //itemsend $_GET['ID'] = abs((int) $_GET['ID']); $_GET['qty'] = abs((int) $_GET['qty']); if($_GET['qty'] && $_GET['user']) { $id=$db->query("SELECT iv.*,it.* FROM inventory iv LEFT JOIN items it ON iv.inv_itemid=it.itmid WHERE iv.inv_id={$_GET['ID']} AND iv.inv_userid=$userid LIMIT 1"); if($db->num_rows($id)==0) { print "Invalid item ID"; } else { $r=$db->fetch_row($id); $m=$db->query("SELECT * FROM users WHERE userid={$_GET['user']} LIMIT 1"); if($_GET['qty'] > $r['inv_qty']) { print "You are trying to send more than you have!"; } else if( $_GET['qty'] <= 0) { print "You haven't entered a valid amount to send."; } else if($db->num_rows($m) == 0) { print "You are trying to send to an invalid user!"; } else { $rm=$db->fetch_row($m); //are we sending it all print "You sent {$_GET['qty']} {$r['itmname']}(s) to {$rm['username']}. However, they must accept this item before they can use it."; event_add($_GET['user'],"You received {$_GET['qty']} {$r['itmname']}(s) from <a href='viewuser.php?u=$userid'>{$ir['username']}</a>. Click <a href='acceptitems.php'>Here</a> to accept this item and view another items you have yet to accept.",$c); $db->query("INSERT INTO itemxferlogs VALUES('',$userid,{$_GET['user']},{$r['itmid']},{$_GET['qty']},unix_timestamp(), '{$ir['lastip']}', '{$rm['lastip']}')"); $db->query("UPDATE inventory SET pending={$_GET['user']}, pending_amount={$_GET['qty']} WHERE inv_itemid={$r['inv_itemid']}')"); } } } else if($_GET['ID']) { $id=$db->query("SELECT iv.*,it.* FROM inventory iv LEFT JOIN items it ON iv.inv_itemid=it.itmid WHERE iv.inv_id={$_GET['ID']} AND iv.inv_userid=$userid LIMIT 1"); if($db->num_rows($id)==0) { print "Invalid item ID"; } else { $r=$db->fetch_row($id); print "<b>Enter who you want to send {$r['itmname']} to and how many you want to send. You have {$r['inv_qty']} to send.</b><br /> <form action='itemsend.php' method='get'> <input type='hidden' name='ID' value='{$_GET['ID']}' />User ID: <input type='text' name='user' value='' /><br /> Quantity: <input type='text' name='qty' value='' /><br /> <input type='submit' value='Send Items (no prompt so be sure!)' /></form>"; } } else { print "Invalid use of file."; } $h->endpage(); ?> acceptitems.php <?php include "globals.php"; $_GET['action'] = isset($_GET['action']) && is_string($_GET['action']) ? strtolower(trim($_GET['action'])) : ""; switch($_GET['action']) { case "accept": accept(); break; case "decline": decline(); break; default: index(); break; } function index() { global $db,$ir,$c,$userid,$h; $q = $db->query("SELECT i.itmid, i.itmname, inv.*, u.username, u.userid FROM inventory inv LEFT JOIN users u ON inv.pending=u.userid LEFT JOIN items i ON i.itmid=inv.inv_itemid WHERE inv.pending={$ir['userid']}"); $num = mysql_num_rows($q); echo "<h3>Accept Items</h3><br><br> The items that you have yet to accept are listed below.<br>"; if($num==0) { echo "You do not have any items to accept.<br>> <a href='index.php'>Go home</a>"; } else { echo "<table width='100%' border='1'> <tr> <th>From</th> <th>Item Name</th> <th>Quantity</th> <th>Time</th> <th>Accept</th> <th>Decline</th> </tr>"; while($item = mysql_fetch_array($q)) { $sent=date('F j, Y, g:i:s a',$item['timeSENT']); echo "<tr> <td>{$item['username']}</td> <td>{$item['itmname']}</td> <td>{$item['pending_amount']}</td> <td>$sent</td> <td><a href='acceptitems.php?action=accept'>Accept</a></td> <td><a href='acceptitems.php?action=decline'>Decline</a></td>"; } echo "</table>"; } } function accept() { global $db,$ir,$c,$userid,$h; $q = $db->query("SELECT i.itmid, i.itmname, inv.*, u.username, u.userid FROM inventory inv LEFT JOIN users u ON inv.pending=u.userid LEFT JOIN items i ON i.itmid=inv.inv_itemid WHERE inv.pending={$ir['userid']}"); $num = mysql_num_rows($q); $item = mysql_fetch_array($q); if($num==0) { die("Either this is not your item to accept or this has already been accepted."); } echo "You have <span style=color:green;>accepted</span> the item <span style=color:green;>{$item['itmname']}</span> from <span style=color:green;>{$item['username']}</span>. Click <a href='acceptitems.php'>Here</a> to go back to accept more items.<br>"; item_add($ir['userid'],$item['inv_itemid'],$item['pending_amount']); mysql_query("DELETE FROM inventory WHERE inv_id={$item['inv_id']}"); } function decline() { global $db,$ir,$c,$userid,$h; $q = $db->query("SELECT i.itmid, i.itmname, inv.*, u.username, u.userid FROM inventory inv LEFT JOIN users u ON inv.pending=u.userid LEFT JOIN items i ON i.itmid=inv.inv_itemid WHERE inv.pending={$ir['userid']}"); $num = mysql_num_rows($q); $item = mysql_fetch_array($q); if($num==0) { die("Either this is not your item to decline or this has already been declined and sent back to the sender."); } echo "You have <span style=color:red;>declined</span> the item <span style=color:red;>{$item['itmname']}</span> from <span style=color:red;>{$item['username']}</span>. Click <a href='acceptitems.php'>Here</a> to go back to accept or decline more items.<br>"; //Needs 2 working queries, 1 to add and 1 to remove } ?> -
Well for destroying a session to force a log out will be in your force_user_logout function. Here it is in your globals file: if($ir['force_logout']) { $db->query("UPDATE users SET force_logout=0 WHERE userid=$userid"); session_unset(); session_destroy(); header("Location: login.php"); exit; } Not sure what you want here, but you can work with that.
-
accept goods sent instead of just auto accept
gurpreet replied to marvin's topic in General Discussion
Anything's possible :) I'm guessing a new table would have to be created, and then when someone sends an item it gets put into that table instead of the other users inventory. Then once the receiver accepts it, it gets removed from that table and into their inventory. So like this User1 sends User2 a gun It gets inserted into the table, lets say 'itemsend' and an event gets created telling them to accept it. A page would probably have to be created where users can see their goods that have to be accepted User2 accepts the goods and it gets removed from 'itemsend' and inserted into User2's inventory -
Alright thanks, I'm going to leave the house tax in the houses table because I don't have many columns in there, and changing that would be a lot of work and put the repossession in another table. I mean like an upkeep, for example when you have an employee you pay them wages, but in a different sense. Not sure how I would apply the concept, but the concept behind it would probably be you have to pay the upkeep to make sure that your weapon doesn't get damaged (but it's daily so they don't do anything). The more expensive items they have, the more upkeep they will have. This will help to keep the number of items down, and inflation down a lot. Perhaps I might include certain donator items so they don't pay upkeep for a few days, and donator items have no upkeep. EDIT: Not sure what would be the best way to link the tables and such together. Would this be good or is there an easier way?: Creating a table called 'tax' with taxID (auto_increment), taxowed and userid. This table would be only for reposessions. In the day cron add an if statement so that if their tax amounts to 75% of their house, it will get put into the 'tax' table and the user will lose their house. Once they have paid off their tax completely, they will regain their house. EDIT 2: Got it all working properly, thanks to Dominion for all his help.
-
Alright, I'll use the system you have explained. That is much better than what I thought of lol. I call the debt value on the index page (an if statement to check if they do owe anything) and on the page where they pay off their tax. Also I will be adding more taxes later on, for more expensive items and maybe even much more complicated systems later on. Would you suggest creating a new table as it's only called on 2 pages (and the loggedin page)?
-
How to move decimal place to the left on prices
gurpreet replied to Hendrickson's topic in General Discussion
You could create a php script for this, I'm terrible at SQL. In the php page include your globals (just for a one time use then delete the file) and select the items and such. Then use a while loop and make a variable like: $newprice = $whilevar['itmbuyprice'] / 100; Then insert the $newprice into the items table. However I would suggest making it more complicated by checking for certain values like if the price is between 0 and 10,000 it will divide by 1 amount, 10,000 - 500,000 another etc. -
How to add an item to everyones inventory?
gurpreet replied to Hendrickson's topic in General Discussion
Ah ok, so just something like this? I think I got it backwards lol: $week = time() - (60*60*24*7); if($r['laston'] > $week) { query here } function mass_give_item_sub() { global $db,$ir,$c; $q=mysql_query("SELECT * FROM users WHERE fedjail=0",$c); while($r=mysql_fetch_array($q)) { $week = time() - (60*60*24*7); if($r['laston'] > $week) { $db->query("INSERT INTO inventory VALUES('',{$_POST['item']},{$r['userid']},{$_POST['qty']})",$c) or die(mysql_error()); event_add($r['userid'],"All users were given an item $itemname, Click <a href='inventory.php'>Here</a> to check.",$c); print "Item Sent To {$r['username']}</br>"; } print "<font color=blue>Mass item sending complete!</br></font>"; stafflog_add("Gave {$_POST['qty']} of item ID {$_POST['item']} to all users"); } } That should work. -
Hi again guys, I'm currently making a house tax mod from scratch and I'm going to make it quite complex (well I think it is). The house tax is 0.5 percent of the house buy price. So far I got the day cron for it, and if they can't pay it off, (checks money in hand, and all banks in case they try to be clever and hide it) the tax amount gets inserted into a field called 'taxowed' in the users table. If their taxowed is greater than 1 then they can go to a page called paytax.php, which I've made and works perfectly. However I'm not sure what the most efficient way of going about the next step is. What I want to do is that once thier taxowed reaches the value of their house, their house will get repossessed (inserted into a new table?). And if they can pay this back, they get the house back. If not, then certain gameplay features will get taken away (games centre, attacking etc) and maybe later certain item types. So what I'm basically asking is what would be the best way to do the repossession feature? Would I make a new table and do a check in the daily cron, and if their tax hits the value of their house they lose their house? Thanks for your time
-
I'm guessing the forum change added the http:// and such. That's not really fixing.
-
How to add an item to everyones inventory?
gurpreet replied to Hendrickson's topic in General Discussion
Add laston in your select query, then do something like this: $week = time() - (60*60*24*7); if($r['laston'] < $week) { } else { the code for giving items and such goes here } $h->endpage(); Something like that, there may be a better way to do it but that should work fine. -
Richards Business Mod--Fixed With a few Things added.
gurpreet replied to Joshua's topic in Free Modifications
Try this: <b>Director /b> <a href='viewuser.php?u=' . $r['userid'] . '>' .stripslashes($r['username']) . ' </a> <td><a href="viewuser.php?u={$fm['userid']}">'.stripslashes($fm['username']).'</a> ['.$fm['userid'].']</td> -
http://lmgtfy.com/?q=javascript+time Or even http://lmgtfy.com/?q=javascript+clock
-
[mccodes v2] Find random items while playing the game...
gurpreet replied to MDK666's topic in Free Modifications
$fia=(int) rand(10,99); $fib=(int) rand(10,99); I think this is right, correct me if I'm wrong, but the chance of finding an item is 89 * 89. So users have a 1 in 7921 chance. If you want to make it easier, make the gap smaller, if you want them to have less of a chance, increase the gap between the numbers. Simple -
In your login it will create a session. Not sure where the definition of the cookies and session is but just look around your global files and header etc.