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

Message to players in a certain place!

icaro1988

New Member
Joined
Jul 1, 2009
Messages
63
Reaction score
1
I need help with this script below!
The This script removes a particular item, and to remove this item I only wanted players who were in a certain area received a message that it was removed!

LUA:
function onThink(pos,interval)
    addEvent(removestone,1000)
    return addEvent(addstone,10*1000)
end
 

local p = {x=295, y=263, z=7} 
function removestone()
    local tile = getTileItemById(p, 1290).uid 
    doRemoveItem(tile)
    local fromPos,toPos = {x=292,y=265,z=7},{x=299,y=200,z=7} 	
    local players = getPlayersOnline()
       for _,pid in ipairs(players) do
          if isInRange(getThingPos(pid),fromPos,toPos) then
             doBroadcastMessage("Stone Removed\n\nGo Outo Now", 22)
        end
    end
	

	
end

function addstone()
    doCreateItem(1290,1,p)
    doBroadcastMessage("Stone Adicionada", 22)
	
end


Rep ++
 
Change:
PHP:
doBroadcastMessage("Stone Removed\n\nGo Outo Now", 22)
with:
PHP:
doPlayerSendTextMessage(pid,MESSAGE_INFO_DESCR, "Stone Removed\n\nGo Out Now")
:thumbup:
 
Change:
PHP:
doBroadcastMessage("Stone Removed\n\nGo Outo Now", 22)
with:
PHP:
doPlayerSendTextMessage(pid,MESSAGE_INFO_DESCR, "Stone Removed\n\nGo Out Now")
:thumbup:

Returned this error

[19/11/2010 00:54:02] [Error - GlobalEvent Interface]
[19/11/2010 00:54:02] In a timer event called from:
[19/11/2010 00:54:02] data/globalevents/scripts/stone_invasion_area.lua:onThink
[19/11/2010 00:54:02] Description:
[19/11/2010 00:54:03] data/lib/032-position.lua:2: attempt to index global 'position' (a nil value)
[19/11/2010 00:54:03] stack traceback:
[19/11/2010 00:54:03] data/lib/032-position.lua:2: in function 'isInRange'
[19/11/2010 00:54:03] data/globalevents/scripts/stone_invasion_area.lua:14: in function <data/globalevents/scripts/stone_invasion_area.lua:8>
[19/11/2010 00:54:11] > Broadcasted message: "Stone Adicionada".
 
Try this:
LUA:
function onThink(pos,interval)
    addEvent(removestone,1000)
    return addEvent(addstone,10*1000)
end
 

local p = {x=295, y=263, z=7} 
function removestone()
    local tile = getTileItemById(p, 1290).uid 
    doRemoveItem(tile)
    local fromPos,toPos = {x=292,y=265,z=7},{x=299,y=200,z=7} 	
    local players = getPlayersOnline()
       for _,pid in ipairs(players) do
          if isInRange(getThingPosition(pid),fromPos,toPos) then
             doPlayerSendTextMessage(pid,MESSAGE_INFO_DESCR, "Stone Removed\n\nGo Out Now")  
        end
    end
	

	
end

function addstone()
    doCreateItem(1290,1,p)
    doBroadcastMessage("Stone Adicionada", 22)
	
end

---------------
4:07 AM in Poland. I go sleep. I'll answer tommorow. Bye :)
 
Try this:
LUA:
function onThink(pos,interval)
    addEvent(removestone,1000)
    return addEvent(addstone,10*1000)
end
 

local p = {x=295, y=263, z=7} 
function removestone()
    local tile = getTileItemById(p, 1290).uid 
    doRemoveItem(tile)
    local fromPos,toPos = {x=292,y=265,z=7},{x=299,y=200,z=7} 	
    local players = getPlayersOnline()
       for _,pid in ipairs(players) do
          if isInRange(getThingPosition(pid),fromPos,toPos) then
             doPlayerSendTextMessage(pid,MESSAGE_INFO_DESCR, "Stone Removed\n\nGo Out Now")  
        end
    end
	

	
end

function addstone()
    doCreateItem(1290,1,p)
    doBroadcastMessage("Stone Adicionada", 22)
	
end

---------------
4:07 AM in Poland. I go sleep. I'll answer tommorow. Bye :)


Stayed the same mistake!
I'll try to see what I can do, good evening to you!
If tomorrow I get from here to straighten it, I notice!

Thanks!
 
Fix your 032-position.lua
Code:
function isInRange([B]pos[COLOR="red"]ition[/COLOR][/B], fromPosition, toPosition)
	return (position.x >= fromPosition.x and position.y >= fromPosition.y and position.z >= fromPosition.z and position.x <= toPosition.x and position.y <= toPosition.y and position.z <= toPosition.z)
end
 
Last edited:
Back
Top