06.08.2017, 23:33
(
Последний раз редактировалось nG Inverse; 11.09.2017 в 00:25.
)
Player Currency Library
About
This library is part of the San Andreas Multiplayer Framework (sampfw) and allows players to use different currencies in-game. More explanation on the framework coming...
Install
Define any settings (see below) then include the files:
pawn Код:
#include <sampfw\extra\util>
#include <sampfw\account\account>
#include <sampfw\server\currency>
Settings
SAMPFW_DEFAULT_CURRENCY
The default currency used by the server
SAMPFW_DBTABLE_CURRENCY
The database table to store currency rates in
SAMPFW_CURRENCY_UPDATE_TIME
The amount of days to pass before updating currency rates
Functions
pawn Код:
sampfw::SetPlayerCurrency(playerid, const currency[])
// Sets a player's currency
pawn Код:
sampfw::GetPlayerCurrency(playerid)
// Returns a player's currency
pawn Код:
sampfw::GetCurrencyName(id)
// Returns a currency's name
pawn Код:
sampfw::GetCurrencyID(const name[])
// Returns a currency's ID
pawn Код:
sampfw::GetConversion(from, to, Float: amount)
// Returns the 'amount' from currency 'from' to currency 'to'
pawn Код:
public OnPlayerCurrencyChange(playerid)
// Called when a player's currency is changed
pawn Код:
#define SAMPFW_DEFAULT_CURRENCY "USD" // Set the server default currency to USD
#define SAMPFW_CURRENCY_UPDATE_TIME 30 // Update currencies in the DB every server restart over 30 days
YCMD:givemoney(playerid, params[], help)
{
new
target,
Float: amount;
if(sscanf(params, "ui", target, amount))
return SendClientMessage(playerid, COLOR_USAGE, "Usage: /givemoney <id> <amount>");
GivePlayerMoney(playerid, floatround(-amount));
amount = sampfw::GetConversion(
sampfw::GetPlayerCurrency(playerid),
sampfw::GetPlayerCurrency(targetid),
amount
);
GivePlayerMoney(target, floatround(amount));
return 1;
}
This is a part of San Andreas Multiplayer Framework, and requires all of its dependencies. Check the GitHub for a list (docs/dependencies.txt).
GitHub
https://github.com/bwhitmire55/sampfw