Save an ammount & load it
#1

Hi, How I can save a ammount, that I can check later? I need it for a job I'm trying to script.
Usage:

As kinapper:
/kidnap ID $(The ammount I want to save in a variable or float, I don't know.)

The player who got kidnaped:

/paykidnap $(The ammount I'm trying to load, so I can pay to the kidnaper.)

I'm not asking you to script it for me, just give me a example or tell me how i do that.

I'm a newbie, and I want to learn.


thanks you
Reply
#2

I'm glad to see someone who actually wants to learn and just doesn't expect hand-outs!

1. You don't need to save the money as a float unless you have a custom money system as they will always be integers (floats are variables btw - not sure if you knew that from your post)

2. How to do it depends on whether you want it to last between connections/server restarts or just temporarily. If temporarily, save the value inside a player array. Otherwise, write the value to a certain file with some type of person identification (like the player's name) while using /kidnap, and reading that number while using /paykidnap.

For writing/reading files, look on the wiki for the functions inside of file.inc .
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)