Raised This Month: $51 Target: $400
 12% 

[CS:1.6/CS:CZ] Counter Strike Bank v1.3


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   Counter-Strike        Category:   Fun Stuff       
ezio_auditore
Senior Member
Join Date: May 2013
Old 06-14-2014 , 12:20   [CS:1.6/CS:CZ] Counter Strike Bank v1.3
Reply With Quote #1

Counter-Strike Bank v1.3
-ezio_auditore

Description :--
This plugin introduces a Bank in Counter-Strike.
This Bank provides facilities like a Savings Account(A/C as it will be used later) and a Loan A/C.
Using this plugin, a player can deposit n% (Adjusted in CVars | Default 25%) of the money he has in
his savings A/C and can withdraw it later.
Think of a situation where you need some money but don't have any. Using this plugin, a player can
take a Loan of $n (Also Adjustible | Default $7500). Once a player takes a loan, interest begins
to apply. The default interest rate is 2% per 5 minutes which can be adjusted in CVars.
When the interest applies, the user who took the loan gets a warning message to pay the loan.
If he ignores these messages for n times(Adjustible | Default 3), he gets punished in various ways.
How he will be punished can also be adjusted in CVars.

CVars :--
Spoiler

cs_bank_punish_mode
Spoiler


Client-Side Commands :--
say /bank - Opens Bank's Main Menu
say /loan - Opens Bank's Loan A/C Menu
say /savings - Opens Your Savings A/C

Credits :--
Jhob94 - Idea For Plugin Security
Flick3rR - Idea For Possible Code Optimization + Suggestion for using new menus
Changelog
Spoiler


Thanks to ConnorMcLeod and Arkshine for uanpproving my Old Plugin and giving some nice idea
Attached Files
File Type: sma Get Plugin or Get Source (bank.sma - 1439 views - 14.4 KB)
__________________

Last edited by ezio_auditore; 10-31-2014 at 02:54. Reason: Update
ezio_auditore is offline
Send a message via Skype™ to ezio_auditore
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-14-2014 , 12:33   Re: Counter Strike Bank
Reply With Quote #2

PHP Code:
stock SaveData(id)  
{  
    new 
AuthID[35
    
get_user_authid(idAuthIDcharsmax(AuthID))
    
    new 
vaultkey[64], vaultdata[256]     
    
format(vaultkeycharsmax(vaultkey), "%s-Bank"AuthID)  
    
format(vaultdatacharsmax(vaultdata), "%i#%i#"g_Debt[id], g_Savings[id])  
     
    
nvault_set(vault ,vaultkeyvaultdata)  
     
    return 
PLUGIN_CONTINUE  

 
stock LoadData(id)  
{  
    new 
AuthID[35
    
get_user_authid(idAuthIDcharsmax(AuthID))
    
    new 
vaultkey[64],vaultdata[256]       
    
format(vaultkeycharsmax(vaultkey), "%s-Bank"AuthID)  
    
format(vaultdatacharsmax(vaultdata), "%i#%i#"g_Debt[id], g_Savings[id])  
     
    
nvault_get(vaultvaultkeyvaultdatacharsmax(vaultdata))  
     
    
replace_all(vaultdatacharsmax(vaultdata), "#"" ")
     
    new 
debt[33], savings[33]  
     
    
parse(vaultdatadebtcharsmax(debt), savingscharsmax(savings))  
    
    
g_Debt[id] = str_to_num(debt)  
     
    
g_Savings[id] = str_to_num(savings)  
     
    return 
PLUGIN_CONTINUE

You don't need to use #, you can simply leave a free space.
PHP Code:
    format(vaultdatacharsmax(vaultdata), "%i#%i#"g_Debt[id], g_Savings[id]) 
->
PHP Code:
    format(vaultdatacharsmax(vaultdata), "%i %i "g_Debt[id], g_Savings[id]) 
And you don't need replace_all anymore.

You can use new menu style, it has more power. This is a very good ideea, keep working on it and add new stuffs.
#Good job.

Last edited by HamletEagle; 06-14-2014 at 12:38.
HamletEagle is offline
Old 06-14-2014, 12:38
ArabicMan
This message has been deleted by ArabicMan. Reason: I realise that i'am wrong
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 06-14-2014 , 12:48   Re: Counter Strike Bank
Reply With Quote #3

Good idea, like it!
But I want to ask you something. Why do you define three different thing, when they are all the same?
PHP Code:
//Menu Key Definitions
#define KeysBankMenu (1<<0)|(1<<1)|(1<<9)    //Bank Main Menu
#define KeysSavings (1<<0)|(1<<1)|(1<<9)    //Savings A/C
#define KeysLoan (1<<0)|(1<<1)|(1<<9)        //Loan Scheme 
You can define something like 'keys' and use it everywhere.
--------------------------------------------------------------------------------------------
Also you may register not only "say" commands, but say_team, and maybe with a slash ( / ) in each type say.
--------------------------------------------------------------------------------------------
And why you formatex szWarnings twice, when you can put the first format directly in the second vie the same method. In other words:
PHP Code:
formatex(szWarningscharsmax(szWarnings), "%i"g_WrnTime[id] <= iMaxWarns g_WrnTime[id] : iMaxWarns)
formatex(szWarningscharsmax(szWarnings), "%s of %i"szWarningsiMaxWarns
--->
PHP Code:
formatex(szWarningscharsmax(szWarnings), "%i of %i"g_WrnTime[id] <= iMaxWarns g_WrnTime[id] : iMaxWarnsiMaxWarns
--------------------------------------------------------------------------------------------
And this
PHP Code:
client_cmd(id"disconnect"
is holly slowhacking, AFAIK. Better use
PHP Code:
//before the switch
new name[32]
get_user_name(idnamecharsmax(name))
//In case 4
case 4:{
    
server_cmd("kick %s"name)

In this case, when the user is kicked, you try to display him a HUD message anyways. This will cause errors. So, put a check if the user is connected and then show the message. Example:
PHP Code:
set_hudmessage(200000.0, -1.006.012.0)
if(
is_user_connected(id))
    
show_hudmessage(id"You Have Been Punished For Not Paying Your Loan^nWe Owe You $%i"g_Debt[id]) 
--------------------------------------------------------------------------------------------
And I think is better to use the new style menu. Not sure, but AFAIK is more efficient and working more properly. Anyways, leave this if you want. But why you put empty "case 9"s? Put some return value, if you want to stop the function, but it's pointless to leave it empty.
--------------------------------------------------------------------------------------------
I think these are the improvements I can tell. Look, I can't get that old menu style, so someone else should take a look. Keep working on this, it's a great idea!!!
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 06-14-2014 , 14:38   Re: Counter Strike Bank
Reply With Quote #4

You should add this for security:
PHP Code:
// Save Data When Pausing The Plugin
public plugin_pause()
{
    new 
iPlayers[32], iNum
    get_players
(iPlayersiNum)
    
    for(new 
ii<iNumi++)
        
SaveData(iPlayers[i])
}

// Load Data After Unpause The Plugin
public plugin_unpause()
{
    new 
iPlayers[32], iNum
    get_players
(iPlayersiNum)
    
    for(new 
ii<iNumi++)
        
LoadData(iPlayers[i])

__________________

Last edited by Jhob94; 06-14-2014 at 14:38.
Jhob94 is offline
BLacking98
Veteran Member
Join Date: Oct 2012
Location: California
Old 06-14-2014 , 15:02   Re: Counter Strike Bank
Reply With Quote #5

Quote:
Originally Posted by ArabicMan View Post
Already exist.
You should really learn how to read.
__________________
BLacking98 is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 06-14-2014 , 15:06   Re: Counter Strike Bank
Reply With Quote #6

Quote:
Originally Posted by BLacking98 View Post
You should really learn how to read.
We cant really blame on him. The name of the thread should be something like bank loans.
__________________
Jhob94 is offline
ArabicMan
Veteran Member
Join Date: Feb 2014
Location: مصر
Old 06-14-2014 , 22:49   Re: Counter Strike Bank
Reply With Quote #7

Quote:
Originally Posted by BLacking98 View Post
You should really learn how to read.
Sorry if i'am wrong i'll learn reading man.
ArabicMan is offline
ezio_auditore
Senior Member
Join Date: May 2013
Old 06-15-2014 , 00:46   Re: Counter Strike Bank
Reply With Quote #8

Updated!
__________________

Last edited by ezio_auditore; 06-15-2014 at 12:01.
ezio_auditore is offline
Send a message via Skype™ to ezio_auditore
ezio_auditore
Senior Member
Join Date: May 2013
Old 10-29-2014 , 13:21   Re: [CS:1.6/CS:CZ/CS:O] Counter Strike Bank v1.1
Reply With Quote #9

Updated.. Added new performance

lol... I reveived an old post
__________________
ezio_auditore is offline
Send a message via Skype™ to ezio_auditore
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 10-29-2014 , 13:47   Re: [CS:1.6/CS:CZ/CS:O] Counter Strike Bank v1.2
Reply With Quote #10

Some improvements:
  • When you open your nvault file you should check for INVALID_HANDLE.
  • Instead of writting the array size directly, use charsmax.
  • You should kick by userid/steamid.
  • set_hudmessage(200, 0, 0, 0.0, -1.0, 0, 6.0, 12.0) should be inside of is_user_connected check.
  • From what I can see you keep looping the SavingsIncrement task, but you could do a global task with flag b and loop all players inside it. Same for all your task that should keep looping.
  • You should really look into new menu style.
  • set_task(0.1, "ShowSavings", id) you don't need it. Jist do ShowSaving(id)
  • In you SaveData return is pointless. Same for LoadData.
  • I know that the xp mod tutorial use format, but it's old. Please use formatex as you do in the rest of the code. Keep the same procedures, and adapt the code to the present.
__________________
HamletEagle is offline
Reply



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 07:31.


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