SMF Shop

SMFShop => Completed Additions => Modifications => Topic started by: feildmaster on July 18, 2007, 06:33:07 am

Title: Limited Carrying Items.
Post by: feildmaster 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...
Title: Re: Limited Carrying Items.
Post by: feildmaster 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...
Title: Re: Limited Carrying Items.
Post by: feeble on July 18, 2007, 03:34:16 pm
Nice work with this mod.

Works nicely, shame about the uninstall, but its a small thing
Title: Re: Limited Carrying Items.
Post by: feildmaster 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. ^^
Title: Re: Limited Carrying Items.
Post by: feeble 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?
Title: Re: Limited Carrying Items.
Post by: feildmaster 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...
Title: Re: Limited Carrying Items.
Post by: jasonwatkins on August 09, 2007, 12:23:05 am
hi, i've tried to install this mod and get an error on the theme test ..

(http://i79.photobucket.com/albums/j145/jasonwatkins/Screenshot.png)

i'm using the scribbles theme for my main theme - any clues ?
Title: Re: Limited Carrying Items.
Post by: feildmaster 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.
Title: Re: Limited Carrying Items.
Post by: jasonwatkins on August 09, 2007, 08:02:26 am
ok, here it is .. from the default theme directory.  thanks for your help.
Title: Re: Limited Carrying Items.
Post by: feildmaster on August 10, 2007, 02:22:57 am
This one should work for u... o.o
Title: Re: Limited Carrying Items.
Post by: Xarcell 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?
Title: Re: Limited Carrying Items.
Post by: feildmaster on August 28, 2007, 07:17:45 am
That will be significantly after I finish all of the lottery mod stuff...
Title: Re: Limited Carrying Items.
Post by: Daniel15 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 (http://en.wikipedia.org/wiki/CDATA). 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 :)
Title: Re: Limited Carrying Items.
Post by: feildmaster 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"
Title: Re: Limited Carrying Items.
Post by: Daniel15 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.
Title: Re: Limited Carrying Items.
Post by: feildmaster on September 02, 2007, 06:45:10 am
im not about to put my mods on that place anyway. I'll use my site.
Title: Re: Limited Carrying Items.
Post by: sc2 on October 19, 2007, 11:06:50 am
Yeah, that was pretty mean feildmaster... I don't know what you have against Daniel, but good advice given should be taken. You shouldn't disregard it just because you don't like someone and if you don't have something nice to say then don't say it at all. I honestly can't see why you would act that way considering all Daniel did was give you some tips on how to improve your code, most people would be grateful.
Title: Re: Limited Carrying Items.
Post by: Lily Flor on November 11, 2007, 04:37:34 am
If I was Daniel I would probably kick this fieldmaster guy out of this forum.  &gt;:( &gt;:( &gt;:(
So Rude!!
Title: Re: Limited Carrying Items.
Post by: AndyII on February 03, 2008, 06:18:54 am
sorry to re hash old stuff, but I find it important to say, that Daniel is a very bright and talented young man, its very obvious looking at his work.
Some may just be envious of his abilities, I am just glad to call him friend and enjoy his work....  :)