mirror of
https://github.com/ErikasKontenis/SabrehavenServer.git
synced 2025-06-14 13:04:27 +02:00
introduce get guild balance npc method and alter table
This commit is contained in:
parent
43fb26cb5e
commit
f127b2abf7
@ -93,7 +93,8 @@ CREATE TABLE `guilds` (
|
||||
`name` varchar(255) NOT NULL,
|
||||
`ownerid` int(11) NOT NULL,
|
||||
`creationdata` int(11) NOT NULL,
|
||||
`motd` varchar(255) NOT NULL DEFAULT ''
|
||||
`motd` varchar(255) NOT NULL DEFAULT '',
|
||||
`balance` bigint(20) UNSIGNED NOT NULL DEFAULT '0',
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
|
@ -541,6 +541,9 @@ NpcBehaviourNode* BehaviourDatabase::readValue(ScriptReader& script)
|
||||
} else if (identifier == "balance") {
|
||||
node = new NpcBehaviourNode();
|
||||
node->type = BEHAVIOUR_TYPE_BALANCE;
|
||||
} else if (identifier == "guildbalance") {
|
||||
node = new NpcBehaviourNode();
|
||||
node->type = BEHAVIOUR_TYPE_GUILDBALANCE;
|
||||
} else if (identifier == "transfertoplayernamestate") {
|
||||
node = new NpcBehaviourNode();
|
||||
node->type = BEHAVIOUR_TYPE_MESSAGE_TRANSFERTOPLAYERNAME_STATE;
|
||||
@ -1254,6 +1257,14 @@ int32_t BehaviourDatabase::evaluate(NpcBehaviourNode* node, Player* player, cons
|
||||
return checkOperation(player, node, message);
|
||||
case BEHAVIOUR_TYPE_BALANCE:
|
||||
return player->getBankBalance();
|
||||
case BEHAVIOUR_TYPE_GUILDBALANCE: {
|
||||
const Guild* playerGuild = player->getGuild();
|
||||
if (!playerGuild) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return IOLoginData::getGuildBalance(playerGuild->getId());
|
||||
}
|
||||
case BEHAVIOUR_TYPE_CLIENTVERSION:
|
||||
return g_game.getClientVersion();
|
||||
case BEHAVIOUR_TYPE_MESSAGE_TRANSFERTOPLAYERNAME_STATE: {
|
||||
|
@ -81,6 +81,7 @@ enum NpcBehaviourType_t
|
||||
BEHAVIOUR_TYPE_SUMMON, // summons a monster
|
||||
BEHAVIOUR_TYPE_EXPERIENCE, // grant experience to a player
|
||||
BEHAVIOUR_TYPE_BALANCE, // return player balance
|
||||
BEHAVIOUR_TYPE_GUILDBALANCE, // return guild balance
|
||||
BEHAVIOUR_TYPE_WITHDRAW, // withdraw from player bank balance
|
||||
BEHAVIOUR_TYPE_DEPOSIT, // deposit x amount of gold
|
||||
BEHAVIOUR_TYPE_TRANSFER, // transfer x amount of gold
|
||||
|
@ -829,6 +829,18 @@ uint32_t IOLoginData::getGuidByName(const std::string& name)
|
||||
return result->getNumber<uint32_t>("id");
|
||||
}
|
||||
|
||||
uint64_t IOLoginData::getGuildBalance(uint32_t id)
|
||||
{
|
||||
std::ostringstream query;
|
||||
query << "SELECT `balance` FROM `guilds` WHERE `id` = " << id;
|
||||
DBResult_ptr result = Database::getInstance()->storeQuery(query.str());
|
||||
if (!result) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return result->getNumber<uint64_t>("balance");
|
||||
}
|
||||
|
||||
// Return 0 means player not found, 1 player is without vocation, 2 player with vocation
|
||||
uint16_t IOLoginData::canTransferMoneyToByName(const std::string& name)
|
||||
{
|
||||
|
@ -45,6 +45,7 @@ class IOLoginData
|
||||
static bool loadPlayer(Player* player, DBResult_ptr result);
|
||||
static bool savePlayer(Player* player);
|
||||
static uint32_t getGuidByName(const std::string& name);
|
||||
static uint64_t getGuildBalance(uint32_t id);
|
||||
static uint16_t canTransferMoneyToByName(const std::string& name);
|
||||
static bool getGuidByNameEx(uint32_t& guid, bool& specialVip, std::string& name);
|
||||
static std::string getNameByGuid(uint32_t guid);
|
||||
|
Loading…
x
Reference in New Issue
Block a user