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

Lua would this work? expbonus revscritp as eventcallback

johnsamir

Advanced OT User
Joined
Oct 13, 2009
Messages
1,093
Solutions
6
Reaction score
192
Location
Nowhere
have never seen something like this this has been made by chatgpt, can a revscript works like an eventcallback?

Lua:
-- Define the name of the script
local scriptName = "PremiumExperienceBonus"

-- Define the callback function for the event
local function onGainExperience(player, experience, rawExperience, source, premium)
    if premium then
        -- Calculate the bonus experience (10% more)
        local bonusExperience = math.ceil(experience * 0.1)
        
        -- Add the bonus experience
        player:addExperience(bonusExperience)
        
        -- Inform the player about the bonus experience
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You received a 10% bonus experience for being a premium account!")
    end
end

-- Register the event callback
experiencemanager.registerCallback(scriptName, onGainExperience)
 
First of all, you have to define the type of script, which will be an action, creaturescript or globalevent?
or just a condition to increase the experience of premium players?
 
So you want give player exp bonus and give player the info about it?


Lua:
local ec = EventCallback

function ec.onGainExperience(player, source, exp, rawExp)
    if not source or source:isPlayer() then
        return exp
    end
    if player:getPremiumDays() > 0 then
        exp = exp * 1.1 -- Means 10% extra exp
    end
    return exp
end

ec:register()



local creatureEvent = CreatureEvent("onLoginLala")

function creatureEvent.onLogin(player)
    if player:getPremiumDays() > 0 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You receive 10% extra exp')
    end
    return true
end

creatureEvent:register()
 
just in data/scripts yeah
thank very much sorry to bother could yo do the same for this script? saying you have bonus enabled by beign premium or something similar? for this script please?
Lua:
local condition = Condition(CONDITION_LIGHT)
condition:setParameter(CONDITION_PARAM_LIGHT_LEVEL, 11)
condition:setParameter(CONDITION_PARAM_LIGHT_COLOR, 215)
condition:setParameter(CONDITION_PARAM_TICKS, -1)

local onLoginLux = CreatureEvent("onLoginLux")

function onLoginLux.onLogin(player)
    if player:isPremium() then
        player:addCondition(condition)
    else
    end

    return true
end

onLoginLux:register()
 
Lua:
local ec = EventCallback

function ec.onGainExperience(player, source, exp, rawExp)
    if not source or source:isPlayer() then
        return exp
    end
    if player:getPremiumDays() > 0 then -- I think player:isPremium() works too
        exp = exp * 1.1 -- Means 10% extra exp
    end
    return exp
end

ec:register()



local condition = Condition(CONDITION_LIGHT)
condition:setParameter(CONDITION_PARAM_LIGHT_LEVEL, 11)
condition:setParameter(CONDITION_PARAM_LIGHT_COLOR, 215)
condition:setParameter(CONDITION_PARAM_TICKS, -1)

local creatureEvent = CreatureEvent("onLoginLala")

function creatureEvent.onLogin(player)
    if player:getPremiumDays() > 0 then -- I think player:isPremium() works too
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You receive 10% extra exp and extra lighting for being a premium player.')
        player:addCondition(condition)
    end
    return true
end

creatureEvent:register()
 
Last edited:
don't know bro haven't tested yet i think it does work at least got no errors in console forgot to reply since im working on the website these days. my bad
 
Lua:
-- Experience Gain Event Callback
local ec = EventCallback

function ec.onGainExperience(player, source, exp, rawExp)
    if not source or source:isPlayer() then
        return exp
    end
    if player:isPremium() then -- Consistent method
        exp = exp * 1.1 -- 10% extra experience
    end
    return exp
end

ec:register()

-- Condition Setup for Extra Lighting
local condition = Condition(CONDITION_LIGHT)
condition:setParameter(CONDITION_PARAM_LIGHT_LEVEL, 11)
condition:setParameter(CONDITION_PARAM_LIGHT_COLOR, 215)
condition:setParameter(CONDITION_PARAM_TICKS, -1)

-- Creature Event for OnLogin
local creatureEvent = CreatureEvent("onLoginLala")

function creatureEvent.onLogin(player)
    if player:isPremium() then -- Consistent method
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You receive 10% extra exp and extra lighting for being a premium player.')
        player:addCondition(condition)
    end
    return true
end

creatureEvent:register()
Tested +Work 100% 1.5 860
 
Back
Top