• 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++ Min level 550 + win gold on kill player

Sir Prototype

New Member
Joined
May 12, 2017
Messages
3
Reaction score
0
Hello guys, please could anyone tell me how do I set the minimum server level to 550? Do I do it through creaturescripts or player.cpp?
I'm using Canary 13.21 data


player.cpp
C++:
if (oldLevel != level) {
            std:stringstream ss;
            ss << "You were downgraded from Level " << oldLevel << " to Level " << level << '.';
            sendTextMessage(MESSAGE_EVENT_ADVANCE, ss.str());
        }

        uint64_t currLevelExp = Player::getExpForLevel(level);
        uint64_t nextLevelExp = Player::getExpForLevel(level + 1);
        if (nextLevelExp > currLevelExp) {
            levelPercent = Player::getPercentLevel(experience - currLevelExp, nextLevelExp - currLevelExp);
        } else {
            levelPercent = 0;
        }
}




and how can I set it to earn 5k gold when killing a player?
I think you could insert the line here

C++:
uint64_t Player::getGainedExperience(std::shared_ptr<Creature> attacker) const {
    if (g_configManager().getBoolean(EXPERIENCE_FROM_PLAYERS)) {
        auto attackerPlayer = attacker->getPlayer();
        if (attackerPlayer && attackerPlayer.get() != this && skillLoss && std::abs(static_cast<int32_t>(attackerPlayer->getLevel() - level)) <= g_configManager().getNumber(EXP_FROM_PLAYERS_LEVEL_RANGE)) {
            return std::max<uint64_t>(0, std::floor(getLostExperience() * getDamageRatio(attacker) * 7.75));
        }
    }
    return 0;
}




or we can do in creaturescripts converting it to canary?

Lua:
function onKill(cid, target, lastHitKiller)
if(isPlayer(target) and isPlayer(lastHitKiller)) then
doPlayerSendTextMessage(cid, 22, "Parabens, voce matou o jogador "..getCreatureName(target).." e ganhou gold")
function additem()
local aditi = doPlayerAddItem(lastHitKiller, 2160, 50)
end
addEvent(additem, 1000)
end




Thanks for all
 
Last edited:
function onKill(cid, target, lastHitKiller) if(isPlayer(target) and isPlayer(lastHitKiller)) then doPlayerSendTextMessage(cid, 22, "Parabens, voce matou o jogador "..getCreatureName(target).." e ganhou gold") function additem() local aditi = doPlayerAddItem(lastHitKiller, 2160, 50) end addEvent(additem, 1000) end
Lua:
function onKill(cid, target, lastHitKiller)
    local player = Player(cid)
    if isPlayer(target) and isPlayer(lastHitKiller) then
        local killer = Player(lastHitKiller)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "Parabéns, você matou o jogador " .. killer:getName() .. " e ganhou ouro!")
        
        local aditi = killer:addItem(2160, 50)
        if aditi then
            killer:sendTextMessage(MESSAGE_INFO_DESCR, "Você ganhou 50 de ouro!")
        else
            killer:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Você não tem espaço no inventário para receber ouro.")
        end
    end
end
 
Back
Top