Majster12
Member
- Joined
- Feb 20, 2009
- Messages
- 134
- Solutions
- 1
- Reaction score
- 16
TFS 1.2
Any ideas?
luascript.cpp
npcsystem\modules.lua
http://pastebin.com/raw/UzY2vvZt
npcsystem\npchandler.lua
http://pastebin.com/raw/cNg0sXhH
Any ideas?
luascript.cpp
Code:
int LuaScriptInterface::luaPlayerGetMoney(lua_State* L)
{
// player:getMoney()
Player* player = getUserdata<Player>(L, 1);
if (player) {
lua_pushnumber(L, player->getMoney());
}
else {
lua_pushnil(L);
}
return 1;
}
Code:
int LuaScriptInterface::luaPlayerRemoveMoney(lua_State* L)
{
// player:removeMoney(money)mon
Player* player = getUserdata<Player>(L, 1);
bool success = false;
if (player) {
uint64_t money = getNumber<uint64_t>(L, 2);
if (!g_game.removeMoney(player, money))
{
uint64_t playerTotal = player->getMoney() + player->getBankBalance();
if (playerTotal >= money)
{
money -= player->getMoney(); //discount player money
if (money < 0) money = 0;
g_game.removeMoney(player, player->getMoney()); //1
if (player->getMoney() < 0) money = 0;
// player money is 0, and its value is discounted. Now remove from balance the rest
playerTotal = player->getBankBalance() - money;
if (playerTotal < 0) playerTotal = 0;
player->setBankBalance(playerTotal);
std::ostringstream ss;
ss << "Paid " << money << " gold from bank account. Your account balance is now " << player->getBankBalance() << " gold.";
player->sendTextMessage(MESSAGE_INFO_DESCR, ss.str());
success = true;
}
}
else
{
success = true;
}
pushBoolean(L, success);
}
else {
lua_pushnil(L);
}
return 1;
}
http://pastebin.com/raw/UzY2vvZt
npcsystem\npchandler.lua
http://pastebin.com/raw/cNg0sXhH