Jump to content

Recommended Posts

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.

[b][u]The code for the shop is this:[/u]
[/b]


<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.com/programs/pbshop/menu/card_shop.gif";

/*ITMLSTSTRHRE*/
var addOnItems = [
[0,"Basic Axe","http://theccworld.com/programs/pbshop/items/axe.gif",30000,"A basic battle axe."],
[1,"Bunch of Balloons","http://theccworld.com/programs/pbshop/items/balloonbunch.gif",1000,"A bunch of brightly colored balloons."],
[2,"Blob","http://theccworld.com/programs/pbshop/items/blob.gif",4500,"Buy your very own pet blob!"],
[3,"Bunny","http://theccworld.com/programs/pbshop/items/bunny.gif",100,"Buy your own pet bunny! Nice and fluffy..."],
[4,"Chain Mace","http://theccworld.com/programs/pbshop/items/chainmace.gif",5450,"High quality iron chain mace."],
[5,"Cross","http://theccworld.com/programs/pbshop/items/cross.gif",750,"A solid stone cross."],
[6,"Cutlass","http://theccworld.com/programs/pbshop/items/cutlass.gif",9540,"A well constructed cutlass."],
[7,"Dagger","http://theccworld.com/programs/pbshop/items/dagger.gif",650,"A short, easily concealible dagger."],
[8,"Dark Blue Balloon","http://theccworld.com/programs/pbshop/items/dbballoon.gif",800,"A dark blue balloon."],
[9,"Double Axe","http://theccworld.com/programs/pbshop/items/doubleaxe.gif",40000,"A double sided battle axe."],
[10,"Fire Axe","http://theccworld.com/programs/pbshop/items/fireaxe.gif",95000,"An axe enchanted with fire."],
[11,"Fire Sword","http://theccworld.com/programs/pbshop/items/firesword.gif",100000,"A sword enchated with fire."],
[12,"Green Balloon","http://theccworld.com/programs/pbshop/items/gballoon.gif",800,"A green balloon."],
[13,"Hammer","http://theccworld.com/programs/pbshop/items/hammer.gif",4000,"A strudy metal hammer."],
[14,"Hand Axe","http://theccworld.com/programs/pbshop/items/handaxe.gif",3560,"A small, but nice hand axe."],
[15,"Harp","http://theccworld.com/programs/pbshop/items/harp.gif",3500,"Make music (or at least noises) with this nice golden harp."],
[16,"Light Blue Balloon","http://theccworld.com/programs/pbshop/items/lbballoon.gif",800,"A light blue balloon."],
[17,"Bow","http://theccworld.com/programs/pbshop/items/makebow.gif",2500,"A low quality make-shift bow."],
[18,"Mallet","http://theccworld.com/programs/pbshop/items/mallet.gif",1565,"A cheap, wooden mallet."],
[19,"Minning Equipment","http://theccworld.com/programs/pbshop/items/mineeqp.gif",500,"A collection of minning equipment."],
[20,"Purple Balloon","http://theccworld.com/programs/pbshop/items/pballoon.gif",800,"A purple balloon."],
[21,"Penguin","http://theccworld.com/programs/pbshop/items/penguin.gif",1000,"Your very own pet penguin! Straight from the south pole."],
[22,"Red Balloon","http://theccworld.com/programs/pbshop/items/rballoon.gif",800,"A red balloon."],
[23,"Royal Bow","http://theccworld.com/programs/pbshop/items/royalbow.gif",50000,"A very high quality bow with all the accessories you could want."],
[24,"Shovel","http://theccworld.com/programs/pbshop/items/shovel.gif",6000,"A simple shovel."],
[25,"Spiked Club","http://theccworld.com/programs/pbshop/items/spikedclub.gif",7000,"A basic club covered in spikes."],
[26,"Sword","http://theccworld.com/programs/pbshop/items/sword.gif",4000,"The basic sword."],
[27,"Water Sword","http://theccworld.com/programs/pbshop/items/watersword.gif",40000,"A sword encahted with water."],
[28,"Wooden Club","http://theccworld.com/programs/pbshop/items/woodenclub.gif",2000,"A thick club of wood."],
[29,"Yellow Balloon","http://theccworld.com/programs/pbshop/items/yballoon.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.proboards8.com/v4images/starblue.gif"],
["Red Star", "http://www.proboards8.com/v4images/starred.gif"],
["Green Star", "http://www.proboards8.com/v4images/stargreen.gif"],
["Yellow Star", "http://www.proboards8.com/v4images/star.gif"]
]
}
};
/*SHPITMENDHRE*/
//-->
</script>
<script type="text/javascript" src="http://theccworld.com/programs/pbshop/0.2/main.js"></script>



***let me know if you know how to do this thanks! :)***
Link to comment
https://forums.phpfreaks.com/topic/3301-virtual-shop-quantity/
Share on other sites

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.
Link to comment
https://forums.phpfreaks.com/topic/3301-virtual-shop-quantity/#findComment-11477
Share on other sites

[!--quoteo(post=343876:date=Feb 8 2006, 02:29 PM:name=icoGreg)--][div class=\'quotetop\']QUOTE(icoGreg @ Feb 8 2006, 02:29 PM) [snapback]343876[/snapback][/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?
Link to comment
https://forums.phpfreaks.com/topic/3301-virtual-shop-quantity/#findComment-11583
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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

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

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.