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

[INC] Bank


Post New Thread Reply   
 
Thread Tools Display Modes
ShawnCZek
Member
Join Date: Mar 2017
Location: Czech Republic
Old 03-20-2018 , 10:48   Re: [INC] Bank
Reply With Quote #21

So I fixed some stuff and I also added function Bank_SetBalanceSteam what is useful if you want to optimize your plugin. And I did it.
The new function is described below (adding include soubor only as code).
PHP Code:
/*
    Include file for Bank.sp
    Provide simple functions to manage a player's bank.
    
    Created by Arkarr (Alliedmodders)
*/

#if defined _bank_included
 #endinput
#endif
#define _bank_included

/**
 * Create a new bank. Can't create bank with same name at once.
 *
 * @param bankName  The name of the bank
 * @return            True on sucess, false otherwise.
 */
native bool Bank_Create(const char[] bankName)

/**
 * Add or substract a certain ammount of credits of a player's balance.
 *
 * @param bank             The name of the bank
 * @param client        The client to add/substract to.
 * @param ammount       The ammount to add/substract.
 * @param forcecreate   Create the user if not found in the bank.
 * @return            True on sucess, false otherwise.
 */
native bool Bank_EditBalance(const char[] bankint clientint ammountbool forcecreate true)

/**
 * Get the balance of a client in a specific bank.
 *
 * @param bank             The name of the bank
 * @param client    The client to get the balance of.
 * @return            The ammount of credits. -1 if no account found.
 */
native int Bank_GetBalance(const char[] bankint client)

/**
 * Set the balance of a client in a specific bank.
 *
 * @param bank             The name of the bank
 * @param client        The client to set the balance of.
 * @param ammount       The ammount to set the balance of the player. That wasn't english.
 * @param forcecreate   Create the user if not found in the bank.
 * @return            True on sucess, false otherwise.
 */
native bool Bank_SetBalance(const char[] bankint clientint ammountbool forcecreate true)

/**
 * Set the balance of a client in a specific bank.
 *
 * @param bank             The name of the bank
 * @param steamID        The client to set the balance of.
 * @param ammount       The ammount to set the balance of the player. That wasn't english.
 * @param forcecreate   Create the user if not found in the bank.
 * @return            True on sucess, false otherwise.
 */
native bool Bank_SetBalanceSteam(const char[] bank, const char[] steamIDint ammountbool forcecreate true
To fix the error I just added a few simple deletes. And it worked perfectly. The problem is the program was storing data about user over and over again and the plugin had to be shut down.
Attached Files
File Type: sp Get Plugin or Get Source (Bank.sp - 104 views - 8.8 KB)
ShawnCZek is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 03-20-2018 , 15:01   Re: [INC] Bank
Reply With Quote #22

I'll add it to the OP, good job.
__________________
Arkarr is offline
ShawnCZek
Member
Join Date: Mar 2017
Location: Czech Republic
Old 03-21-2018 , 12:21   Re: [INC] Bank
Reply With Quote #23

Quote:
Originally Posted by Arkarr View Post
I'll add it to the OP, good job.
Thank you. And as I wrote - the new function is useful for optimizing. For example I store data about an user when he connects and I edit his credits only in my plugin. And for storing them for the next time I use the database when he disconnects.
ShawnCZek is offline
KoKoDoDo
New Member
Join Date: Apr 2018
Old 04-06-2018 , 12:33   Re: [INC] Bank
Reply With Quote #24

someone can give me example of what i need to do to Activate this with DB?
KoKoDoDo is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 04-06-2018 , 14:42   Re: [INC] Bank
Reply With Quote #25

L 04/06/2018 - 18:15:03: [SM] Exception reported: Invalid database Handle 0 (error: 4)
L 04/06/2018 - 18:15:03: [SM] Blaming: Bank.smx
L 04/06/2018 - 18:15:03: [SM] Call stack trace:
L 04/06/2018 - 18:15:03: [SM] [0] SQL_Query
L 04/06/2018 - 18:15:03: [SM] [1] Line 321, C:\Users\Arkarr\AppData\Roaming\spedit\source pawn\scripts\Bank.sp::GetBankID
L 04/06/2018 - 18:15:03: [SM] [2] Line 348, C:\Users\Arkarr\AppData\Roaming\spedit\source pawn\scripts\Bank.sp::BankExist
L 04/06/2018 - 18:15:03: [SM] [3] Line 88, C:\Users\Arkarr\AppData\Roaming\spedit\source pawn\scripts\Bank.sp::Native_BankCreate
L 04/06/2018 - 18:15:03: [SM] [5] Bank_Create


What to do?
__________________
I am available to make plugins for pay.

Discord: Eyal282#1334
eyal282 is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 04-06-2018 , 15:54   Re: [INC] Bank
Reply With Quote #26

Quote:
Originally Posted by KoKoDoDo View Post
someone can give me example of what i need to do to Activate this with DB?
I don't understand your question.
Quote:
Originally Posted by eyal282 View Post
L 04/06/2018 - 18:15:03: [SM] Exception reported: Invalid database Handle 0 (error: 4)
L 04/06/2018 - 18:15:03: [SM] Blaming: Bank.smx
L 04/06/2018 - 18:15:03: [SM] Call stack trace:
L 04/06/2018 - 18:15:03: [SM] [0] SQL_Query
L 04/06/2018 - 18:15:03: [SM] [1] Line 321, C:\Users\Arkarr\AppData\Roaming\spedit\source pawn\scripts\Bank.sp::GetBankID
L 04/06/2018 - 18:15:03: [SM] [2] Line 348, C:\Users\Arkarr\AppData\Roaming\spedit\source pawn\scripts\Bank.sp::BankExist
L 04/06/2018 - 18:15:03: [SM] [3] Line 88, C:\Users\Arkarr\AppData\Roaming\spedit\source pawn\scripts\Bank.sp::Native_BankCreate
L 04/06/2018 - 18:15:03: [SM] [5] Bank_Create


What to do?
Fix CVAR so plugin can connect to database.
__________________
Arkarr is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 04-06-2018 , 15:58   Re: [INC] Bank
Reply With Quote #27

Quote:
Originally Posted by Arkarr View Post
I don't understand your question.
Fix CVAR so plugin can connect to database.
What cvar? I don't see any convars in your plugin.
__________________
I am available to make plugins for pay.

Discord: Eyal282#1334
eyal282 is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 04-06-2018 , 16:26   Re: [INC] Bank
Reply With Quote #28

Quote:
Originally Posted by eyal282 View Post
What cvar? I don't see any convars in your plugin.
My bad, it's in databae.cfg that you have to insert those infos.
__________________
Arkarr is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 04-06-2018 , 16:39   Re: [INC] Bank
Reply With Quote #29

Quote:
Originally Posted by Arkarr View Post
My bad, it's in databae.cfg that you have to insert those infos.
I've inserted all the data and correctly.

Code:
	"Bank" 
    	{ 
       		 "driver"            "default" 
       		 "host"            "127.0.0.1" 
       		 "database"  "almog_bank"
		 "user"  "almog_bank"
		 "pass"  "CENSORED" 
 	 }
If I put the wrong password, I get the access denied error obviously so it might prove the issue is not with connecting, anything I missed?
__________________
I am available to make plugins for pay.

Discord: Eyal282#1334

Last edited by eyal282; 04-06-2018 at 16:39.
eyal282 is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 04-07-2018 , 11:33   Re: [INC] Bank
Reply With Quote #30

Fixed, I believe.
__________________
Arkarr 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 09:34.


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