Jump to content


Photo

Virtual Shop quantity...


  • Please log in to reply
4 replies to this topic

#1 SirChick

SirChick
  • Members
  • PipPipPip
  • Advanced Member
  • 755 posts

Posted 01 February 2006 - 06:35 PM

Ok i have a shop on my website (non real) where by as you earn money you buy items etc. The code works well but i want to have a counter so the admin of the site decides how many of the items are available. So for example, if a new "rare" item came to the shop and the admin sets the quantity to one. Then only one person gets it and the first one who can afford it, buys it. Then once they have bought it, itll tell the other users the quantity in stock = 0 thus disabling the ability to buy it. This would help me for getting more "rare" items in to the game cos atm there is no quantity and so any one can buy it which kinda reduces the rareity once more people have puchased it.

The code for the shop is this:



<script type="text/javascript">
<!--
/*
YourShop
Version 0.2

This Header must remain intact at all times.

*/

// staff that can mange shop settings
var shopAdmin = [
"admin"
];

// staff that can edit money
// Note: Users in shopAdmin do not need to be listed here too
var shopStaff = [
"ccworld"
];

var moneyName = "Pounds";
var moneySym = "$";
var moneyPP = 2;
var shopOn = 1;
var shopSig = 0;
var shopAvatar = 0;
var useButton = 1;
// can leave blank ""
var buttonUrl = "http://theccworld.co...card_shop.gif";

/*ITMLSTSTRHRE*/
var addOnItems = [
[0,"Basic Axe","http://theccworld.co...e.gif",30000,"A basic battle axe."],
[1,"Bunch of Balloons","http://theccworld.co...ch.gif",1000,"A bunch of brightly colored balloons."],
[2,"Blob","http://theccworld.co....gif",4500,"Buy your very own pet blob!"],
[3,"Bunny","http://theccworld.co...y.gif",100,"Buy your own pet bunny! Nice and fluffy..."],
[4,"Chain Mace","http://theccworld.co...gif",5450,"High quality iron chain mace."],
[5,"Cross","http://theccworld.co...oss.gif",750,"A solid stone cross."],
[6,"Cutlass","http://theccworld.co...ss.gif",9540,"A well constructed cutlass."],
[7,"Dagger","http://theccworld.co...ger.gif",650,"A short, easily concealible dagger."],
[8,"Dark Blue Balloon","http://theccworld.co...oon.gif",800,"A dark blue balloon."],
[9,"Double Axe","http://theccworld.co...e.gif",40000,"A double sided battle axe."],
[10,"Fire Axe","http://theccworld.co....gif",95000,"An axe enchanted with fire."],
[11,"Fire Sword","http://theccworld.co....gif",100000,"A sword enchated with fire."],
[12,"Green Balloon","http://theccworld.co...oon.gif",800,"A green balloon."],
[13,"Hammer","http://theccworld.co...er.gif",4000,"A strudy metal hammer."],
[14,"Hand Axe","http://theccworld.co...xe.gif",3560,"A small, but nice hand axe."],
[15,"Harp","http://theccworld.co...gif",3500,"Make music (or at least noises) with this nice golden harp."],
[16,"Light Blue Balloon","http://theccworld.co...oon.gif",800,"A light blue balloon."],
[17,"Bow","http://theccworld.co...ow.gif",2500,"A low quality make-shift bow."],
[18,"Mallet","http://theccworld.co...et.gif",1565,"A cheap, wooden mallet."],
[19,"Minning Equipment","http://theccworld.co...eqp.gif",500,"A collection of minning equipment."],
[20,"Purple Balloon","http://theccworld.co...oon.gif",800,"A purple balloon."],
[21,"Penguin","http://theccworld.co...gif",1000,"Your very own pet penguin! Straight from the south pole."],
[22,"Red Balloon","http://theccworld.co...oon.gif",800,"A red balloon."],
[23,"Royal Bow","http://theccworld.co...w.gif",50000,"A very high quality bow with all the accessories you could want."],
[24,"Shovel","http://theccworld.co...el.gif",6000,"A simple shovel."],
[25,"Spiked Club","http://theccworld.co...ub.gif",7000,"A basic club covered in spikes."],
[26,"Sword","http://theccworld.co....gif",4000,"The basic sword."],
[27,"Water Sword","http://theccworld.co...d.gif",40000,"A sword encahted with water."],
[28,"Wooden Club","http://theccworld.co...ub.gif",2000,"A thick club of wood."],
[29,"Yellow Balloon","http://theccworld.co...oon.gif",800,"A yellow balloon."]
];
var cMaxItems = 29;
/*ITMLSTENDHRE*/
/*SHPITMSTRHRE*/
var shopItems = {
title: {
available: 1,
amount: 15000
},
sig: {
available: 1,
amount: 20000
},
avatar: {
available: 1,
amount: 10000
},
usernameBold: {
available: 1,
amount: 500
},
usernameItalic: {
available: 0,
amount: 100
},
usernameColor: {
available: 1,
amount: 10000
},
usernameUline: {
available: 1,
amount: 10000
},
rank: {
available: 0,
amount: 0,
max: 0,
urls: [
["Blue Star", "http://www.proboards.../starblue.gif"],
["Red Star", "http://www.proboards...s/starred.gif"],
["Green Star", "http://www.proboards...stargreen.gif"],
["Yellow Star", "http://www.proboards...ages/star.gif"]
]
}
};
/*SHPITMENDHRE*/
//-->
</script>
<script type="text/javascript" src="http://theccworld.co...n.js"></script>



***let me know if you know how to do this thanks! :)***


#2 SirChick

SirChick
  • Members
  • PipPipPip
  • Advanced Member
  • 755 posts

Posted 08 February 2006 - 07:10 PM

So is this possible ?

#3 icoGreg

icoGreg
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 08 February 2006 - 07:29 PM

The script will reload and reinitialize the variables everytime some comes to you website. If you store the quantity remaining in a Database or read/write to file, you will be able to save the 'quantity remaining' variable and reload it from there. I wouldn't think you could hard code it into the JScript because it will then reinitialize to whatever that number is every time someone loads it. You have to read the quanitity from some source external from your JS file.

#4 SirChick

SirChick
  • Members
  • PipPipPip
  • Advanced Member
  • 755 posts

Posted 11 February 2006 - 02:41 PM

[!--quoteo(post=343876:date=Feb 8 2006, 02:29 PM:name=icoGreg)--][div class=\'quotetop\']QUOTE(icoGreg @ Feb 8 2006, 02:29 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
The script will reload and reinitialize the variables everytime some comes to you website. If you store the quantity remaining in a Database or read/write to file, you will be able to save the 'quantity remaining' variable and reload it from there. I wouldn't think you could hard code it into the JScript because it will then reinitialize to whatever that number is every time someone loads it. You have to read the quanitity from some source external from your JS file.
[/quote]


Yeh i though that may be the case and thats ok but i just dont know how to do that ! lol Im not an expert with code and that code i had help with you see? How would i create a code so that each item has a quantity, that reduces each time people by them etc?


#5 SirChick

SirChick
  • Members
  • PipPipPip
  • Advanced Member
  • 755 posts

Posted 13 February 2006 - 05:39 PM

Can anyone help me with this then or no? :(




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users