Use command once a day
Hi all, well I want to add a command /get that gives 50 ammo packs but I want to only use it once a day, I did this but it does not work, I can use it once on each map, can someone tell me what is the problem? ... thx in advance
PHP Code:
|
Re: Use command once a day
I really do not understand much of nvault, but here is a mistake, because you are comparing the global last use with steamid, and that does not make sense.
I will not know how to exemplify it, but you have to use nvault's "timestamp" feature, and only then do you compare it to the latest usage, I think. |
Re: Use command once a day
The issue is that the value that you read from nvault is the same value that you write to nvault. Therefore, you are never updating the value stored in nvault. So, you need to update g_last_used[id] before you write the value to nvault.
Also, players are only guaranteed to have a valid SteamID after client_authorized() so you need to use client_authorized() instead of client_putinserver(). |
Re: Use command once a day
Quote:
As far as I can tell, the problem is in your SaveTime function: PHP Code:
The second mistake is updating g_last_used[id] after saving it's value in the vault. This means the value you're saving is the old last use time, not the new one, so the saved value actually never gets updated. Using nVault's own timestamps probably would be more efficient for your use case though, and would save you from all this trouble. nVault automatically stores a timestamp together with each key in the vault, so all you would have to do to update a key to current timestamp (or create a new entry with the current timestamp if it doesn't already exist) is: PHP Code:
PHP Code:
|
| All times are GMT -4. The time now is 07:37. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.