示例#1
0
void PCommands::doCmdkick()
{
    bool SyntaxError = false;
    if(ArgC < 1)
    {
        SyntaxError = true;
    }

    if(SyntaxError == true)
    {
        Chat->send(source, CHAT_DIRECT, "Usage", "@kick <charID or nickname>");
        return;
    }

    if(IsArgNumeric(1) == true)
    {
        target = GetClientByID(GetArgInt(1));
    }
    else
    {
        char tmp_destNick[50];
        GetArgText(1, tmp_destNick, 50);
        target = GetClientByNick(tmp_destNick);
    }

    if(target == NULL) // If victim isnt found, return error
    {
        Chat->send(source, CHAT_DIRECT, "System", "No such player");
        return;
    }

    // Make sure only people with a higher level than victim can kick victim
    if(source->GetAccountLevel() <= target->GetAccountLevel())
    {
        char tmpMsg[200];
        snprintf(tmpMsg, 199, "Cant kick %s, target level is higher or equal to yours!", Chars->GetChar(target->GetCharID())->GetName().c_str());
        tmpMsg[199] = '\0';
        Chat->send(source, CHAT_DIRECT, "System", tmpMsg);
        return;
    }

// *************** Checks done, proceed with command
    int final_bantime = std::time(NULL) + 60;               // Ban 60 seconds (Anti-Rejoin)
    PAccount Acc(target->GetAccountID());
    Acc.SetBannedUntilTime(final_bantime);
    Acc.Save();

    target->InitCharVanish();
    GameServer->ClientDisconnected(target);                 // Kick

    Console->Print("%s %s (Lv %d) kicked %s (Lv %d)", Console->ColorText(YELLOW, BLACK, "[GameCommand]"), Chars->GetChar(source->GetCharID())->GetName().c_str(), source->GetAccountLevel(), Chars->GetChar(target->GetCharID())->GetName().c_str(), target->GetAccountLevel());
    char successmsg[100];
    snprintf(successmsg, 99, "Kicked %s", Chars->GetChar(target->GetCharID())->GetName().c_str());
    successmsg[99] = '\0';
    Chat->send(source, CHAT_DIRECT, "System", successmsg);
}
示例#2
0
void PCommands::doCmdshun()
{
    bool SyntaxError = false;
    if(ArgC < 1)
    {
        SyntaxError = true;
    }

    if(SyntaxError == true)
    {
        Chat->send(source, CHAT_DIRECT, "Usage", "@shun <charID or nickname>");
        return;
    }

    if(IsArgNumeric(1) == true)
    {
        target = GetClientByID(GetArgInt(1));
    }
    else
    {
        char tmp_destNick[50];
        GetArgText(1, tmp_destNick, 50);
        target = GetClientByNick(tmp_destNick);
    }

    if(target == NULL) // If victim isnt found, return error
    {
        Chat->send(source, CHAT_DIRECT, "System", "No such player");
        return;
    }
    if(source->GetAccountLevel() <= target->GetAccountLevel())
    {
        char tmpMsg[200];
        snprintf(tmpMsg, 199, "Cant shun %s, target level is higher or equal to yours!", Chars->GetChar(target->GetCharID())->GetName().c_str());
        tmpMsg[199] = '\0';
        Chat->send(source, CHAT_DIRECT, "System", tmpMsg);
        return;
    }
    if(target->GetChar()->IsShunned() == false)
    {
        target->GetChar()->SetShun(true);

        char tmpMsg_success[81];
        snprintf(tmpMsg_success, 80, "Successfully shunned %s", target->GetChar()->GetName().c_str());
        tmpMsg_success[80] = '\0';
        Chat->send(source, CHAT_DIRECT, "System", tmpMsg_success);
        return;
    }
    else
    {
        Chat->send(source, CHAT_DIRECT, "System", "Player is already shunned");
        return;
    }
}
示例#3
0
void PCommands::doCmdban()
{
    bool SyntaxError = false;
    if(ArgC < 2)
    {
        SyntaxError = true;
    }

    if(SyntaxError == true)
    {
        Chat->send(source, CHAT_DIRECT, "Usage", "@ban <charID or nickname> <xS(econds)>/<xM(inutes)>/<xH(ours)>/<xD(ays)>");
        return;
    }

    if(IsArgNumeric(1) == true)
    {
        target = GetClientByID(GetArgInt(1));
    }
    else
    {
        char tmp_destNick[50];
        GetArgText(1, tmp_destNick, 50);
        target = GetClientByNick(tmp_destNick);
    }

    if(target == NULL) // If victim isnt found, return error
    {
        Chat->send(source, CHAT_DIRECT, "System", "No such player");
        return;
    }
    if(source->GetAccountLevel() <= target->GetAccountLevel())
    {
        char tmpMsg[200];
        snprintf(tmpMsg, 199, "Cant ban %s, target level is higher or equal to yours!", Chars->GetChar(target->GetCharID())->GetName().c_str());
        tmpMsg[199] = '\0';
        Chat->send(source, CHAT_DIRECT, "System", tmpMsg);
        return;
    }
    char tmpTimeVal[10];
    GetArgText(2, tmpTimeVal, 10);

    int loop_i = 0;
    char tmp_atoi[10];

    while(isdigit(tmpTimeVal[loop_i]) != 0 && loop_i < 10)
    {
        tmp_atoi[loop_i] = tmpTimeVal[loop_i];
        loop_i++;
    }
    char timefactor[1];
    timefactor[0] = tmpTimeVal[loop_i];
    int timevalue = atoi(tmp_atoi);
    int time_to_ban = 0;

    if(strcasecmp(timefactor, "s") == 0 )
    {
        time_to_ban = timevalue;
    }
    else if(strcasecmp(timefactor, "m") == 0 )
    {
        time_to_ban = timevalue * 60;
    }
    else if(strcasecmp(timefactor, "h") == 0 )
    {
        time_to_ban = timevalue * 60 * 60;
    }
    else if(strcasecmp(timefactor, "d") == 0 )
    {
        time_to_ban = timevalue * 60 * 60 * 24;
    }
    else
    {
        Chat->send(source, CHAT_DIRECT, "Usage", "@ban <charID or nickname> <xS(econds)>/<xM(inutes)>/<xH(ours)>/<xD(ays)>");
        return;
    }
    
    int final_bantime = std::time(NULL) + time_to_ban;
    PAccount Acc(target->GetAccountID());
    Acc.SetBannedUntilTime(final_bantime);
    Acc.Save();

    target->InitCharVanish();

    GameServer->ClientDisconnected(target);  // Now kick the player (Hes banned :) )

    char tmpMsg_success[81];
    snprintf(tmpMsg_success, 80, "Successfully banned %s", target->GetChar()->GetName().c_str());
    tmpMsg_success[80] = '\0';
    Chat->send(source, CHAT_DIRECT, "System", tmpMsg_success);
    return;
}
示例#4
0
void PCommands::doCmdrecall()
{
  bool SyntaxError = false;
  if ( ArgC < 1 )
  {
    SyntaxError = true;
  }

  if ( SyntaxError == true )
  {
    Chat->send( source, CHAT_DIRECT, "Usage", "@recall <charID or nickname>" );
    return;
  }

  if ( IsArgNumeric( 1 ) == true )
  {
    target = GetClientByID( GetArgInt( 1 ) );
  }
  else
  {
    char tmp_destNick[50];
    GetArgText( 1, tmp_destNick, 50 );
    target = GetClientByNick( tmp_destNick );
  }

  if ( target == NULL ) // If victim isnt found, return error
  {
    Chat->send( source, CHAT_DIRECT, "System", "No such player" );
    return;
  }
  // Check accountlevel (Only higher's can perform commands on lower's)
  if ( source->GetAccountLevel() <= target->GetAccountLevel() )
  {
    char tmpMsg[200];
    snprintf( tmpMsg, 199, "Cant warp %s to you, target level is higher or equal to yours!", Chars->GetChar( target->GetCharID() )->GetName().c_str() );
    tmpMsg[199] = '\0';
    Chat->send( source, CHAT_DIRECT, "System", tmpMsg );
    return;
  }

  // Warp target player to GM/Admin
  int destZone = Chars->GetChar( source->GetCharID() )->GetLocation();
  if ( !Worlds->IsValidWorld( destZone ) )
  {
    Console->Print( "%s Can't change location, destZone '%d' is invalid for some reason", Console->ColorText( RED, BLACK, "[PANIC]" ), destZone );
    return;
  }
// *************** Checks done, proceed with command

  if ( target->ChangeCharLocation( destZone ), true )
  {
    PMessage* tmpMsg_zone = MsgBuilder->BuildAptLiftUseMsg( target, destZone, 0 );
    target->SendUDPMessage( tmpMsg_zone );
    tmpMsg_zone = NULL;

    u16 nNewX, nNewY, nNewZ;
    nNewX = source->GetChar()->Coords.mX;
    nNewY = source->GetChar()->Coords.mY;
    nNewZ = source->GetChar()->Coords.mZ;
    target->SetAwaitingWarpto( true, nNewX, nNewY, nNewZ );

    char tmpMsg_success[81];
    snprintf( tmpMsg_success, 80, "Successfully recalled %s", target->GetChar()->GetName().c_str() );
    tmpMsg_success[80] = '\0';
    Chat->send( source, CHAT_DIRECT, "System", tmpMsg_success );
    return;
  }
  else
  {
    Console->Print( "%s Unable to change location for player %d to %d", Console->ColorText( RED, BLACK, "[PANIC]" ), target->GetCharID(), destZone );
  }
}
示例#5
0
void PCommands::doCmdSetMainSkill()
{
    u8 tNewLevel = 0;
    u8 tMainSkill = 0;

    bool SyntaxError = false;
    if (ArgC < 2)
    {
        SyntaxError = true;
    }

    if (IsArgNumeric(1) == false)
        SyntaxError = true;
    else
        tMainSkill = (u16)GetArgInt(1);

    if (IsArgNumeric(2) == false)
        SyntaxError = true;
    else
        tNewLevel = (u8)GetArgInt(2);

    if (tNewLevel == 0)
        SyntaxError = true;

    if ( source->GetChar()->Skill->IsValidMainSkill(tMainSkill) == false)
        SyntaxError = true;

    if (SyntaxError == true)
    {
        Chat->send(source, CHAT_DIRECT, "Usage", "@setmainskill <1-5> <1-255> [<charID or nickname>]");
        Chat->send(source, CHAT_DIRECT, "Usage", "1:STR 2:DEX 3:CON 4:INT 5:PSI");
        return;
    }

    PClient *temp_target = NULL;
    if ( ArgC == 3 )
    {
        if (IsArgNumeric(3) == true)
        {
            temp_target = GetClientByID(GetArgInt(3));
        }
        else
        {
            char tmp_destNick[50];
            GetArgText(3, tmp_destNick, 50);
            temp_target = GetClientByNick(tmp_destNick);
        }
        if (temp_target == NULL)
        {
            Chat->send(source, CHAT_DIRECT, "System", "No such player");
            return;
        }
    }
    else
        temp_target = source;

    // Now setting player's Skill tMainSkill to tNewLevel
    u8 tOldLevel = 0;
    u16 tNewSkillPoints = 0;
    int tLevelDiff = 0;

    // Grab old Level
    tOldLevel = temp_target->GetChar()->Skill->GetMainSkill(tMainSkill);
    tLevelDiff = tNewLevel - tOldLevel;
    if ( tLevelDiff == 0 )
    {
        Chat->send(source, CHAT_DIRECT, "System", "Not setting anything. No difference at all");
        return;
    }
    else if ( tLevelDiff > 0 ) // INCreasing mainskill
    {
        tNewSkillPoints = tLevelDiff*5;
        temp_target->GetChar()->Skill->SetSP(tMainSkill, tNewSkillPoints);
    }
    else if ( tLevelDiff < 0 ) // DECreasing mainskill
    {
        // Set all subskills to zero, and add tNewLevel*5 skillpoints
        temp_target->GetChar()->Skill->ZeroMSSubSkills(tMainSkill);
        temp_target->GetChar()->Skill->SetSP(tMainSkill, tNewLevel*5);
        tNewSkillPoints = 0;
        // Not perfect, player has to rezone for the correct values. Need a way to do massupdate subskills...
        // But on the other side, its not very common to DEcrease someone's skills, isnt it?
    }
    temp_target->GetChar()->Skill->SetMainSkill(tMainSkill, tNewLevel);

    char tmp[50];
    snprintf(tmp, 50, "Setting Level to %d", tNewLevel);
    Chat->send(source, CHAT_DIRECT, "System", tmp);
    //PMessage* PMsgBuilder::BuildLevelUpMessage( PClient* nClient, u8 nMainSkill, u8 nNewLevel, u16 nFreeSkillPoints)
    PMessage* tmpMsg_setLv = MsgBuilder->BuildLevelUpMessage(temp_target, tMainSkill, tNewLevel, tNewSkillPoints);
    temp_target->SendUDPMessage(tmpMsg_setLv);
    tmpMsg_setLv = NULL;
    temp_target = NULL;
}