Not working after mandatory update
Not working after mandatory updateSolved
can agree, loads fine but doesnt retreive players balances.
also agree, it states that my players do not have enough money to buy from shop. Economics is broken
Any workaround yet?
Mevent has updated the Shop plugin, and now the balance is visible there. However, Playtimerewards are currently not being credited to the balance.
yep, I am having the same issues.
same here
im starting to think economics is working but its the individual plugins that use economics that needs updates
raidable bases now works and uses economics
hud info panel now shows current economics
car sharing now uses economics
however there are other devs that think its economics not working. guess its a waiting game to see when its all fixed lol
caseyjonesjrim starting to think economics is working but its the individual plugins that use economics that needs updates
raidable bases now works and uses economics
hud info panel now shows current economics
car sharing now uses economics
however there are other devs that think its economics not working. guess its a waiting game to see when its all fixed lol
When you try and give players money the balance doesn't move. If a plugin that hands out $ tries to hook into it says failed to deposit money into the player's balance. To display the balance I feel is a bit different.
This plugin is currently working. Errors have occurred in other plugins integrated with it, and as those plugins started getting updated, it was found that the economics plugin is working. So, there is no serious issue. Just for your information.
Change in Economics.cs all in #region API Methods for
#region API Methods
private double Balance(object playerId)
{
ulong userId;
switch (playerId)
{
case ulong id:
userId = id;
break;
case string id:
if (!ulong.TryParse(id, out userId))
{
LogWarning("Balance method called with invalid player ID string: " + id);
return 0.0;
}
break;
case BasePlayer.EncryptedValue<ulong> id:
userId = id.Get();
break;
case BasePlayer player:
userId = player.userID.Get();
break;
case IPlayer player:
if (!ulong.TryParse(player.Id, out userId))
{
LogWarning("Balance method called with invalid player ID string: " + player.Id);
return 0.0;
}
break;
default:
LogWarning("Balance method called with unsupported player ID type: " + playerId.GetType());
return 0.0;
}
return storedData.Balances.TryGetValue(userId.ToString(), out double playerData)
? playerData
: config.StartingBalance;
}
private bool Deposit(object playerId, double amount)
{
ulong userId;
switch (playerId)
{
case ulong id:
userId = id;
break;
case string id:
if (!ulong.TryParse(id, out userId))
{
LogWarning("Deposit method called with invalid player ID string: " + id);
return false;
}
break;
case BasePlayer.EncryptedValue<ulong> id:
userId = id.Get();
break;
case BasePlayer player:
userId = player.userID.Get();
break;
case IPlayer player:
if (!ulong.TryParse(player.Id, out userId))
{
LogWarning("Deposit method called with invalid player ID string: " + player.Id);
return false;
}
break;
default:
LogWarning("Deposit method called with unsupported player ID type: " + playerId.GetType());
return false;
}
if (amount <= 0) return false;
if (SetBalance(userId.ToString(), amount + Balance(userId.ToString())))
{
Interface.Call("OnEconomicsDeposit", userId.ToString(), amount);
if (config.LogTransactions)
{
LogToFile("transactions",
$"[{DateTime.Now}] {GetLang("LogDeposit", null, amount, userId.ToString())}", this);
}
return true;
}
return false;
}
private bool SetBalance(object playerId, double amount)
{
ulong userId;
switch (playerId)
{
case ulong id:
userId = id;
break;
case string id:
if (!ulong.TryParse(id, out userId))
{
LogWarning("SetBalance method called with invalid player ID string: " + id);
return false;
}
break;
case BasePlayer.EncryptedValue<ulong> id:
userId = id.Get();
break;
case BasePlayer player:
userId = player.userID.Get();
break;
case IPlayer player:
if (!ulong.TryParse(player.Id, out userId))
{
LogWarning("SetBalance method called with invalid player ID string: " + player.Id);
return false;
}
break;
default:
LogWarning("SetBalance method called with unsupported player ID type: " + playerId.GetType());
return false;
}
if (amount >= 0 || config.AllowNegativeBalance)
{
amount = Math.Round(amount, 2);
if (config.BalanceLimit > 0 && amount > config.BalanceLimit)
{
amount = config.BalanceLimit;
}
else if (config.AllowNegativeBalance && config.NegativeBalanceLimit < 0 &&
amount < config.NegativeBalanceLimit)
{
amount = config.NegativeBalanceLimit;
}
storedData.Balances[userId.ToString()] = amount;
changed = true;
Interface.Call("OnEconomicsBalanceUpdated", userId.ToString(), amount);
Interface.CallDeprecatedHook("OnBalanceChanged", "OnEconomicsBalanceUpdated",
new System.DateTime(2022, 7, 1), userId.ToString(), amount);
if (config.LogTransactions)
{
LogToFile("transactions",
$"[{DateTime.Now}] {GetLang("LogSetBalance", null, amount, userId.ToString())}", this);
}
return true;
}
return false;
}
private bool Withdraw(object playerId, double amount)
{
ulong userId;
if (!TryParsePlayerId(playerId, out userId))
{
return false;
}
if (amount >= 0 || config.AllowNegativeBalance)
{
double balance = Balance(userId);
if ((balance >= amount ||
(config.AllowNegativeBalance && balance + amount > config.NegativeBalanceLimit)) &&
SetBalance(userId.ToString(), balance - amount))
{
Interface.Call("OnEconomicsWithdrawl", userId.ToString(), amount);
if (config.LogTransactions)
{
LogToFile("transactions",
$"[{DateTime.Now}] {GetLang("LogWithdrawl", null, amount, userId.ToString())}", this);
}
return true;
}
}
return false;
}
private bool TryParsePlayerId(object playerId, out ulong userId)
{
userId = 0;
switch (playerId)
{
case ulong id:
userId = id;
break;
case string id:
if (!ulong.TryParse(id, out userId))
{
LogWarning("Method called with invalid player ID string: " + id);
return false;
}
break;
case BasePlayer.EncryptedValue<ulong> id:
userId = id.Get();
break;
case BasePlayer player:
userId = player.userID.Get();
break;
case IPlayer player:
if (!ulong.TryParse(player.Id, out userId))
{
LogWarning("Method called with invalid player ID string: " + player.Id);
return false;
}
break;
default:
LogWarning("Method called with unsupported player ID type: " + playerId.GetType());
return false;
}
return true;
}
#endregion API Methods
All plugins will work
Locked automatically