• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

C++ Frags only vocations

igorlabanca

New Member
Joined
Aug 15, 2010
Messages
36
Reaction score
3
I am trying to make a type of script where the vocations of orc only unjustifiedKills in orcs, elves only in elves and humans only in humans. Since for them not to unjustifiedKills their vocations, the level difference has to be 2/3 of your level.

Im try this
Code:
void Player::addUnjustifiedDead(const Player* attacked)
{
    
    uint16_t orc = getVocationId() == 17 || getVocationId() == 18 || getVocationId() == 19 || getVocationId() == 20 || getVocationId() == 21 || getVocationId() == 22;
    uint16_t elf = getVocationId() == 23 || getVocationId() == 24 || getVocationId() == 25 || getVocationId() == 26 || getVocationId() == 27;
    uint16_t humano = getVocationId() == 1 || getVocationId() == 5 || getVocationId() == 9 || getVocationId() == 28 || getVocationId() == 2 || getVocationId() == 6 || getVocationId() == 10 || getVocationId() == 29 || getVocationId() == 3 || getVocationId() == 7 || getVocationId() == 7 || getVocationId() == 12 || getVocationId() == 13 || getVocationId() == 32 || getVocationId() == 33 || getVocationId() == 4 || getVocationId() == 8 || getVocationId() == 11 || getVocationId() == 30 || getVocationId() == 14 || getVocationId() == 15 || getVocationId() == 16 || getVocationId() == 31;

    if (hasFlag(PlayerFlag_NotGainInFight) || attacked == this || g_game.getWorldType() == WORLD_TYPE_PVP_ENFORCED) {
        return;
    }


    if (orc != attacked->getVocationId()) {
        return;
    }
    if (elf != attacked->getVocationId()) {
        return;
    }
    if (humano != attacked->getVocationId()) {
        return;
    }


    sendTextMessage(MESSAGE_EVENT_ADVANCE, "Warning! The murder of " + attacked->getName() + " was not justified.");

    unjustifiedKills.emplace_back(attacked->getGUID(), time(nullptr), true);

    uint8_t dayKills = 0;
    uint8_t weekKills = 0;
    uint8_t monthKills = 0;

    for (const auto& kill : unjustifiedKills) {
        const auto diff = time(nullptr) - kill.time;
        if (diff <= 24 * 60 * 60) {
            dayKills += 1;
        }
        if (diff <= 7 * 24 * 60 * 60) {
            weekKills += 1;
        }
        if (diff <= 30 * 24 * 60 * 60) {
            monthKills += 1;
        }
    }

    if (getSkull() != SKULL_BLACK) {
        if (dayKills >= 2 * g_config.getNumber(ConfigManager::DAY_KILLS_TO_RED) || weekKills >= 2 * g_config.getNumber(ConfigManager::WEEK_KILLS_TO_RED) || monthKills >= 2 * g_config.getNumber(ConfigManager::MONTH_KILLS_TO_RED)) {
            setSkull(SKULL_BLACK);
            //start black skull time
            skullTicks = static_cast<int64_t>(g_config.getNumber(ConfigManager::BLACK_SKULL_DURATION)) * 24 * 60 * 60 * 1000;
        } else if (dayKills >= g_config.getNumber(ConfigManager::DAY_KILLS_TO_RED) || weekKills >= g_config.getNumber(ConfigManager::WEEK_KILLS_TO_RED) || monthKills >= g_config.getNumber(ConfigManager::MONTH_KILLS_TO_RED)) {
            setSkull(SKULL_RED);
            //reset red skull time
            skullTicks = static_cast<int64_t>(g_config.getNumber(ConfigManager::RED_SKULL_DURATION)) * 24 * 60 * 60 * 1000;
        }
    }

    sendUnjustifiedPoints();
}


But not sucess :l
 
You're comparing "true"/"false" with the attacked vocationid which is a number
So if attacked is an orc (id 17) and attacker is also an orc (lets say id 18), it's basically saying
Lua:
if true == 17
 
Last edited:
Back
Top