ID:178798
 
Yes I was wondering If someone could tell me how to stop negative numbers in money and other vars? ANyone who can help plz be my guess
mob/verb/Give_Gold(mob/M in world)
if(!M)
src << "Give Gold to who??"
return
var/give = input("Give how much?","Give") as num
if(give <= 0)
src << "Enter a amount that is vailed!"//Make sure no negitive gold.
return
if(give <= src.Gold)
src.Gold -= give
M.Gold += give
M << "[src] gave you [give] Gold!"
src << "You gave [M] [give] Gold!"
else
usr<<"You don't have that much Gold!"
if(M.Gold<= 0)
usr <<"[M] is broke."
return

Is that what your looking for?

-Kappa the Imp







In response to Kappa the Imp
ok i am not sure heres an ex of my code


turf
Class_3_Station
icon = 'Turfs.dmi'
icon_state = "spacestation"
density = 1
Click()
var/i = input("Would you like to Buy or Sell any goods here?","Omega Station") in list ("Buy Dilithium 24creds 1unit","Buy Tools 5creds 1unit","Sell Dilithium 12creds 1unit","Buy Fuel 5creds 5units","Nevermind") // ask the player what the variable 'r' is (ask what race they want to be)
switch(i)
if("Buy Dilithium 12creds 1unit") // the program already knows what it's comparing (r). this was established with the line 'switch(r)'. now the program is checking to see what 'r' equals. just use if("example") to do so, because we've already checked to see what we're looking at
usr.wealth-=24
usr.dilithium+=1


if("Buy Tools 6creds 1unit") // the program already knows what it's comparing (r). this was established with the line 'switch(r)'. now the program is checking to see what 'r' equals. just use if("example") to do so, because we've already checked to see what we're looking at
usr.wealth-=6
usr.Tools+=1


if("Sell Dilithium 12creds 1unit")
usr.wealth+=6
usr.dilithium-=1

if("Buy Fuel 5creds 5units")
usr.wealth-=6
usr.fuel+=5


if("Nevermind")