Yes, but I can't manage to do that script, I don't know how to use properly the storage.
Storage is kinda like a variable, you can hold all sorts of things in storage such as text (i like apples), numbers (1, 2, 1.0, 2.5, 3.567, 0.56799) or boolean values (1 or 0, true or false) the only thing you can't store in storage is a table we'll at least to my knowledge you can't or at least I haven't had any luck with it.
Unlike variables which usually begin with a letter or underscore, storage is defined using a number, you can define storage in a number of ways
Assigned to a variable
Assigned as an element or index of a table
Code:
local storage =
{
[18000] = 0 -- we should set this to something initially
}
or
local config =
{
storage = 18000
}
You can't officially define just a number, but you can write a comment stating this storage number is for such and such
The way you initially assign a value to the storage is using its set method or function
Code:
setPlayerStorageValue(cid, 18000, 1)
This is just a general explanation of functions & methods and will use them interchangeably
Functions / Methods perform an action, setPlayerStorageValue is a function that sets a storage value to be used elsewhere in any script, consider it a tiny database within the bigger database.
Functions can contain parameter(s) which are seen in between the parentheses they are used to pass value(s) to that function as an argument(s)
Lets look at the parameters of setPlayerStorageValue
The 1st parameter cid is the id of the player which is always a number, you don't need to define this as it is always passed to the function, the 2nd parameter is the storage, and the 3rd is the value you want to assign to the storage.
There are a number of ways you can set the storage value lets take a look, using the examples above
Please note these are not the only ways to assign storage
Code:
setPlayerStorageValue(cid, 18000, 1) -- just using the number
setPlayerStorageValue(cid, storage, 1) -- just using the variable as a reference
setPlayerStorageValue(cid, storage[18000], 1) -- using a table element or index as a reference, this would replace the value of 0 with 1
setPlayerStorageValue(cid, config.storage, 1) -- using a table element or index as a reference, this would replace the value of 0 with 1
When we set any storage value the storage is saved in the database
Now that we have our storage set, we can retrieve this value by calling it's get method or function
The get method returns or retrieves the value stored inside of our storage value 18000
Code:
-- all of these would return 1
getPlayerStorageValue(cid, 18000)
getPlayerStorageValue(cid, storage)
getPlayerStorageValue(cid, storage[18000])
getPlayerStorageValue(cid, config.storage)
Which can then be used elsewhere in the program
Hope this has been a little helpful