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

One message in pz temple?

aero12

New Member
Joined
Aug 6, 2013
Messages
5
Reaction score
0
Hi, How to use messages when a player enters the temple, and when he leaves the temple?
in globalevents?
 
When I go around the temple, the message pops up all the time. (Movements)

function onStepIn(cid, item, pos)
if getPlayerStorageValue(cid, 2313, 1)
doPlayerSendTextMessage(cid, 22, "Welcome in pz!")
else
doPlayerSendTextMessage(cid, 22, "You are not in pz zone!")
return true
end
 
script.lua
Lua:
function onStepIn(cid, item, position, fromPosition)
    if getTilePzInfo(fromPosition) == true and getTilePzInfo(position) == false then
        doPlayerSendTextMessage(cid, 22, "You are not in pz zone!")
    else if getTilePzInfo(fromPosition) == false and getTilePzInfo(position) == true then
        doPlayerSendTextMessage(cid, 22, "Welcome in pz!")
    end
    end
    return true
end

edit moveevents.xml and add
XML:
<movevent type="StepIn" actionid="7000" event="script" value="script.lua"/>
now you will have to add aid to tiles outside and inside of pz you could only set aid to those tiles where entrance is
pzpz.png
 
Last edited:
i think it's a good approach you can use this to check if player is in pz
getTilePzInfo(getThingPosition(cid)) (returns true or false)
 
Hello.
Globalevents is counting globally. However, I want to make the globalevents count down for the player since he finds himself in the temple.
 
you can check if player is in temple(by his position or check if he is in PZ) by iterating over getPlayersOnline()/getOnlinePlayers()
 
Lua:
function getPlayersfromArea(a, b)
    local c = {}
    for x = a.x, b.x do
        for y = a.y, b.y do
            for z = a.z, b.z do
                local d = getTopCreature({x=x, y=y, z=z}).uid
                if d ~= 0 and isPlayer(d) then
                    table.insert(c, d)
                end
            end
        end
    end
    return c
end

local config = {
    area = {
        frompos = {x = 3041, y = 2986, z =9},
        topos = {x = 3052, y = 2991, z=9}
    }
}
function onThink(interval, lastExecution, thinkInterval)
    if #getPlayersfromArea(config.area.frompos, config.area.topos) < 1 then
        local players = getPlayersfromArea(config.area.frompos, config.area.topos)
        for _, player in ipairs(players) do
           
-- here you enter what you want to get working with all players which are inside specified area (you must set area frompos, topos above in config)
 -- what should be done for players inside the area

        end
    end
    return true
end

in creaturescripts event onThink
and inside script put your codes (what should happens when players are inside specific area)
and remember to change frompos (left top corner of area) and topos(right down corner of area)
 
Lua:
function getPlayersfromArea(a, b)
    local c = {}
    for x = a.x, b.x do
        for y = a.y, b.y do
            for z = a.z, b.z do
                local d = getTopCreature({x=x, y=y, z=z}).uid
                if d ~= 0 and isPlayer(d) then
                    table.insert(c, d)
                end
            end
        end
    end
    return c
end

local config = {
    area = {
        frompos = {x = 3041, y = 2986, z =9},
        topos = {x = 3052, y = 2991, z=9}
    }
}
function onThink(interval, lastExecution, thinkInterval)
    if #getPlayersfromArea(config.area.frompos, config.area.topos) < 1 then
        local players = getPlayersfromArea(config.area.frompos, config.area.topos)
        for _, player in ipairs(players) do
         
-- here you enter what you want to get working with all players which are inside specified area (you must set area frompos, topos above in config)
 -- what should be done for players inside the area

        end
    end
    return true
end

in creaturescripts event onThink
and inside script put your codes (what should happens when players are inside specific area)
and remember to change frompos (left top corner of area) and topos(right down corner of area)
If multiple players are on 1 position, this won't grab them all. (ladder/stairs, for example.)

Should use getSpectators, or loop through online players and compare positions.
 
You have substantially changed your original request. That might be why no one is replying. If these helpful people have solved your original request, make sure to detail what worked for you so that people find the answer in the forums. You should also do this by selecting an answer as the Best Answer.
 
Back
Top