Raised This Month: $ Target: $400
 0% 

Save Money (nvault)


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   Counter-Strike        Category:   General Purpose       
Mo3taz
Member
Join Date: Apr 2022
Location: Algeria
Old 08-28-2023 , 13:00   Save Money (nvault)
Reply With Quote #1

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
Attached Files
File Type: sma Get Plugin or Get Source (bg_savemoney.sma - 77 views - 2.5 KB)
__________________
Save Money (nvault)
DISCORD: Mo3taz#8978
Mz

Last edited by Mo3taz; 12-09-2023 at 10:22. Reason: report any bug please
Mo3taz is offline
Send a message via Yahoo to Mo3taz
bigdaddy424
Senior Member
Join Date: Oct 2021
Location: Jupiter
Old 08-28-2023 , 23:38   Re: Save Money (vault)
Reply With Quote #2

im impressed
__________________
bigdaddy424 is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Location: Siiiiiiiiuu
Old 08-29-2023 , 11:49   Re: Save Money (vault)
Reply With Quote #3

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?
__________________
Jhob94 is offline
Mo3taz
Member
Join Date: Apr 2022
Location: Algeria
Old 08-29-2023 , 13:25   Re: Save Money (vault)
Reply With Quote #4

@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
__________________
Save Money (nvault)
DISCORD: Mo3taz#8978
Mz
Mo3taz is offline
Send a message via Yahoo to Mo3taz
mlibre
Veteran Member
Join Date: Nov 2015
Location: return PLUGIN_CONTINUE
Old 09-08-2023 , 20:32   Re: Save Money (vault)
Reply With Quote #5

@Jhob94 help him optimize his contribution
__________________
mlibre is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 09-09-2023 , 23:47   Re: Save Money (vault)
Reply With Quote #6

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"
__________________

Last edited by Bugsy; 09-09-2023 at 23:47.
Bugsy is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Location: Siiiiiiiiuu
Old 09-10-2023 , 09:13   Re: Save Money (vault)
Reply With Quote #7

Quote:
Originally Posted by mlibre View Post
@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
}
__________________
Jhob94 is offline
mlibre
Veteran Member
Join Date: Nov 2015
Location: return PLUGIN_CONTINUE
Old 09-10-2023 , 14:39   Re: Save Money (vault)
Reply With Quote #8

@Mo3taz you already know what to do for your next beta, using macros helps a lot
__________________
mlibre is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 09-11-2023 , 01:46   Re: Save Money (vault)
Reply With Quote #9

Quote:
Originally Posted by mlibre View Post
@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
lexzor is offline
mlibre
Veteran Member
Join Date: Nov 2015
Location: return PLUGIN_CONTINUE
Old 09-12-2023 , 13:22   Re: Save Money (vault)
Reply With Quote #10

@lexzor in terms of memory and processing, potter has a master's degree in that
__________________
mlibre is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 22:59.


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