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

Bless when not in pz

in globalevent/scripts/blessing.lua
Code:
function onThink(interval)
for i = 1,5 do
    if not getPlayerBlessing(cid, i) and not getTilePzInfo(getThingPos(cid)) then
        doPlayerSendTextMessage(cid,25, "You Don't Have Blessing")
        end
        return true
        end
        end

for 0.4
Code:
        <globalevent name="remove" interval="5000" event="script" value="blessing.lua"/>
for 0.3.6
Code:
        <globalevent name="remove" interval="5" event="script" value="remove.lua"/>
 
Will spam like hell.
I think the best way is to detect a change between pz zone and no pz zone and then send a message to player in sources.
 
in globalevent/scripts/blessing.lua
Code:
function onThink(interval)
for i = 1,5 do
    if not getPlayerBlessing(cid, i) and not getTilePzInfo(getThingPos(cid)) then
        doPlayerSendTextMessage(cid,25, "You Don't Have Blessing")
        end
        return true
        end
        end

for 0.4
Code:
        <globalevent name="remove" interval="5000" event="script" value="blessing.lua"/>
for 0.3.6
Code:
        <globalevent name="remove" interval="5" event="script" value="remove.lua"/>
yAKMjE.png

Btw I renamed it to blesschecker!
 
Code:
function onThink(interval)
    local storage = 9725 -- change to any empty storage in your server if this does not work.
    for _, cid in ipairs(getPlayersOnline()) do
        if getTilePzInfo(getThingPos(cid)) then
            setPlayerStorageValue(cid, storage, 1)
        end
        for i = 1,5 do
            if not getPlayerBlessing(cid, i) and not getTilePzInfo(getThingPos(cid)) and getPlayerStorageValue(cid, storage) > 0 then
                doPlayerSendTextMessage(cid,25, "Warning: You are leaving a protection zone without having blessings!")
                setPlayerStorageValue(cid, storage, 0)
            end
        end
    end
    return true
end
I'd recommend setting a low interval on this globalevent. It is not the most efficient way to do this, but it will work out fine for most lightweight servers. (C++ method is probably much, much more efficient)
 
Code:
function onThink(interval)
    local storage = 9725 -- change to any empty storage in your server if this does not work.
    for _, cid in ipairs(getPlayersOnline()) do
        if getTilePzInfo(getThingPos(cid)) then
            setPlayerStorageValue(cid, storage, 1)
        end
        for i = 1,5 do
            if not getPlayerBlessing(cid, i) and not getTilePzInfo(getThingPos(cid)) and getPlayerStorageValue(cid, storage) > 0 then
                doPlayerSendTextMessage(cid,25, "Warning: You are leaving a protection zone without having blessings!")
                setPlayerStorageValue(cid, storage, 0)
            end
        end
    end
    return true
end
I'd recommend setting a low interval on this globalevent. It is not the most efficient way to do this, but it will work out fine for most lightweight servers. (C++ method is probably much, much more efficient)


Is it possible to change how long the message will been seen?
Feels like I lagging when I use interval 0.9 can that be so?
 
Last edited:
Code:
function onThink(interval) local storage = 9725 -- change to any empty storage in your server if this does not work. for _, cid in ipairs(getPlayersOnline()) do if getTilePzInfo(getThingPos(cid)) and getPlayerStorageValue(cid, storage) <= 0 then setPlayerStorageValue(cid, storage, 1) end for i = 1,5 do if not getPlayerBlessing(cid, i) and not getTilePzInfo(getThingPos(cid)) and getPlayerStorageValue(cid, storage) > 0 then doPlayerSendTextMessage(cid,25, "Warning: You are leaving a protection zone without having blessings!") setPlayerStorageValue(cid, storage, 0) end end end return true end

Well there was a little bit of a problem with my older script, try this one. (Although I can't promise it won't lag using this one either, this type of highly repetitive global-range lua script is not efficient)
Also, I couldn't understand what you asked me in your previous post, please explain more.
 
Code:
function onThink(interval) local storage = 9725 -- change to any empty storage in your server if this does not work. for _, cid in ipairs(getPlayersOnline()) do if getTilePzInfo(getThingPos(cid)) and getPlayerStorageValue(cid, storage) <= 0 then setPlayerStorageValue(cid, storage, 1) end for i = 1,5 do if not getPlayerBlessing(cid, i) and not getTilePzInfo(getThingPos(cid)) and getPlayerStorageValue(cid, storage) > 0 then doPlayerSendTextMessage(cid,25, "Warning: You are leaving a protection zone without having blessings!") setPlayerStorageValue(cid, storage, 0) end end end return true end

Well there was a little bit of a problem with my older script, try this one. (Although I can't promise it won't lag using this one either, this type of highly repetitive global-range lua script is not efficient)
Also, I couldn't understand what you asked me in your previous post, please explain more.
You know when you go out of pz, then the massages shows for like 3 seconds is there any chance to change it to... 1sec ? or something
 
Back
Top