Jump to content
MakeWebGames

How to add an item to everyones inventory?


Hendrickson

Recommended Posts

I think that only adds to one person inventory doesn't it?

I would liek to add an items to everyone's. What would the mysl query for that be?

With Mccodes V2 there is a mass give items. You should be able to give to everyone.. It should look something like this

staff_items.php?action=massitemgive

Link to comment
Share on other sites

Open up staff_items.php

under

switch($_GET['action'])

{

add

case 'massitemgive': mass_give_item(); break;
case 'massitemgivesub': mass_give_item_sub(); break;

 

At the bottom of the page before

 

$h->endpage();
?>

 

add

 

function mass_give_item()
{
global $db,$ir,$c;
print "<h3>Giving Item To All Users</h3>
<form action='staff_items.php?action=massitemgivesub' method='post'>
Item: ".item_dropdown($c,'item')."<br />
Quantity: <input type='text' name='qty' value='1' /><br />
<input type='submit' value='Mass Send' /></form>";
}
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))
{
$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 "<br /><font color=blue>Mass item sending complete!</br></font>";
stafflog_add("Gave {$_POST['qty']} of item ID {$_POST['item']} to all users");
}

You'll have to add the link if its not there already but that should do it.

Edited by chicka
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Indeed just put it in the actual query your check for players that have been on in the last 7 days. No need for the if...

Link to comment
Share on other sites

Indeed just put it in the actual query your check for players that have been on in the last 7 days. No need for the if...

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
}

 

Sorry I'm noob and hwo do I just put it in the query?

 

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...