I had made a credit system prior to this that I hacked up as a temporary thing. But I have updated the SVN with a Qglobal-based credit system that people can use that is much more flexible than the one I provided before, and even in some of the code I currently use.
This plugins file contains a
credit system functionality that will allow you to store credits using the qglobal system. This system currently supports two types of credit storage:
1. Player Specific Credit - 0
2. Account Specific Credit - 1
3. Guild Specific Credit - 2
For each of these three types, there are three functions:
1. Check
###Usage: plugin::QCreditCheck("Creditname", 0=Player 1=Account 2=Guild);
2. Withdraw
###Usage: plugin::QCreditWithdraw("Creditname", Amount, 0=Player 1=Account 2=Guild, [1 = Give to Player], [0=Nothing 1=Show Window 2=Show Text 3=Show Both Window/Text]);
3. Deposit
###Usage: plugin::QCreditDeposit("Creditname", Cost, 0=Player 1=Account 2=Guild, [0=Nothing 1=Show Window 2=Show Text 3=Show Both Window/Text]);
You can use this credit system for
text-based merchant scripts, or to hold credit for weightless or virtual
Platinum systems. Or you can even have it remember whatever you need it to remember for anything related to credits.
NOTE: Qglobals must be enable on NPC's that the script is being initiated from.
NOTE: You must also have the following in globals.pl at line 62, or the plugins SVN:
Code:
if ($varName eq 'itemcount' || $varName eq 'qglobals')
Below shows how simple a script can be to utilize these plugins:
This example is using personal (player) specific credit, any other credit storage type (player/account/guild) would work the same way:
Code:
sub EVENT_SAY{
my $CA = plugin::commify(plugin::QCreditCheck("BankCredit", 0));
$client->Message(315, "You have $CA credit");
if($text=~/deposit/i){
plugin::QCreditDeposit("BankCredit", 100, 0, 3);
}
if($text=~/withdraw/i){
plugin::QCreditWithdraw("BankCredit", 100, 0, 0, 3);
}
}
*Note: The 4th argument for deposit and the 5th argument for Withdraw both establish what message type you want to have output the final amount of your credit after the deposit or withdraw. You could have a window or text, or both, or even none at all:
Quote:
[0=Nothing 1=Show Window 2=Show Text 3=Show Both Window/Text]
|