• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

isInArea

Xleniz

New Member
Joined
Jul 6, 2009
Messages
178
Reaction score
3
Location
Sweden
Can someone help me with this script? It's supposed to count people with playerstoragevalue 1, and 2 in an area.
Code:
	while h < 6 do
		fromPoz = {x = 1622, y = 1253, y = 7}
		toPoz = { x = 1635, y = 1265, y = 7}
		if(isInArea(getPlayerPosition(player[h]), fromPoz, toPoz)) then
			if(getPlayerStorageValue(player[h], 1400)==1) then
				countteamone = countteamone + 1
			end
			if(getPlayerStorageValue(player[h], 1400)==2) then
				countteamtwo = countteamtwo + 1
			end
		end
	end

error:
Code:
[21/05/2010 23:46:05] [Error - GlobalEvent Interface] 
[21/05/2010 23:46:05] In a timer event called from: 
[21/05/2010 23:46:05] data/globalevents/scripts/tp3v3.lua:onThink
[21/05/2010 23:46:05] Description: 
[21/05/2010 23:46:05] data/lib/032-position.lua:2: attempt to index local 'position' (a boolean value)
[21/05/2010 23:46:05] stack traceback:
[21/05/2010 23:46:05] 	data/lib/032-position.lua:2: in function 'isInArea'
[21/05/2010 23:46:05] 	data/globalevents/scripts/tp3v3.lua:131: in function <data/globalevents/scripts/tp3v3.lua:40>

Thx
 
Well first of all you have to use a loop on all the players online.

Example:

LUA:
fromPoz = {x = 1622, y = 1253, y = 7}
toPoz = { x = 1635, y = 1265, y = 7}
players = getPlayersOnline()
	for _, pid in ipairs(players) do
		if(isInArea(getPlayerPosition(pid), fromPoz, toPoz)) then
			if(getPlayerStorageValue(pid, 1400)==1) then
				countteamone = countteamone + 1
			end
			if(getPlayerStorageValue(pid, 1400)==2) then
				countteamtwo = countteamtwo + 1
			end
		end
	end
 
Back
Top