TalkAction Hunting graphics!

Mock

Mock the bear (MTB)
Joined
Jul 29, 2008
Messages
619
Best answers
0
Reaction score
101
Location
Brazil

Author:

Distro: TFS 0.3.x+/Matriz(svn)
Version
: 3.0
Ruire: OTAL v1.2 http://otland.net/f163/otal-open-tibia-advanced-lib-v-1-2-a-56771/


This script you install it and let this script running around 5 days and execute talkaction it will show an graphic with most hunted places!​

YES ITS TRUE LOOK AT PHOTO!


If you dont understando this photo has 10124x124 pixels, 1 pixel = 1 sqm in the map, every place where a monster dies the pixel will going to whiteblue! and changing colors look at scale on > \/ of the photo.

Well you can use .luai files to install script or in old method ^^ lest start by old method
First go to creaturescripts.xml and add this tag
Code:
<event type="kill" name="kill" event="script" value="graficos.lua"/>
Now goto login.lua and add this line in last line (before last and and before return TRUE of course.)
-- This stept you need do using and not using otal.
Lua:
registerCreatureEvent(cid, "kill")
Now in graficos.lua add it:
Lua:
function onKill(cid, target)
         if isMonster(cid) == TRUE then
            local pa = getCreaturePosition(cid)
            local file = io.open('posi.txt', "a+")
            if file then
               file:write(pa.x..","..pa.y..">")
               file:close()
            end
         end
	return TRUE
end
I will expain, when you kill an moster this script will save this posittion on posi.txt, before around 5 days this txt will be verry bigger! around 700kb~ (depend of your server :ninja:) and when you think is good execute talk and see the photo, lets install talk.
Add this tag:
PHP:
<talkaction log="yes" words="!grafico" access="5" event="script" value="grafico.lua"/>
Now in grafico.lua (talkactions) add this, and CONFIG!
Lua:
function onSay(cid, words, param)
    local q = os.clock()
    doPlayerSendTextMessage(cid, 25, 'Started in: '..(os.clock()-q)..'.')
	-- Multipiler, 10 to small server 5~2 to big server
	local multipliler = 10
	local mapx = 1024 -- Map size (x)
	local mapy = 1024 -- Map size (y)
	---Creating photo
	local im = assert(gd.createTrueColor(mapx, mapy),'could not create photo!')
	if multipliler > 10 then multipliler = 10 end
	local imgn = math.floor(0xff/multipliler)
	local colors = {
	[0] = im:colorAllocate(0,multipliler,multipliler),
	}
	-- Set all colors
	for e=1,imgn do
		if e ~= imgn then
		   colors[im:colorAllocate(0,multipliler*e,multipliler*e)] = im:colorAllocate(0,multipliler*e+multipliler,multipliler*e+multipliler)
		else
			colors[im:colorAllocate(0,multipliler*e,multipliler*e)] = im:colorAllocate(0xff,0,0)
			for kd=0,imgn do
			   if kd ~= imgn then
				  colors[im:colorAllocate(0xff,kd*multipliler,0)] = im:colorAllocate(0xff,multipliler*kd+multipliler,0)
			   else
				  colors[im:colorAllocate(0xff,kd*multipliler,0)] = im:colorAllocate(0xff,0xff,0)
				  for kk=0,imgn do
					 colors[im:colorAllocate(0xff,0xff,kk*multipliler)] = im:colorAllocate(0xff,0xff,multipliler*kk+multipliler)
				  end
			   end
			end
		end
	end
	doPlayerSendTextMessage(cid, 25, 'Colors loaded in: '..(os.clock()-q)..'.')
	--- Load file with pos
	local file = io.open('posi.txt', "r")
	local str = file:read(-1)
	doPlayerSendTextMessage(cid, 25, 'File loaded: '..(os.clock()-q)..'.')
	local nw = string.explode(str,">")
	for w=1,#nw do
	local str2 = string.explode(nw[w],',')
		 if str2 ~= nil and str2[1] ~= nil and str2[2] ~= nil then
			local n1 = tonumber(str2[1])
			local n2 = tonumber(str2[2])
			if n1 ~= nil and n2 ~= nil then
			   c = im:getPixel(n1, n2)
			   if colors[c] ~= nil then
				  im:setPixel(n1, n2,colors[c])
			   end
			end
		 end
	end
	doPlayerSendTextMessage(cid, 25, 'Colors set in: '..(os.clock()-q)..'.')
	-- Get colos table n
	na = -1
	for i,b in pairs(colors) do
		na = na+1
	end
	--- Scale
	for e=0,na do
		for x=(mapx-5),mapx do
			for y=(mapy-(na-e)),mapy do
			   c = im:getPixel(x, y)
			   if colors[c] ~= nil then
				  im:setPixel(x, y,colors[c])
			   end
			end
		end
	end
	--- Set photo
	im:png("oute.png")
	doPlayerSendTextMessage(cid, 25, 'Finished in: '..(os.clock()-q)..' seconds. Open file oute.png')
	return TRUE
end
Done! if you want test now summon MANY monsters and kill all! before say !grafico, your server will freeze by 5~6 seconds, before open your server folder and open with paint file: oute.png (paint its better to see) ;D

together of attachment has an .posi.txt file, if you want put on your server folder and execute !graficos so see it working ;D
 
Last edited:
OP
Mock

Mock

Mock the bear (MTB)
Joined
Jul 29, 2008
Messages
619
Best answers
0
Reaction score
101
Location
Brazil
its verry easy to use luaGD ;D
you can make an minimap of your server with scripts ^^
 

Synthetic_

deathzot.net
Joined
Dec 30, 2008
Messages
2,535
Best answers
0
Reaction score
568
Oh, I think I understand now, anyways rep++ for another great release:)
 
OP
Mock

Mock

Mock the bear (MTB)
Joined
Jul 29, 2008
Messages
619
Best answers
0
Reaction score
101
Location
Brazil
@SyntheticX
if you dont undestand i can teach you ^^
 

cbrm

Top Class brunet scripter
Staff member
Global Moderator
Joined
Jan 6, 2009
Messages
6,585
Best answers
3
Reaction score
852
Location
Caribbean Sea
haha, epic! good one mock :)

btw what happens if I use this on a RL map?
 
Last edited:
OP
Mock

Mock

Mock the bear (MTB)
Joined
Jul 29, 2008
Messages
619
Best answers
0
Reaction score
101
Location
Brazil
@Cybermaster
it works, its just change map size ^^
 

cbrm

Top Class brunet scripter
Staff member
Global Moderator
Joined
Jan 6, 2009
Messages
6,585
Best answers
3
Reaction score
852
Location
Caribbean Sea
heya mock, someone has to script a php page to show the map in aac :)
 
OP
Mock

Mock

Mock the bear (MTB)
Joined
Jul 29, 2008
Messages
619
Best answers
0
Reaction score
101
Location
Brazil
@Cybermaster
you can transfer this sctipt to globalevents and update every 1h photo to website :D
 
OP
Mock

Mock

Mock the bear (MTB)
Joined
Jul 29, 2008
Messages
619
Best answers
0
Reaction score
101
Location
Brazil
thanks
someone tested it? ;D
 

zakius

Enter the Ninja!
Joined
Apr 30, 2009
Messages
2,635
Best answers
0
Reaction score
61
Location
with Taiga
Hey, its great!
Working good for me, just one thing:
It will be even better if this will create one graphic file for each floor, so admin can better see where monsters are hunted and where not.
Now I'll try to make it by myself, but probably someone better can make it and release earlier.
ok, I did it.
Creaturescript:
Lua:
function onKill(cid, target)
         if isMonster(target) == TRUE then
            local pa = getCreaturePosition(cid)
            local file = io.open(getDataDir() .. 'posi'..pa.z..'.txt', "a+")
            if file then
               file:write(pa.x..","..pa.y..">")
               file:close()
            end
         end
	return TRUE
end
and talkaction
Lua:
function onSay(cid, words, param)
    local q = os.clock()
    doPlayerSendTextMessage(cid, 25, 'Started in: '..(os.clock()-q)..'.')
	-- Multipiler, 10 to small server 5~2 to big server
	local multipliler = 10
	local mapx = 2048 -- Tamanho do mapa (x)
	local mapy = 2048 -- Tamanho do mapa (y)
	---Creating photo
	local im = assert(gd.createTrueColor(mapx, mapy),'could not create photo!')
	if multipliler > 10 then multipliler = 10 end
	local imgn = math.floor(0xff/multipliler)
	local colors = {
	[0] = im:colorAllocate(0,multipliler,multipliler),
	}
	-- Set all colors
for v=1, 14 do
	for e=1,imgn do
		if e ~= imgn then
		   colors[im:colorAllocate(0,multipliler*e,multipliler*e)] = im:colorAllocate(0,multipliler*e+multipliler,multipliler*e+multipliler)
		else
			colors[im:colorAllocate(0,multipliler*e,multipliler*e)] = im:colorAllocate(0xff,0,0)
			for kd=0,imgn do
			   if kd ~= imgn then
				  colors[im:colorAllocate(0xff,kd*multipliler,0)] = im:colorAllocate(0xff,multipliler*kd+multipliler,0)
			   else
				  colors[im:colorAllocate(0xff,kd*multipliler,0)] = im:colorAllocate(0xff,0xff,0)
				  for kk=0,imgn do
					 colors[im:colorAllocate(0xff,0xff,kk*multipliler)] = im:colorAllocate(0xff,0xff,multipliler*kk+multipliler)
				  end
			   end
			end
		end
	end
	doPlayerSendTextMessage(cid, 25, 'Colors loaded in: '..(os.clock()-q)..'.')
	--- Load file with pos
	local file = io.open(getDataDir() .. 'posi'..v..'.txt', "r")
	local str = file:read(-1)
	doPlayerSendTextMessage(cid, 25, 'File loaded: '..(os.clock()-q)..'.')
	local nw = string.explode(str,">")
	for w=1,#nw do
	local str2 = string.explode(nw[w],',')
		 if str2 ~= nil and str2[1] ~= nil and str2[2] ~= nil then
			local n1 = tonumber(str2[1])
			local n2 = tonumber(str2[2])
			if n1 ~= nil and n2 ~= nil then
			   c = im:getPixel(n1, n2)
			   if colors[c] ~= nil then
				  im:setPixel(n1, n2,colors[c])
			   end
			end
		 end
	end
	doPlayerSendTextMessage(cid, 25, 'Colors set in: '..(os.clock()-q)..'.')
	-- Get colos table n
	na = -1
	for i,b in pairs(colors) do
		na = na+1
	end
	--- Scale
	for e=0,na do
		for x=(mapx-5),mapx do
			for y=(mapy-(na-e)),mapy do
			   c = im:getPixel(x, y)
			   if colors[c] ~= nil then
				  im:setPixel(x, y,colors[c])
			   end
			end
		end
	end
	--- Set photo
	im:png("oute"..v..".png")
	doPlayerSendTextMessage(cid, 25, 'Finished in: '..(os.clock()-q)..' seconds. Open file oute.png')
end
	return TRUE
end
Before using talkaction make sure that you have files posi1 to 14, all with txt extension, and in each file is at least one position saved
Without this it won't work, probably someone can fix this, or even me.
But now I'm tired
EDIT, oh, BTW my version reads and writes positions in Data dir, its cleaner than 14 txt files in main directory imo

And one important thing: auto installing scripts other than actions puts <actions> instead of correct tag at the beginning of xml file

EDIT: fixed the autoinstaller, here it is: http://otland.net/f163/fixed-autoinstaller-otlal-57037/#post579945
 
Last edited:
OP
Mock

Mock

Mock the bear (MTB)
Joined
Jul 29, 2008
Messages
619
Best answers
0
Reaction score
101
Location
Brazil
@zakius
thansk by auto installer ;D
verry good chages. its better change file to a mysql DB ;D
 
Top