Jump to content
MakeWebGames

Recommended Posts

Posted

ok im trying to make it that when you equip a wep in the users table it saves where the files can be found but im having problems getting it to work instead of doing what i want it to do its chucking out a SQL error and showing the pic instead of just equiping the weapon im gonna post the alter sql and the code and hopefully some1 can point me in the right direction

here is the alter sql

[mysql]

ALTER TABLE `users` ADD `primarypic` VARCHAR( 255 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL

ALTER TABLE `users` ADD `secondarypic` VARCHAR( 255 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL

[/mysql]

here is the stock equip_weapon plus my little bit of code

<?php
include "globals.php";
$_GET['ID'] = abs((int) $_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";
$h->endpage();
exit;
}
else
{
$r=$db->fetch_row($id);
}
if(!$r['weapon'])
{
print "This item cannot be equipped to this slot.";
$h->endpage();
exit;
}
if($_GET['type'])
{
if(!in_array($_GET['type'], array("equip_primary", "equip_secondary")))
{
print "This slot ID is not valid.";
$h->endpage();
exit;
}
if($ir[$_GET['type']])
{
item_add($userid, $ir[$_GET['type']], 1);
}
item_remove($userid, $r['itmid'], 1);
$db->query("UPDATE users SET {$_GET['type']} = {$r['itmid']} WHERE userid={$userid}");
if($r['itmpic']) {
$itmpic = "[img=itmpics/".$r[]query("UPDATE users SET secendarypic = '{$itmpic}' WHERE userid={$userid}");
}
else
{
$db->query("UPDATE users SET primarypic = '{$itmpic}' WHERE userid={$userid}");
}
print "Item {$r['itmname']} equipped successfully.";
}
else
{
print "<h3>Equip Weapon</h3><hr />
<form action='equip_weapon.php' method='get'>
<input type='hidden' name='ID' value='{$_GET['ID']}' />
Please choose the slot to equip {$r['itmname']} to, if there is already a weapon in that slot, it will be removed back to your inventory.

<input type='radio' name='type' value='equip_primary' checked='checked' /> Primary

<input type='radio' name='type' value='equip_secondary'  /> Secondary

<input type='submit' value='Equip Weapon' /></form>";
}
$h->endpage();
?>

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...