• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

CreatureEvent Broadcast levelup

Dilio

Owner of Project Thala
Joined
Jun 8, 2008
Messages
188
Reaction score
7
Location
London, Ontario
Decided to remake my script but make it more configurable.

Step 1 -
Go to Creaturescripts

Step 2 -
Open Creaturescripts.xml
Add:
Code:
<event type="advance" name="LevelBroadcast" script="levelbroadcast.lua"/>

Step 3 -
Go to login.lua
Add:
Code:
registerCreatureEvent(cid, "LevelBroadcast")

Step 4 -
Go to creaturescripts and create levelbroadcast.lua
Add:
Lua:
local old = 100 --Level you want broadcasted
local new = 99 --1 Level below what you want broadcasted
function onAdvance(cid, skill, oldlevel, newlevel)
	local name = getCreatureName(cid)
    if skill == SKILL__LEVEL and oldlevel < old and newlevel > new then
        doBroadcastMessage("Congratulations " .. name .. " on level " .. old .. "!", MESSAGE_STATUS_CONSOLE_RED)
    return TRUE
	end
end

Basically if you want it to broadcast at level 100, then you set the local old as 100, and the local new as 99 since that's 1 level below it. That way if someone is level 99, and reaches level 101, it will still broadcast, whereas just putting newlevel == 100, it wouldn't work.

Credits:
Me(Script)

:)
 
Seen this before, but good :thumbup:
 
Last edited:
Will work? :huh:

Lua:
local config =
{
	old = 99,
	new = 100,
        storage = 12345
}

function onAdvance(cid, skill, oldlevel, newlevel)
local name = getCreatureName(cid)
    if skill == SKILL__LEVEL and oldlevel < config.old and newlevel > config.new then
        doBroadcastMessage("Congratulations, ".. name .." advanced from level ".. config.old .." to level ".. config.new .."!", MESSAGE_STATUS_CONSOLE_RED)
	setPlayerStorageValue(cid, config.storage, 1)
    return TRUE
    end
	
    if getPlayerStorageValue(cid, config.storage) == 1 then
	doBroadcastMessage("Congratulations, ".. name .." on getting level ".. config.new .." again!", MESSAGE_STATUS_CONSOLE_RED)
    return TRUE
    end
end

If he gets the level again, it'll broadcast different message.
 
Last edited:
Will work? :huh:

Lua:
local config =
{
	old = 99,
	new = 100,
        storage = 12345
}

function onAdvance(cid, skill, oldlevel, newlevel)
local name = getCreatureName(cid)
    if skill == SKILL__LEVEL and oldlevel < config.old and newlevel > config.new then
        doBroadcastMessage("Congratulations, ".. name .." advanced from level ".. config.old .." to level ".. config.new .."!", MESSAGE_STATUS_CONSOLE_RED)
	setPlayerStorageValue(cid, config.storage, 1)
    return TRUE
    end
	
    if getPlayerStorageValue(cid, config.storage) == 1 then
	doBroadcastMessage("Congratulations, ".. name .." on getting level ".. config.new .." again!", MESSAGE_STATUS_CONSOLE_RED)
    return TRUE
    end
end

If he gets the level again, it'll broadcast different message.

It should, I have the script setup COMPLETELY differently, but it did work. Though, change it to this:
Lua:
local config =
{
	old = 99,
	new = 100,
        storage = 12345
}

function onAdvance(cid, skill, oldlevel, newlevel)
        local name = getCreatureName(cid)
        if skill == SKILL__LEVEL and oldlevel < config.old and newlevel > config.new and getPlayerStorageValue(cid, config.storage) == -1 then
                doBroadcastMessage("Congratulations, ".. name .." advanced from level ".. config.old .." to level ".. config.new .."!", MESSAGE_STATUS_CONSOLE_RED)
        	setPlayerStorageValue(cid, config.storage, 1)
        elseif skill == SKILL__LEVEL and oldlevel < config.old and newlevel > config.new and getPlayerStorageValue(cid, config.storage) == 1 then
	        doBroadcastMessage("Congratulations, ".. name .." on getting level ".. config.new .." again!", MESSAGE_STATUS_CONSOLE_RED)
        return TRUE
        end
end
 
Last edited:
Yea, I had it like that before, then changed it.

Don't need: (On the second part)
Lua:
skill == SKILL__LEVEL and oldlevel < config.old and newlevel > config.new
It will just recognize the storage.
 
Yea, I had it like that before, then changed it.

Don't need: (On the second part)
Lua:
skill == SKILL__LEVEL and oldlevel < config.old and newlevel > config.new
It will just recognize the storage.

Set it up like that because what if they die a few times, and then get level 98 then level 99 might show up with the message.
 
oh yea, true...
okay cool.
 
Yes, this script should work with 0.3.5
 
Try this one?

Lua:
local config =
{
    old = 99,
    new = 100,
    storage = 12345
}

function onAdvance(cid, skill, oldlevel, newlevel)
local name = getCreatureName(cid)
    if skill == SKILL__LEVEL and oldlevel < config.old and newlevel > config.new and getPlayerStorageValue(cid, config.storage) == -1 then
        doBroadcastMessage("Congratulations, ".. name .." advanced from level ".. config.old .." to level ".. config.new .."!", MESSAGE_STATUS_WARNING)
        setPlayerStorageValue(cid, config.storage, 1)
    elseif skill == SKILL__LEVEL and oldlevel < config.old and newlevel > config.new and getPlayerStorageValue(cid, config.storage) == 1 then
        doBroadcastMessage("Congratulations, ".. name .." on getting level ".. config.new .." again!", MESSAGE_STATUS_CONSOLE_RED)
    return TRUE
    end
end
 
I use this script but doesn't work, no errors just doesn't broadcast, i use tfs 3777
 
Back
Top