Author Topic: Limited Carrying Items.  (Read 20647 times)

Offline feildmaster

Limited Carrying Items.
« on: July 18, 2007, 06:33:07 am »
Hello and welcome to the first mod I posted here!

This mod gives every item an "item limit" so that members can't buy more than the limit. (By default all items are set as "unlimited")

This mod only works with SMF shop 3.0. If you have any questions direct them to my mod site (dunno if this is ok to list in this forum but i will anyway...) http://feildmaster.com/mods-codes/ bugs and stuff can be reported here, but help with the mod will only be given at the site mentioned. (or by ppl here...) Too busy to give help. =)

You set it by editing the item (also lets you set it when you make an item).
Download the attachment here...
« Last Edit: August 09, 2007, 06:32:30 am by feildmaster »

Offline feildmaster

Re: Limited Carrying Items.
« Reply #1 on: July 18, 2007, 07:49:45 am »
Oh yes... One note I forgot to mention... (to the person that downloaded it...)

It doesn't uninstall.... o.o You have to do it manualy...

Offline feeble

Re: Limited Carrying Items.
« Reply #2 on: July 18, 2007, 03:34:16 pm »
Nice work with this mod.

Works nicely, shame about the uninstall, but its a small thing

Offline feildmaster

Re: Limited Carrying Items.
« Reply #3 on: July 19, 2007, 12:21:16 am »
Yes, I'll figure it out sometime... and glad to hear it works nicely... ^^

Makes me want to finish all my other mods. ^^

Offline feeble

Re: Limited Carrying Items.
« Reply #4 on: July 19, 2007, 03:39:12 am »
Yes, I'll figure it out sometime... and glad to hear it works nicely... ^^

Makes me want to finish all my other mods. ^^
Lol.

how many you got going?

Offline feildmaster

Re: Limited Carrying Items.
« Reply #5 on: July 19, 2007, 06:32:09 am »
Bout 19 mods for adding stuff to already made mods. and... 4 completely new mods... lets see... a Lotto mod (stand alone and can join up with SMFShop...), a mod needed i need personally... (gonna make it a package anyway... ^^), a better more advanced pet mod (used to have one but... it wasn't too advanced. ^^), and... a secret mod i been working on for 2 months... (and been lazy on it...)

That's about it... oh yeah... n like 17 shop items... but that shouldn't be too hard...^^ actually im just saving them to do later...

jasonwatkins

  • Guest
Re: Limited Carrying Items.
« Reply #6 on: August 09, 2007, 12:23:05 am »
hi, i've tried to install this mod and get an error on the theme test ..



i'm using the scribbles theme for my main theme - any clues ?

Offline feildmaster

Re: Limited Carrying Items.
« Reply #7 on: August 09, 2007, 06:31:25 am »
Doesn't matter what theme you are using... it edits the default theme, upload your Shop.template.php and i will get u a new one/modify the package for u.

jasonwatkins

  • Guest
Re: Limited Carrying Items.
« Reply #8 on: August 09, 2007, 08:02:26 am »
ok, here it is .. from the default theme directory.  thanks for your help.

Offline feildmaster

Re: Limited Carrying Items.
« Reply #9 on: August 10, 2007, 02:22:57 am »
This one should work for u... o.o

Offline Xarcell

Re: Limited Carrying Items.
« Reply #10 on: August 27, 2007, 06:40:03 am »
I noticed you mentioned you were working on a pet mod. Any updates on that? Any demos available?

Offline feildmaster

Re: Limited Carrying Items.
« Reply #11 on: August 28, 2007, 07:17:45 am »
That will be significantly after I finish all of the lottery mod stuff...

Offline Daniel15

Re: Limited Carrying Items.
« Reply #12 on: August 31, 2007, 08:28:34 pm »
There are some problems with this package:
 - The ID needs to be in the format YourUsername:ModNameWithoutSpaces. For example, feildmaster:LimitItems. The current ID (Limit Items) is not in the required format.
 - You need to wrap all edits in the SMF_Shop_Limit.xml file CDATA tags. So, for example,
Code: [Select]
<operation>
<search position="before">
if ($context['shop_inv']['last_col_type'] == 'buy')
{
</search>
<add>
global $db_prefix, $ID_MEMBER;
//Cuz I am lazy lets put the query here.
$result = db_query("
SELECT count(*) as `count`
FROM {$db_prefix}shop_inventory
WHERE ownerid = '{$ID_MEMBER}' AND itemid = '{$item['id']}'", __FILE__, __LINE__);
$itemLimit = mysql_fetch_assoc($result);
$thingy=$item['limit'] - $itemLimit['count'];

</add>
</operation>
Should be
Code: [Select]
<operation>
<search position="before"><![CDATA[
if ($context['shop_inv']['last_col_type'] == 'buy')
{
]]></search>
<add><![CDATA[
global $db_prefix, $ID_MEMBER;
//Cuz I am lazy lets put the query here.
$result = db_query("
SELECT count(*) as `count`
FROM {$db_prefix}shop_inventory
WHERE ownerid = '{$ID_MEMBER}' AND itemid = '{$item['id']}'", __FILE__, __LINE__);
$itemLimit = mysql_fetch_assoc($result);
$thingy=$item['limit'] - $itemLimit['count'];

]]></add>
</operation>
This is so the < and > symbols do not cause problems.

 - Technically, queries are not allowed in templates.

Use my package parser (at http://modparser.dev.dansoftaustralia.net/) to see if the mod is valid. If it is, it should not give any errors, and display all the edits the mod does.
Also, you may want to read the SMF Coding Guidelines, available on simplemachines.org (as a stickyed topic in the Coding forum).

Good luck with all your mods :)

Quote
If you have any questions direct them to my mod site (dunno if this is ok to list in this forum but i will anyway...)
Sure, that's fine :)

Offline feildmaster

Re: Limited Carrying Items.
« Reply #13 on: September 01, 2007, 02:21:14 pm »
ah, i was having trouble using CDATA code on my packager. So I didn't include it unless it wouldn't work without the CDATA.

and i didn't know how the ID works. But yeah, the CDATA i wont include unless it's necessary to make it install.

also, who cares where queries go, it's better than making the text go in through source code. as long as it works, it is all fine.

oh n, sorry if i sound rude. But i never liked u anyway. I will not listen to ur pointers if a package is "valid"

Offline Daniel15

Re: Limited Carrying Items.
« Reply #14 on: September 01, 2007, 05:19:16 pm »
Quote
ah, i was having trouble using CDATA code on my packager. So I didn't include it unless it wouldn't work without the CDATA.
The CDATA tags are required, and will cause unexpected errors if they're omitted.
If  you don't use CDATA tags, you must escape all "special" characters. > needs to be &gt;, < needs to be &lt;, etc. See that Wikipedia article I linked to.
This is probably what's causing the uninstall error.

Quote
and i didn't know how the ID works.
It's all mentioned in the documentation.

Quote
also, who cares where queries go, it's better than making the text go in through source code. as long as it works, it is all fine.
Did you even read the SMF Coding Guidelines?

Quote
oh n, sorry if i sound rude. But i never liked u anyway.
Well, that's your choice.
I pay for the server for this site (and my others) from my pocket. No one else is involved; I'm paying for everything.
I dedicate time to writing SMF mods, time which I could spend doing other things. I'm still in high school and don't have that much free time.
I've never had ads on this site for a long period of time, and have never forced users to pay anything to access any of my code or my forum (nor will I ever do this).
All this to please the SMF community and users such as yourself.
If you don't like me, then fair enough.
But there's no reason to be mean about it.
Remember that access to this site is a priviledge, not a right.

Quote
I will not listen to ur pointers if a package is "valid"
Well then, if you write any of your own SMF mods, do not expect them to be approved on the SMF mods site. SMF mods are required to follow those guidelines, and the package needs to be valid. Unexpected errors can occur if it's not.