ID:179794
 
Ok in my game i have clans and in one of the clans bases there is a guy who you can donate Gold to for the clan to use for whatever. the only problem is that once the server goes down, the amount of gold that is donated goes back to zero. This is my code for him.
mob/TPCdude
icon = 'bank_keeper.dmi'
var/TPCgold = 0
verb/Talk()
set src in view(2)
var/A = input("Hey [usr.name]! What can I do for you? TPC currently has [TPCgold] gold in its vault","TPC fund")in list("Deposit Gold","Cancel")//choose to Deposit or or cancle
if(A == "Deposit Gold")//if you choose Deposit Gold
var/D = input("How much gold you want to deposit?","Deposit Gold") as num//type in the amount as a number
D = round(D)//round the number off to prevent decimals
if(D > usr.wealth || isnull(D))//if the amount is more than you have or is nothing
usr << "You dont have that much to deposit."
else if(D <= 0)//if the amount typed in is less than or equal to zero (this prevents people from using negative numbers to gain gold)
usr << "Can't deposit less than 1."
return
else
TPCgold += D //puts the amount in your account
usr.wealth -= D // minuses the amount from the gold on you
if(A == "Cancel")
usr << "Thank you. Come again!"
return

Ok what do i need to do to that?
Store it in some kind of save file, like you would do with a mob. Mayby make an entire seperate savefile just for npc mobs to save(If you save the mob, you save all the vars and their values)

Alathon
In response to Alathon
Alathon wrote:
Store it in some kind of save file, like you would do with a mob. Mayby make an entire seperate savefile just for npc mobs to save(If you save the mob, you save all the vars and their values)

Alathon

how do i do that?
In response to Alathon
Ok can someone help me with makeing a .sav file, im clueless.... i dont understand how to make it save one, or to draw info from one. i looked that deadron's character handling lib. and i dont understand exactly how it works, and all i could figure out from the reference was that there is the file and 2 sub diretorys or somthing.
In response to dbz73
Here is a simple system.


mob/verb/Save()
var/savefile/F = new("[usr.ckey].sav")
Write(F)//This saves all the vars besides tmp global.
mob/verb/Load()
var/savefile/F = new("[usr.ckey].sav")
Read(F)//This reads all the info within the file specified in the var definition


That's a extremly simple system and I suggest you look up:

<<(savefile)
(savefile)
savefile
Read() proc
Write() proc
In response to Nadrew
Nadrew wrote:
Here is a simple system.


> 
> mob/verb/Save()
> var/savefile/F = new("[usr.ckey].sav")
> Write(F)//This saves all the vars besides tmp global.
> mob/verb/Load()
> var/savefile/F = new("[usr.ckey].sav")
> Read(F)//This reads all the info within the file specified in the var definition
>
>

That's a extremly simple system and I suggest you look up:

<<(savefile)
(savefile)
savefile
Read() proc
Write() proc

thanks a lot nadrew =) ill look that up