AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   New Plugin Submissions (https://forums.alliedmods.net/forumdisplay.php?f=26)
-   -   Save Money (nvault) (https://forums.alliedmods.net/showthread.php?t=343768)

Mo3taz 08-28-2023 12:00

Save Money (nvault)
 
1 Attachment(s)
Save Money
Description:
  • Simple plugin which will save your money after: [ disconnecting from the server | changing map ]. and load it again when you are in the server
  • No bugs, created with nvault
  • Even if: [ the server restarted | warmup ] your money will load without any problem
  • added cvar to turn the plugin on - off
Note:
  • Change: [ cs_get_user_money | cs_set_user_money ] if your mod have another money natives.
plugin tested in server and it worked successfully

Updated (2023/9/29) vault ==> nvault

report any bugs please

bigdaddy424 08-28-2023 22:38

Re: Save Money (vault)
 
im impressed

Jhob94 08-29-2023 10:49

Re: Save Money (vault)
 
I love simple stuff but this is too simple.
Learn how to properly use nvault
Learn how to use charsmax instead of hardcoded values.
Make a define for the money natives, this way it’s easier for user to edit and change it.

Btw, does not this plugin already exists?

Mo3taz 08-29-2023 12:25

Re: Save Money (vault)
 
@Jhob94
i think i am gonna to update it this days and make it better
no its not exists
i tried crx_savemoney plugin and there is problem with that plugin when you restart the server, you will get the amount of money which set in "mp_startmoney"
i changed the cvar of "sm_maponly" many times and the same result
so i decided to make save money with vault

mlibre 09-08-2023 19:32

Re: Save Money (vault)
 
@Jhob94 help him optimize his contribution

Bugsy 09-09-2023 22:47

Re: Save Money (vault)
 
Has this been tested? I'd think setting money @ client_connect() would be too early, but could be wrong. Authid is not guaranteed to be available at client_connect() either so this would not be stable. I am also surprised that this does not already exist, did you search yet, OP?

Just a few suggestions, some of which jhob94 already pointed out:
  • Use charsmax( array-variable ) instead of the array size minus 1 value
  • Use formatex() instead of format
  • For converting an integer to string (in SaveData), use num_to_str()
  • Not a big deal, but ideally you should store authid in a 2-dimension global array so that you only call get_user_authid() once for each player per connection
  • I'd suggest calling LoadData at client_authorized() and giving money at client_putinserver(). There's no guarantee that the authid is available at client_connect(). It may work in your personal testing but will not be stable for server use.
  • Use nvault instead of vault and avoid having to prefix your key value with "SVM"

Jhob94 09-10-2023 08:13

Re: Save Money (vault)
 
Quote:

Originally Posted by mlibre (Post 2809879)
@Jhob94 help him optimize his contribution

This is not scripting help, we can give some tips but this is not the place for him to improve the code.
I'll leave one script because this may be harder for him to find.

Code:

#include <amxmodx>
#include <cstrike>

#define Get_User_Money(%1)        cs_get_user_money(%1)
#define Set_User_Money(%1,%2)        cs_set_user_money(%1,%2)

public client_connect(id)
{
        Set_User_Money(id, Get_User_Money(id) + 500) // This is just an example
}


mlibre 09-10-2023 13:39

Re: Save Money (vault)
 
@Mo3taz you already know what to do for your next beta, using macros helps a lot

lexzor 09-11-2023 00:46

Re: Save Money (vault)
 
Quote:

Originally Posted by mlibre (Post 2809944)
@Mo3taz you already know what to do for your next beta, using macros helps a lot

define how much from word "a lot" can macros help

mlibre 09-12-2023 12:22

Re: Save Money (vault)
 
@lexzor in terms of memory and processing, potter has a master's degree in that

Mo3taz 09-12-2023 21:58

Re: Save Money (vault)
 
thanks guys for your help, i will upgrade it

Mo3taz 09-29-2023 15:57

Re: Save Money (nvault)
 
@Jhob94 @mlibre @Bugsy @lexzor
plugin updated :D


All times are GMT -4. The time now is 10:12.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.