Jump to content
Maintenance : Final step ×

Ban System - Ban Command with Reason


Sanchez

Recommended Posts

  • 2 weeks later...
  • 1 month later...
  • 2 months later...
  • 1 month later...
ACMD(do_ban)

Now time to add the complete code to ACMD(do_ban):
 
?
// Args
char arg1[256], arg2[256], arg3[256];
 
// Local variables
const char*  szName;
const char*  szReason;
int          iDuration;
 
one_argument(two_arguments(argument, arg1, sizeof(arg1), arg2, sizeof(arg2)), arg3, sizeof(arg3));
 
// Invalid syntax
if (!*arg1 || !*arg2 || !*arg3)
{
    ch->ChatPacket(CHAT_TYPE_INFO, "Invalid Syntax, usage: <player name> <time in hours> <reason> tip: don't use spaces in the reason, use _");
    return;
}
 
szName      = arg1;
iDuration   = atoi(arg2);
szReason    = arg3;
 
if (iDuration <= 0)
{
    ch->ChatPacket(CHAT_TYPE_INFO, "Duration can't be 0 or minus.");
    return;
}
 
LPCHARACTER tch = CHARACTER_MANAGER::instance().FindPC(szName);
 
if (!tch)
{
    ch->ChatPacket(CHAT_TYPE_INFO, "%s is not playing", szName);
    return;
}
 
if (!tch->GetDesc())
{
    ch->ChatPacket(CHAT_TYPE_INFO, "%s don't have desc", szName);
    return;
}
 
if (tch == ch)
{
    ch->ChatPacket(CHAT_TYPE_INFO, "What's wrong with you? Don't ban yourself");
    return;
}
 
if (tch->GetGMLevel() > GM_PLAYER)
{
    ch->ChatPacket(CHAT_TYPE_INFO, "Do not ban GMs");
    return;
}
 
std::auto_ptr<SQLMsg> msg(DBManager::instance().DirectQuery("UPDATE account.account SET availDt = FROM_UNIXTIME(UNIX_TIMESTAMP(CURRENT_TIMESTAMP()) + %i), reason = '%s' WHERE id = %d", iDuration * 3600, szReason, tch->GetDesc()->GetAccountTable().id));
 
tch->GetDesc()->DelayedDisconnect(5);
 
sys_log(0, "%s[%d] banned %s for %i hours with reason: %s", ch->GetName(), ch->GetPlayerID(), szName, iDuration, szReason);
 
ch->ChatPacket(CHAT_TYPE_INFO, "%s has been banned for %i hours with reason: %s", szName, iDuration, szReason);

 not work for me spam fully error i have tab

 

please give me this file cpp i look where is i create wrong

Link to comment
Share on other sites

  • 1 month later...
ACMD(do_ban)
{
	char szName[CHARACTER_NAME_MAX_LEN + 1];
	char szReason[512];
	int iDuration;
	
	one_argument(two_arguments(argument,szName,sizeof(szName),szReason,sizeof(szReason)),iDuration,sizeof(iDuration));
	
	// Invalid syntax
	if (!*arg1 || !*arg2 || !*arg3)
	{
		ch->ChatPacket(CHAT_TYPE_INFO, "Invalid Syntax, usage: <player name> <time in hours> <reason> tip: don't use spaces in the reason, use _");
		return;
	}
	
	str_to_number(iDuration,arg2);
	
	if (iDuration <= 0)
	{
		ch->ChatPacket(CHAT_TYPE_INFO, "Duration can't be 0 or minus.");
		return;		
	}
	
	LPCHARACTER tch = CHARACTER_MANAGER::instance().FindPC(szName);
	
	if (!tch->GetDesc())
	{
		ch->ChatPacket(CHAT_TYPE_INFO, "%s don't have desc", szName);
		return;
	}
	  
	if (tch == ch)
	{
		ch->ChatPacket(CHAT_TYPE_INFO, "What's wrong with you? Don't ban yourself");
		return;
	}
	  
	if (tch->GetGMLevel() > GM_HIGH_WIZARD)
	{
		ch->ChatPacket(CHAT_TYPE_INFO, "Do not ban GMs");
		return;
	}
	
	std::auto_ptr<SQLMsg> msg(DBManager::instance().DirectQuery("UPDATE account.account SET availDt = FROM_UNIXTIME(UNIX_TIMESTAMP(CURRENT_TIMESTAMP()) + %d), reason = '%s' WHERE id = %u", iDuration * 3600, szReason, tch->GetDesc()->GetAccountTable().id));
	
	if(msg.get() && msg->Get()->uiAffectedRows == 0 || msg->Get()->uiAffectedRows == (uint32_t)-1)
	{
		ch->ChatPacket(CHAT_TYPE_INFO,"do_ban failed : can not modify account table");
		return;
	}
	
	tch->GetDesc()->DelayedDisconnect(5);
	  
	sys_log(0, "%s[%u] banned %s for %d hours with reason: %s", ch->GetName(), ch->GetPlayerID(), szName, iDuration, szReason);
	  
	ch->ChatPacket(CHAT_TYPE_INFO, "%s has been banned for %d hours with reason: %s", szName, iDuration, szReason);	
}

Kind Regards

Ken ~ TA

Edited by Ken
  • Love 1

Do not be sorry, be better.

Link to comment
Share on other sites

ACMD(do_ban)
{
	char szName[CHARACTER_NAME_MAX_LEN + 1];
	char szReason[512];
	int iDuration;
	
	one_argument(two_arguments(argument,arg1,sizeof(arg1),arg2,sizeof(arg2)),arg3,sizeof(arg3));
	
	// Invalid syntax
	if (!*arg1 || !*arg2 || !*arg3)
	{
		ch->ChatPacket(CHAT_TYPE_INFO, "Invalid Syntax, usage: <player name> <time in hours> <reason> tip: don't use spaces in the reason, use _");
		return;
	}
	
	str_to_number(iDuration,arg2);
	
	if (iDuration <= 0)
	{
		ch->ChatPacket(CHAT_TYPE_INFO, "Duration can't be 0 or minus.");
		return;		
	}
	
	LPCHARACTER tch = CHARACTER_MANAGER::instance().FindPC(szName);
	
	if (!tch->GetDesc())
	{
		ch->ChatPacket(CHAT_TYPE_INFO, "%s don't have desc", szName);
		return;
	}
	  
	if (tch == ch)
	{
		ch->ChatPacket(CHAT_TYPE_INFO, "What's wrong with you? Don't ban yourself");
		return;
	}
	  
	if (tch->GetGMLevel() > GM_HIGH_WIZARD)
	{
		ch->ChatPacket(CHAT_TYPE_INFO, "Do not ban GMs");
		return;
	}
	
	std::auto_ptr<SQLMsg> msg(DBManager::instance().DirectQuery("UPDATE account.account SET availDt = FROM_UNIXTIME(UNIX_TIMESTAMP(CURRENT_TIMESTAMP()) + %d), reason = '%s' WHERE id = %u", iDuration * 3600, szReason, tch->GetDesc()->GetAccountTable().id));
	
	if(msg.get() && msg->Get()->uiAffectedRows == 0 || pmsg->Get()->uiAffectedRows == (uint32_t)-1)
	{
		ch->ChatPacket(CHAT_TYPE_INFO,"do_ban failed : can not modify account table");
		return;
	}
	
	tch->GetDesc()->DelayedDisconnect(5);
	  
	sys_log(0, "%s[%u] banned %s for %d hours with reason: %s", ch->GetName(), ch->GetPlayerID(), szName, iDuration, szReason);
	  
	ch->ChatPacket(CHAT_TYPE_INFO, "%s has been banned for %d hours with reason: %s", szName, iDuration, szReason);	
}

Kind Regards

Ken ~ TA

 

I add this code but .

cmd_gm.cpp: In function 'void do_ban(CHARACTER*, const char*, int, int)':
cmd_gm.cpp:4407: error: 'arg1' was not declared in this scope
cmd_gm.cpp:4407: error: 'arg2' was not declared in this scope
cmd_gm.cpp:4407: error: 'arg3' was not declared in this scope
cmd_gm.cpp:4446: error: 'pmsg' was not declared in this scope
Makefile:119: recipe for target 'OBJDIR/cmd_gm.o' failed
gmake: *** [OBJDIR/cmd_gm.o] Error 1
root@metin2:/usr/src/Server/game/src #

Link to comment
Share on other sites

Why are you guys still using std::auto_ptr? It's old, deprecated and unsafe. Just use sse std::unique_ptr instead.

 

GCC 4.2 is not support that. As galet said. If you wanna use that, you can use it. Meanwhile new command for gcc 4.8+

ACMD(do_ban)
{
    char szName[CHARACTER_NAME_MAX_LEN + 1];
    char szReason[512];
    int iDuration;
     
    one_argument(two_arguments(argument,szName,sizeof(szName),szReason,sizeof(szReason)),iDuration,sizeof(iDuration));
     
    // Invalid syntax
    if (!*arg1 || !*arg2 || !*arg3)
    {
        ch->ChatPacket(CHAT_TYPE_INFO, "Invalid Syntax, usage: <player name> <time in hours> <reason> tip: don't use spaces in the reason, use _");
        return;
    }
     
    str_to_number(iDuration,arg2);
     
    if (iDuration <= 0)
    {
        ch->ChatPacket(CHAT_TYPE_INFO, "Duration can't be 0 or minus.");
        return;     
    }
     
    LPCHARACTER tch = CHARACTER_MANAGER::instance().FindPC(szName);
     
    if (!tch->GetDesc())
    {
        ch->ChatPacket(CHAT_TYPE_INFO, "%s don't have desc", szName);
        return;
    }
       
    if (tch == ch)
    {
        ch->ChatPacket(CHAT_TYPE_INFO, "What's wrong with you? Don't ban yourself");
        return;
    }
       
    if (tch->GetGMLevel() > GM_HIGH_WIZARD)
    {
        ch->ChatPacket(CHAT_TYPE_INFO, "Do not ban GMs");
        return;
    }
     
    std::unique_ptr<SQLMsg> msg(DBManager::instance().DirectQuery("UPDATE account.account SET availDt = FROM_UNIXTIME(UNIX_TIMESTAMP(CURRENT_TIMESTAMP()) + %d), reason = '%s' WHERE id = %u", iDuration * 3600, szReason, tch->GetDesc()->GetAccountTable().id));
     
    if(msg.get() && msg->Get()->uiAffectedRows == 0 || msg->Get()->uiAffectedRows == (uint32_t)-1)
    {
        ch->ChatPacket(CHAT_TYPE_INFO,"do_ban failed : can not modify account table");
        return;
    }
     
    tch->GetDesc()->DelayedDisconnect(5);
       
    sys_log(0, "%s[%u] banned %s for %d hours with reason: %s", ch->GetName(), ch->GetPlayerID(), szName, iDuration, szReason);
       
    ch->ChatPacket(CHAT_TYPE_INFO, "%s has been banned for %d hours with reason: %s", szName, iDuration, szReason);  
}

Kind Regards

Ken ~ TA

Edited by Ken
  • Love 2

Do not be sorry, be better.

Link to comment
Share on other sites

  • 1 month later...

compile cmd_gm.cpp
cmd_gm.cpp: In function 'void do_ban(CHARACTER*, const char*, int, int)':
cmd_gm.cpp:2816: error: only constructors take base initializers
cmd_gm.cpp:2818: error: expected identifier before 'char'
cmd_gm.cpp:2818: error: expected `(' before 'char'
cmd_gm.cpp:2818: error: expected `{' before 'char'
cmd_gm.cpp: At global scope:
cmd_gm.cpp:2825: error: expected constructor, destructor, or type conversion before '(' token
cmd_gm.cpp:2828: error: expected unqualified-id before 'if'
cmd_gm.cpp:2834: error: expected constructor, destructor, or type conversion before '=' token
cmd_gm.cpp:2835: error: expected constructor, destructor, or type conversion before '=' token
cmd_gm.cpp:2836: error: expected constructor, destructor, or type conversion before '=' token
cmd_gm.cpp:2838: error: expected unqualified-id before 'if'
cmd_gm.cpp:2846: error: expected unqualified-id before 'if'
cmd_gm.cpp:2852: error: expected unqualified-id before 'if'
cmd_gm.cpp:2858: error: expected unqualified-id before 'if'
cmd_gm.cpp:2864: error: expected unqualified-id before 'if'
cmd_gm.cpp:2872: error: expected constructor, destructor, or type conversion before '->' token
cmd_gm.cpp:2874: error: expected constructor, destructor, or type conversion before '(' token
cmd_gm.cpp:2876: error: expected constructor, destructor, or type conversion before '->' token
cmd_gm.cpp: In function 'void do_set_stat(CHARACTER*, const char*, int, int)':
cmd_gm.cpp:3997: warning: NULL used in arithmetic
gmake: *** [OBJDIR/cmd_gm.o] Error 1
root@Damian:/usr/src/Source/main/Srcs/Server/game/src #
 

Link to comment
Share on other sites

  • 3 months later...
  • 2 weeks later...
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.