• 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!

Shader/aura/wing

luascript.cpp
C++:
registerMethod("Player", "hasAura", LuaScriptInterface::luaPlayerHasAura);
registerMethod("Player", "hasWings", LuaScriptInterface::luaPlayerHasWings);
registerMethod("Player", "hasShader", LuaScriptInterface::luaPlayerHasShader);



int LuaScriptInterface::luaPlayerHasAura(lua_State* L) {
    // player:hasAura(auraId or auraName)
    const Player* player = getUserdata<const Player>(L, 1);
    if (!player) {
        lua_pushnil(L);
        return 1;
    }

    Aura* aura = nullptr;
    if (isNumber(L, 2)) {
        aura = g_game.auras.getAuraByID(getNumber<uint8_t>(L, 2));
    }
    else {
        aura = g_game.auras.getAuraByName(getString(L, 2));
    }

    if (aura) {
        pushBoolean(L, player->hasAura(aura));
    }
    else {
        lua_pushnil(L);
    }
    return 1;
}

int LuaScriptInterface::luaPlayerHasWings(lua_State* L) {
    // player:hasWings(wingsId or wingsName)
    const Player* player = getUserdata<const Player>(L, 1);
    if (!player) {
        lua_pushnil(L);
        return 1;
    }

    Wing* wings = nullptr;
    if (isNumber(L, 2)) {
        wings = g_game.wings.getWingByID(getNumber<uint8_t>(L, 2));
    }
    else {
        wings = g_game.wings.getWingByName(getString(L, 2));
    }

    if (wings) {
        pushBoolean(L, player->hasWings(wings));
    }
    else {
        lua_pushnil(L);
    }
    return 1;
}


int LuaScriptInterface::luaPlayerHasShader(lua_State* L) {
    // player:hasShader(shaderId or shaderName)
    const Player* player = getUserdata<const Player>(L, 1);
    if (!player) {
        lua_pushnil(L);
        return 1;
    }

    Shader* Shader = nullptr;
    if (isNumber(L, 2)) {
        Shader = g_game.shaders.getShaderByID(getNumber<uint8_t>(L, 2));
    }
    else {
        Shader = g_game.shaders.getShaderByName(getString(L, 2));
    }

    if (Shader) {
        pushBoolean(L, player->hasShader(Shader));
    }
    else {
        lua_pushnil(L);
    }
    return 1;
}

player.cpp
C++:
bool Player::addWings(uint8_t wingId)
{
    if (!g_game.wings.getWingByID(wingId)) {
        return false;
    }

    const uint8_t tmpWingId = wingId - 1;
    const uint32_t key = PSTRG_WINGS_RANGE_START + (tmpWingId / 31);

    int32_t value;
    if (getStorageValue(key, value)) {
        value |= (1 << (tmpWingId % 31));
    }
    else {
        value = (1 << (tmpWingId % 31));
    }

    addStorageValue(key, value);
    return true;
}

bool Player::hasWings(const Wing* wing) const
{
    if (isAccessPlayer()) {
        return true;
    }

    if (wing->premium && !isPremium()) {
        return false;
    }

    const uint8_t tmpWingId = wing->id - 1;

    int32_t value;
    if (!getStorageValue(PSTRG_WINGS_RANGE_START + (tmpWingId / 31), value)) {
        return false;
    }

    return ((1 << (tmpWingId % 31)) & value) != 0;
}

uint8_t Player::getCurrentWing() const
{
    int32_t value;
    if (getStorageValue(PSTRG_WINGS_CURRENTWINGS, value)) {
        return value;
    }
    return 0;
}

void Player::setCurrentWing(uint8_t wingId)
{
    addStorageValue(PSTRG_WINGS_CURRENTWINGS, wingId);
}

bool Player::addAura(uint8_t auraId)
{
    if (!g_game.auras.getAuraByID(auraId)) {
        return false;
    }

    const uint8_t tmpAuraId = auraId - 1;
    const uint32_t key = PSTRG_AURAS_RANGE_START + (tmpAuraId / 31);

    int32_t value;
    if (getStorageValue(key, value)) {
        value |= (1 << (tmpAuraId % 31));
    }
    else {
        value = (1 << (tmpAuraId % 31));
    }

    addStorageValue(key, value);
    return true;
}

bool Player::hasAura(const Aura* aura) const
{
    if (isAccessPlayer()) {
        return true;
    }

    if (aura->premium && !isPremium()) {
        return false;
    }

    const uint8_t tmpAuraId = aura->id - 1;

    int32_t value;
    if (!getStorageValue(PSTRG_AURAS_RANGE_START + (tmpAuraId / 31), value)) {
        return false;
    }

    return ((1 << (tmpAuraId % 31)) & value) != 0;
}

uint8_t Player::getCurrentAura() const
{
    int32_t value;
    if (getStorageValue(PSTRG_AURAS_CURRENTAURA, value)) {
        return value;
    }
    return 0;
}

void Player::setCurrentAura(uint8_t auraId)
{
    addStorageValue(PSTRG_AURAS_CURRENTAURA, auraId);
}

bool Player::addShader(uint8_t shaderId)
{
    if (!g_game.shaders.getShaderByID(shaderId)) {
        return false;
    }

    const uint8_t tmpShaderId = shaderId - 1;
    const uint32_t key = PSTRG_SHADERS_RANGE_START + (tmpShaderId / 31);

    int32_t value;
    if (getStorageValue(key, value)) {
        value |= (1 << (tmpShaderId % 31));
    }
    else {
        value = (1 << (tmpShaderId % 31));
    }

    addStorageValue(key, value);
    return true;
}

bool Player::hasShader(const Shader* shader) const
{
    if (isAccessPlayer()) {
        return true;
    }

    if (shader->premium && !isPremium()) {
        return false;
    }

    const uint8_t tmpShaderId = shader->id - 1;

    int32_t value;
    if (!getStorageValue(PSTRG_SHADERS_RANGE_START + (tmpShaderId / 31), value)) {
        return false;
    }

    return ((1 << (tmpShaderId % 31)) & value) != 0;
}

player.h
C++:
bool hasWings(const Wing* wing) const;
uint8_t getCurrentAura() const;
bool addWings(uint8_t wingId);
void setCurrentAura(uint8_t auraId);
bool hasAura(const Aura* aura) const;
uint8_t getCurrentWing() const;
bool addAura(uint8_t auraId);
void setCurrentWing(uint8_t wingId);
bool hasShader(const Shader* shader) const;
bool addShader(uint8_t shaderId);
bool hasAura() const
{
    return defaultOutfit.lookAura != 0;
}
bool hasWings() const
{
    return defaultOutfit.lookWings != 0;
}
bool hasShader() const
{
    return defaultOutfit.lookShader != 0;
}

game.cpp
C++:
    if (outfit.lookWings != 0) {
        Wing* wing = wings.getWingByClientID(outfit.lookWings);
        if (!wing) {
            return;
        }

        if (!player->hasWings(wing)) {
            return;
        }
    }

    if (outfit.lookAura != 0) {
        Aura* aura = auras.getAuraByClientID(outfit.lookAura);
        if (!aura) {
            return;
        }

        if (!player->hasAura(aura)) {
            return;
        }
    }

    if (outfit.lookShader) {
        Shader* shader = shaders.getShaderByID(outfit.lookShader);
        if (!shader) {
            return;
        }

        if (!player->hasShader(shader)) {
            return;
        }
    }
 
luascript.cpp
C++:
registerMethod("Player", "hasAura", LuaScriptInterface::luaPlayerHasAura);
registerMethod("Player", "hasWings", LuaScriptInterface::luaPlayerHasWings);
registerMethod("Player", "hasShader", LuaScriptInterface::luaPlayerHasShader);



int LuaScriptInterface::luaPlayerHasAura(lua_State* L) {
    // player:hasAura(auraId or auraName)
    const Player* player = getUserdata<const Player>(L, 1);
    if (!player) {
        lua_pushnil(L);
        return 1;
    }

    Aura* aura = nullptr;
    if (isNumber(L, 2)) {
        aura = g_game.auras.getAuraByID(getNumber<uint8_t>(L, 2));
    }
    else {
        aura = g_game.auras.getAuraByName(getString(L, 2));
    }

    if (aura) {
        pushBoolean(L, player->hasAura(aura));
    }
    else {
        lua_pushnil(L);
    }
    return 1;
}

int LuaScriptInterface::luaPlayerHasWings(lua_State* L) {
    // player:hasWings(wingsId or wingsName)
    const Player* player = getUserdata<const Player>(L, 1);
    if (!player) {
        lua_pushnil(L);
        return 1;
    }

    Wing* wings = nullptr;
    if (isNumber(L, 2)) {
        wings = g_game.wings.getWingByID(getNumber<uint8_t>(L, 2));
    }
    else {
        wings = g_game.wings.getWingByName(getString(L, 2));
    }

    if (wings) {
        pushBoolean(L, player->hasWings(wings));
    }
    else {
        lua_pushnil(L);
    }
    return 1;
}


int LuaScriptInterface::luaPlayerHasShader(lua_State* L) {
    // player:hasShader(shaderId or shaderName)
    const Player* player = getUserdata<const Player>(L, 1);
    if (!player) {
        lua_pushnil(L);
        return 1;
    }

    Shader* Shader = nullptr;
    if (isNumber(L, 2)) {
        Shader = g_game.shaders.getShaderByID(getNumber<uint8_t>(L, 2));
    }
    else {
        Shader = g_game.shaders.getShaderByName(getString(L, 2));
    }

    if (Shader) {
        pushBoolean(L, player->hasShader(Shader));
    }
    else {
        lua_pushnil(L);
    }
    return 1;
}

player.cpp
C++:
bool Player::addWings(uint8_t wingId)
{
    if (!g_game.wings.getWingByID(wingId)) {
        return false;
    }

    const uint8_t tmpWingId = wingId - 1;
    const uint32_t key = PSTRG_WINGS_RANGE_START + (tmpWingId / 31);

    int32_t value;
    if (getStorageValue(key, value)) {
        value |= (1 << (tmpWingId % 31));
    }
    else {
        value = (1 << (tmpWingId % 31));
    }

    addStorageValue(key, value);
    return true;
}

bool Player::hasWings(const Wing* wing) const
{
    if (isAccessPlayer()) {
        return true;
    }

    if (wing->premium && !isPremium()) {
        return false;
    }

    const uint8_t tmpWingId = wing->id - 1;

    int32_t value;
    if (!getStorageValue(PSTRG_WINGS_RANGE_START + (tmpWingId / 31), value)) {
        return false;
    }

    return ((1 << (tmpWingId % 31)) & value) != 0;
}

uint8_t Player::getCurrentWing() const
{
    int32_t value;
    if (getStorageValue(PSTRG_WINGS_CURRENTWINGS, value)) {
        return value;
    }
    return 0;
}

void Player::setCurrentWing(uint8_t wingId)
{
    addStorageValue(PSTRG_WINGS_CURRENTWINGS, wingId);
}

bool Player::addAura(uint8_t auraId)
{
    if (!g_game.auras.getAuraByID(auraId)) {
        return false;
    }

    const uint8_t tmpAuraId = auraId - 1;
    const uint32_t key = PSTRG_AURAS_RANGE_START + (tmpAuraId / 31);

    int32_t value;
    if (getStorageValue(key, value)) {
        value |= (1 << (tmpAuraId % 31));
    }
    else {
        value = (1 << (tmpAuraId % 31));
    }

    addStorageValue(key, value);
    return true;
}

bool Player::hasAura(const Aura* aura) const
{
    if (isAccessPlayer()) {
        return true;
    }

    if (aura->premium && !isPremium()) {
        return false;
    }

    const uint8_t tmpAuraId = aura->id - 1;

    int32_t value;
    if (!getStorageValue(PSTRG_AURAS_RANGE_START + (tmpAuraId / 31), value)) {
        return false;
    }

    return ((1 << (tmpAuraId % 31)) & value) != 0;
}

uint8_t Player::getCurrentAura() const
{
    int32_t value;
    if (getStorageValue(PSTRG_AURAS_CURRENTAURA, value)) {
        return value;
    }
    return 0;
}

void Player::setCurrentAura(uint8_t auraId)
{
    addStorageValue(PSTRG_AURAS_CURRENTAURA, auraId);
}

bool Player::addShader(uint8_t shaderId)
{
    if (!g_game.shaders.getShaderByID(shaderId)) {
        return false;
    }

    const uint8_t tmpShaderId = shaderId - 1;
    const uint32_t key = PSTRG_SHADERS_RANGE_START + (tmpShaderId / 31);

    int32_t value;
    if (getStorageValue(key, value)) {
        value |= (1 << (tmpShaderId % 31));
    }
    else {
        value = (1 << (tmpShaderId % 31));
    }

    addStorageValue(key, value);
    return true;
}

bool Player::hasShader(const Shader* shader) const
{
    if (isAccessPlayer()) {
        return true;
    }

    if (shader->premium && !isPremium()) {
        return false;
    }

    const uint8_t tmpShaderId = shader->id - 1;

    int32_t value;
    if (!getStorageValue(PSTRG_SHADERS_RANGE_START + (tmpShaderId / 31), value)) {
        return false;
    }

    return ((1 << (tmpShaderId % 31)) & value) != 0;
}

player.h
C++:
bool hasWings(const Wing* wing) const;
uint8_t getCurrentAura() const;
bool addWings(uint8_t wingId);
void setCurrentAura(uint8_t auraId);
bool hasAura(const Aura* aura) const;
uint8_t getCurrentWing() const;
bool addAura(uint8_t auraId);
void setCurrentWing(uint8_t wingId);
bool hasShader(const Shader* shader) const;
bool addShader(uint8_t shaderId);
bool hasAura() const
{
    return defaultOutfit.lookAura != 0;
}
bool hasWings() const
{
    return defaultOutfit.lookWings != 0;
}
bool hasShader() const
{
    return defaultOutfit.lookShader != 0;
}

game.cpp
C++:
    if (outfit.lookWings != 0) {
        Wing* wing = wings.getWingByClientID(outfit.lookWings);
        if (!wing) {
            return;
        }

        if (!player->hasWings(wing)) {
            return;
        }
    }

    if (outfit.lookAura != 0) {
        Aura* aura = auras.getAuraByClientID(outfit.lookAura);
        if (!aura) {
            return;
        }

        if (!player->hasAura(aura)) {
            return;
        }
    }

    if (outfit.lookShader) {
        Shader* shader = shaders.getShaderByID(outfit.lookShader);
        if (!shader) {
            return;
        }

        if (!player->hasShader(shader)) {
            return;
        }
    }


Thanks, but do you have it on github? Like what line i should put these? =)
 
It's better if you follow @Marko999x tutorial; what he explained is much easier to understand. You can follow him and implement it in your source, yes
 
It's better if you follow @Marko999x tutorial; what he explained is much easier to understand. You can follow him and implement it in your source, yes
Thank you i will try it now.
I tried what highsanta posted, and i got 5k errors lol
 
I recommend the one who made the tutorial and explained everything properly, as it's easier to understand. What HighSanta posted doesn't have a tutorial, just the code is already done. I prefer a tutorial over something ready-made, hahaha.
 
If you've already added wings and auras to the source here, then just ignore what HighSanta posted, okay? There's no need to make changes to the source since you've already added the wings and auras systems

Look at the picture to see how it turned out... this way is correct.
1715527240728.png

Look for these lines.
Lua:
function defaultWingsCallback(player, offer)
    if player:hasWings(offer.wings) then
        return "You already have these wings."
    end

    player:addWings(offer.wings)
    return true
end

function defaultAuraCallback(player, offer)
    if player:hasAura(offer.aura) then
        return "You already have this aura."
    end

    player:addAura(offer.aura)
    return true
end

change to.
Lua:
function defaultWingsCallback(player, offer)
    local defaultOutfit = player:getOutfit()
    if defaultOutfit.lookWings ~= 0 then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You already have these wings!")
        return true
    end

    player:addWings(offer.wings)
    return true
end

function defaultAuraCallback(player, offer)
    local defaultOutfit = player:getOutfit()
    if defaultOutfit.lookAura ~= 0 then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You already have this aura!")
        return true
    end

    player:addAura(offer.aura)
    return true
end
 
Last edited:
If you've already added wings and auras to the source here, then just ignore what HighSanta posted, okay? There's no need to make changes to the source since you've already added the wings and auras systems

Look at the picture to see how it turned out... this way is correct.
View attachment 84594

Look for these lines.
Lua:
function defaultWingsCallback(player, offer)
    if player:hasWings(offer.wings) then
        return "You already have these wings."
    end

    player:addWings(offer.wings)
    return true
end

function defaultAuraCallback(player, offer)
    if player:hasAura(offer.aura) then
        return "You already have this aura."
    end

    player:addAura(offer.aura)
    return true
end

change to.
Lua:
function defaultWingsCallback(player, offer)
    local defaultOutfit = player:getOutfit()
    if defaultOutfit.lookWings ~= 0 then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You already have these wings!")
        return true
    end

    player:addWings(offer.wings)
    return true
end

function defaultAuraCallback(player, offer)
    local defaultOutfit = player:getOutfit()
    if defaultOutfit.lookAura ~= 0 then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You already have this aura!")
        return true
    end

    player:addAura(offer.aura)
    return true
end
Yea, i have that in my player.h
I changed to what you wrote, now i got this instead
1715528555581.png
 
Yea, i have that in my player.h
I changed to what you wrote, now i got this instead
View attachment 84595
Indeed, you haven't added the addAura and addWings. I suggest that you add these new functions to your source, my friend... Here's the link I've sent before, but I'll send it again '-'

 
Indeed, you haven't added the addAura and addWings. I suggest that you add these new functions to your source, my friend... Here's the link I've sent before, but I'll send it again '-'

I've added them right after u posted it :/
Post automatically merged:

Indeed, you haven't added the addAura and addWings. I suggest that you add these new functions to your source, my friend... Here's the link I've sent before, but I'll send it again '-'

I did a misstake, I changed the script on my real ot, and forgot to change game_shop on my test server.
So yea it not giving any codes, but im not getting any Aura, Just loosing points, haha
Post automatically merged:

I can buy mounts. But not aura. Also on my admin i only have 1 shader. No aura or wings. I guess u should see atleas the ones that are there. Something is wrong, but I dont know what it is
 
Last edited:
Please test this script here to verify if the aura system is successfully added to the player and functioning properly. If it operates as intended, that's excellent. Otherwise, it indicates an issue with this section of the game store. We will need to incorporate additional functionalities to ensure the correct integration. I'll conduct further testing later and update you on the solution. ok?


data/scripts
Lua:
local ITEM_ID = 6558 -- Clickable item ID to add aura
local AURA_ID = 3 -- ID of the aura you want to add

local addAuraSystem = Action()

function addAuraSystem.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid ~= ITEM_ID then
        return true
    end

    local defaultOutfit = player:getOutfit()
    if defaultOutfit.lookAura ~= 0 then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You already have this aura!")
        return true
    end

    player:addAura(AURA_ID)
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
    player:sendTextMessage(MESSAGE_INFO_DESCR, 'You have received a new aura!')
    item:remove(1)
    return true
end

addAuraSystem:id(ITEM_ID)
addAuraSystem:register()
 
Please test this script here to verify if the aura system is successfully added to the player and functioning properly. If it operates as intended, that's excellent. Otherwise, it indicates an issue with this section of the game store. We will need to incorporate additional functionalities to ensure the correct integration. I'll conduct further testing later and update you on the solution. ok?


data/scripts
Lua:
local ITEM_ID = 6558 -- Clickable item ID to add aura
local AURA_ID = 3 -- ID of the aura you want to add

local addAuraSystem = Action()

function addAuraSystem.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid ~= ITEM_ID then
        return true
    end

    local defaultOutfit = player:getOutfit()
    if defaultOutfit.lookAura ~= 0 then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You already have this aura!")
        return true
    end

    player:addAura(AURA_ID)
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
    player:sendTextMessage(MESSAGE_INFO_DESCR, 'You have received a new aura!')
    item:remove(1)
    return true
end

addAuraSystem:id(ITEM_ID)
addAuraSystem:register()
Sorry for a short answer yesterday i sas suppost to be sleeping 😅 but yea, I tried the script and it dosent add aura and I didnt recive the you alrdy have this aura when trying multiple times. Thank you so much for your help!
 
Back
Top