Command for setting Cash of account
#1


so when testing around i just remembered there wasn't a way to add cash to your account via command, so let's change this..

 

doFuncAdmin.cpp:

void do_GM_Cash(CPC* ch, const char* arg, std::vector<std:Confusedtring>& vec)
{

char tmpBuf[MAX_MESSAGE_SIZE] = { 0, };

*tmpBuf = '\0';
if (!arg || !(*arg))
return;

arg = AnyOneArg(arg, tmpBuf, true);

int amount = atoi(tmpBuf);

CLCString sql(2048);
CDBCmd cmd;
cmd.Init(&gserver->m_dbauth);

sql.Format("UPDATE bg_user SET cash = %d WHERE user_code = %d", amount, ch->m_desc->m_index);
cmd.SetQuery(sql);
if (!cmd.Update())
{
LOG_ERROR("Cash Query failed");
}

}

 

doFuncAdmin.h:

void do_GM_Cash(CPC* ch, const char* arg, std::vector<std:Confusedtring>& vec);

 

GMCmdList.cpp:

add(new CGMCmd("cash", 10, do_GM_Cash));


YOU ALSO NEED TO ADD WHAT KRAVENS POSTED BELOW FOR THIS TO WORK PROPERLY! THE DEFAULT GAMESERVER DOESN'T HAVE CONNECTION TO THE AUTH DATABASE!

Then after adding it you just need to use the command /cash and type whatever number you want.

#2

Easy code, but usefull, thanks ?

You miss to write fews line of code and a setup for newstomb.bin, so i will show it here.

GameServer/Server.h

MYSQL m_dbauth; // AuthDatabase

GameServer/Server.cpp

mysql_init(&m_dbauth);

bool CServer::ConnectDB() function

if (!mysql_real_connect(
&m_dbauth,
m_config.Find("Auth DB", "IP"),
m_config.Find("Auth DB", "User"),
m_config.Find("Auth DB", "Password"),
m_config.Find("Auth DB", "DBName"),
0, NULL, 0))
{
LOG_ERROR("Can't connect Auth DB : ip[%s] id[%s] pw[%s] dbname[%s] error[%s]",
m_config.Find("Auth DB", "IP"),
m_config.Find("Auth DB", "User"),
m_config.Find("Auth DB", "Password"),
m_config.Find("Auth DB", "DBName"),
mysql_error(&m_dbauth)
);
return false;
}

Now go to gameserver newstomb.bin and add

[Auth DB]
IP=127.0.0.1
DBName=dbauth
User=root
Password=

 

#3

Oh I didn't even notice that, had this forever so I never once thought that this isn't added in the source itself. Thanks ?

#4


On 12/26/2020 at 2:15 PM, kravens said:




Easy code, but usefull, thanks ?


You miss to write fews line of code and a setup for newstomb.bin, so i will show it here.



GameServer/Server.h




MYSQL m_dbauth; // AuthDatabase


GameServer/Server.cpp




mysql_init(&m_dbauth);


bool CServer::ConnectDB() function




if (!mysql_real_connect(
&m_dbauth,
m_config.Find("Auth DB", "IP"),
m_config.Find("Auth DB", "User"),
m_config.Find("Auth DB", "Password"),
m_config.Find("Auth DB", "DBName"),
0, NULL, 0))
{
LOG_ERROR("Can't connect Auth DB : ip[%s] id[%s] pw[%s] dbname[%s] error[%s]",
m_config.Find("Auth DB", "IP"),
m_config.Find("Auth DB", "User"),
m_config.Find("Auth DB", "Password"),
m_config.Find("Auth DB", "DBName"),
mysql_error(&m_dbauth)
);
return false;
}


Now go to gameserver newstomb.bin and add




[Auth DB]
IP=127.0.0.1
DBName=dbauth
User=root
Password=


 




Or you can just edit


Quote




cmd.Init(&gserver->m_dbauth);




into


Quote




cmd.Init(&gserver->m_dbAuth);



#5

kravens post is right, there is no way to apparently call the auth database unless you add it yourself. "m_dbAuth" does not exist within the gameserver.

@Desarija your apparently have a source that this has been added into, this is does not seem to be standard.

#6



7 hours ago, Veni said:




kravens post is right, there is no way to apparently call the auth database unless you add it yourself. "m_dbAuth" does not exist within the gameserver.

@Desarija your apparently have a source that this has been added into, this is does not seem to be standard.




My bad then, sorry^^ I thought that was there by default, but you're right



Forum Jump:


Users browsing this thread: