ID:270297
 
Ok i've been messing with a browser shop for about a day or 2 now but i cant seem to make it to were i can have Class requirements and such how would i go about doing this to were only a certain class see the weapons that they can buy in the table that shows the weapons.
Maybe make a list variable and leave it empty to start. Then make another list for each class with the items they can buy. Then when a player uses the shop, check for their class, and add to the empty list the items in the list that coresponds with the players class. Then, when they choose to buy, show them the items in the list with the newly added items and go from there.
In response to Pyro_dragons
hmm never thought of doing it that way.
In response to National Guardsmen
Glad to help.

It's really simple when you do it and should prove effective. Here's a quick snippet on how it would look.

mob/Shopkeeper
icon = 'blah.dmi'
icon_state = "blah"
verb/Shop()
switch(alert("Welcome. What do you want to do?","Shop","Buy items","Sell")) //i like to use alert here, but input is fine too
if("Buy items")
Buy_Items() //call the Buy_Items porc

proc/Buy_Items(mob/M)
var/list/buyable = list() //empty list
var/list/Swordsman = list(new /obj/Sword) //swordsman list
var/list/Mage = list(new /obj/Staff) //mage list
if(M.class = "Swordsman") //if thats the class
buyable += Swordsman //add that list
var/obj/O = input("What would you like to buy?","Buy items")in buyable //any item in buyable is shown
//continue from there


Just a quick snippet. Probably made a mistake somewhere, but its just a really basic example. Correct if you please.
You really don't have to do this, as you can go around it with the way the shop is designed. Keep several variables for pages that contain lists of items classes can buy, then display the appropriate page after checking the class of the player who is shopping and in each page provide links to each other class's page. Realistically you would allow a player to buy anything regardless if it goes with their class or not, though you would warn the player before buying that they can't use/wear/equip that item with their current class.
In response to Artemio
Yeah you could do that too. There's many ways to do it.