Save an ammount & load it - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Save an ammount & load it (
/showthread.php?tid=419454)
Save an ammount & load it -
mailu - 28.02.2013
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
Re: Save an ammount & load it -
Bakr - 01.03.2013
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 .