help me the code will not work :(
verb
Sell()
set src in oview(2)
switch(input("What do you want to sell.","Paulie's Weapons Shop")in list("Ammo","Magnum","Sawedoff","Pump shotgun","Tommy gun","Dynamite","Nothing"))
if("Sawedoff")
if(usr.contents==/obj/Sawedoff)
del(src)
usr.money+=250
alert("Thanks for selling the sawedoff. Come back again.")
if("Nothing")
alert("Fine have it your way...")
if("Pump shotgun")
if(usr.contents==/obj/Pumpshotgun)
del(src)
usr.money+=750
alert("Thanks for selling the pump shotgun. Come back again.")
if("Magnum")
del(src)
usr.money+=50
alert("Thanks for selling the magnum. Come back again.")
if("Tommy gun")
if(usr.contents==/obj/Tommygun)
del(src)
usr.money+=5000
alert("Thanks for selling the tommy gun. Come back again.")
if("Dynamite")
if(usr.contents==/obj/Dynamite)
del(src)
usr.money+=5250
alert("Thanks for selling the dynamite. Have fun blowing something or someone up.")
if("Ammo")
if(usr.ammo==200)
usr.money+=100
usr.ammo-=200
alert("Thanks for selling some ammo. Come back again.")
ID:148252
![]() May 9 2003, 5:32 pm (Edited on May 9 2003, 5:38 pm)
|
|
![]() May 9 2003, 5:48 pm
|
|
Well, the problem is this...you're defining a list which may or may not pretain to the usr's contents, and also you're trying to use and if() proc to locate something in a list. Instead, use something similar to this:
|
Also, although this has nothing to do with the code, it's a sawn-off shotgun, not a sawedoff shotgun.
|
Goku72 wrote:
Well, the problem is this...you're defining a list which may or may not pretain to the usr's contents, and also you're trying to use and if() proc to locate something in a list. Instead, use something similar to this: > mob will this make it so i can sell the weapons and ammo at 1/2 price??? List of weapons and prices i whan sell them at: Ammo: $1 per unit Magnum:$50 Sawnoff shotgun:$250 Pump shotgun:$750 Tommy gun:$5000 Dynamite:$5250 |
here is my code so far
turf shopkeeper paulie verb Sell() set src in oview(2) var/list/A=new() var/B for(var/obj/O in usr.contents) A+=O A+="Cancel" B=input("[src] - What do you wish to sell?","[src]","Cancel") in A if(B=="Cancel") return 0 else switch(alert("[src] - Are you sure you wish to sell [B] for [B.value]?","[src]","Yes","No")) if("Yes") usr.money+=round(TargetItem.Value/2) del(B) usr<<"[src] - Transaction completed!" else usr<<"[src] - Thank you, come again!" return 0 when i compile i get 2 errors they are B.value:undefined var TargetItem.Value:undefined var i try to define them and it dont work. can someone help me. |
usr.money+=round(TargetItem.Value/2)
That's your problem, Volte merely put that in there for an example. Please, when we try to help you don't just copy+paste directly from the forums. It's a bad habit and could cause problems. But, for your current problem: TargetItem=B Value=B.value that simple :-p So, in final form, usr.money+=round(B.value/2) |
Goku72 wrote:
usr.money+=round(TargetItem.Value/2) Actually, the only problem on that line is that it should be B, not TargetItem. But yes, copying and pasting stuff directly is a bad idea. But, for your current problem: You probably didn't intend that as code, I know, but Coolz might've thought you did. Anyway, it's not the problem. =) The second problem is that B wasn't defined as an obj. Instead of <code>var/B</code>, it should be <code>var/obj/B</code>; as it is, the compiler doesn't know that B is an obj. It has to be explicitly told. |
Crispy wrote:
the compiler doesn't know that B is an obj. It has to be explicitly told. That catches me out so many times! |
here is my code
turf shopkeeper paulie verb Sell() set src in oview(2) var/list/A=new() var/obj/B for(var/obj/O in usr.contents) A+=O A+="Cancel" B=input("[src] - What do you wish to sell?","[src]","Cancel") in A if(B=="Cancel") return 0 else switch(alert("[src] - Are you sure you wish to sell [B] for [B.value]?","[src]","Yes","No")) if("Yes") usr.money+=round(B.value/2) del(B) usr<<"[src] - Transaction completed!" else usr<<"[src] - Thank you, come again!" return 0 var value=B.value im now getting four errors WHY??? error:B.value:undefined var error:= :expected a constant expression error:B.value:undefined var error:B.value:undefined var |
That's because you probably never defined value. the var value was meant as an example.
So first you need to define a var called value or sellprice or whatever under your obj <code>obj/var/value</code> Then for each seperate obj you need to define its value <code>obj/bullet value = 1</code> I think that should about cover it. Resonating Light |
here is my code now why will it still not work
turf shopkeeper paulie verb Sell() set src in oview(2) var/list/A=new() var/obj/B for(var/obj/O in usr.contents) A+=O A+="Cancel" B=input("[src] - What do you wish to sell?","[src]","Cancel") in A if(B=="Cancel") return 0 else switch(alert("[src] - Are you sure you wish to sell [B] for [sellprice]?","[src]","Yes","No")) if("Yes") usr.money+=round(sellprice/2) del(B) usr<<"[src] - Transaction completed!" else usr<<"[src] - Thank you, come again!" return 0 obj/var/sellprice obj/Magnum sellprice=100 obj/Sawnoffshotgun sellprice=500 obj/Pumpshotgun sellprice=1500 obj/Tommygun sellprice=10000 obj/Dynamite sellprice=10500 obj/Ammo sellprice=1 im geting two errors error:sellprice:undefined var error:sellprice:undefined var |
Instead of sellprice you could try doing B.sellprice. sellprice, because it has nothing in front of it is assumed to be src.sellprice. Seeing as how the shopkeeper doesnt have a sellprice var that error pops up. B.sellprice SHOULD be the sellprice of whatever item you decide to buy.
|
mob
Shopkeeper icon = 'mobs.dmi' icon_state = "shop keep" npc = 1 verb Sell() set src in oview(3) set category = "Commands" switch(input("Hello! What do you wish to buy?", "Shopkeeper",text) in list ("Weapon1","Weapon2")) if("weapon1") if(usr.gold <= 9) usr << "You need 10 Gold!" if(usr.gold >= 10) usr << "You get a weapon1!" usr.contents += new /obj/weapon1 usr.gold -= 20 usr.sight = 0 if("weapon2") if(usr.gold <= 9) usr << "You need 10 Gold!" if(usr.gold >= 10) usr << "You get a weapon2!" usr.contents += new /obj/weapon2 usr.gold -= 20 usr.sight = 0 |
here is my code i have NO ERRORS now YES!!! but i have one prob when i run it the sell verb does not pop up in the list of things u can do with the shopkeeper.
turf shopkeeper paulie verb Sell() set src in oview(2) var/list/A=new() var/obj/B for(var/obj/O in usr.contents) A+=O A+="Cancel" B=input("[src] - What do you wish to sell?","[src]","Cancel") in A if(B=="Cancel") return 0 else switch(alert("[src] - Are you sure you wish to sell [B] for [B.sellprice]?","[src]","Yes","No")) if("Yes") usr.money+=round(B.sellprice/2) del(B) usr<<"[src] - Transaction completed!" else usr<<"[src] - Thank you, come again!" return 0 obj/var/sellprice obj/Magnum sellprice=100 obj/Sawnoffshotgun sellprice=500 obj/Pumpshotgun sellprice=1500 obj/Tommygun sellprice=10000 obj/Dynamite sellprice=10500 obj/Ammo sellprice=1 |
i got my sell verb fixed but i have one prob in it. when u click sell it only pick up on the weapon u have in your 1st slot in your inventory even if u have two weapons. how can i fix it so it pick up on the whole inventory and how can i fix it so if u have nothing in your inventory the sell verb is not there???
|
Look up lists in the help files and try defining the list a different way since there are a couple different ways of assigning lists. That may help.
I would have just told you myself but I'm afraid of it being wrong.... I suck at lists =[ Resonating Light |
i still need help with my sell verb(look at my last post:the one before RL's) and now i need help on how to give a pc stuff from a npc. i have this
usr.money+=50 usr<<"Ralph gives you 50 dollars." and it works but how do i fix it so ralph will only give it to the pc when the usr's money is 0??? |
Basically if you want Ralph to only give money if its 0 just use
if(usr.money ==0) usr<<"Ralp Gives you 50 dollars" usr.money + 50 else usr<<"Im sorry but you have money you dont need anymore" or just leave thta out so if(usr.money ==0) usr<<"Ralp Gives you 50 dollars" usr.money + 50 {Cloud54367} |
Please try not to post code that has already been sorted-out. Also, try to close your HTML tags and put code in DM tags.
That code would also only pertain to buying code, and is extremely long winded. Having to code every single object into a shop is a very bad idea, as it uses a huge amount of code. |