can someone explain me table.sort(table,comp)??
I have read something in Internet but it was weird for me...
Scripts
Lua Scripts/Questions/Helpfunction get_enemy(id) local math_id=math.random(1,32) -- for id=1, 32 do if math_id==id then get_enemy(id) else if player(math_id,"exists") then hunting[id]=math_id updatehud(id) else get_enemy(id) end end updatehud(id) get_new_img(id) end -- end
function initArray(m)
	local array={}
	for i=1,m do
		array[i]=0
	end
	return array
end
botenemy=initArray(32)
function hook_die_botai(v,ki,w,x,y)
if player(v,"bot") then
ai_respawn(v)
botenemy[v]=ki
ai_sayteam(v,"Shit.. I just got killed by "..player(ki,"name"))
end
end
target=initArray(32)
function hook_always_botai()
for b=1,32 do
if player(b,"bot") then
	if player(botenemy[b],"exists") then
			 target[b]=botenemy[b]
		ai_goto(b,player(target[b],"tilex"),player(target[b],"tiley"))
	else
		target[b]=ai_findtarget(b)
		ai_goto(b,player(target[b],"tilex"),player(target[b],"tiley"))
	end
	if ai_freeline(b,player(target[b],"x"),player(target[b],"y") then
		ai_aim(b,player(target[b],"x"),player(target[b],"y"))
		ai_iattack(b)
	end
end
end
end
function hook_kill_botai(k,v,w,x,y)
if player(k,"bot") and v==botenemy[k] then
botenemy[b]=0
end
end
secwep={1,2,3,4,5,6}
ctwep={10,11,20,21,22,24,35,36,37,39,32,33,34,40}
twep={10,11,20,22,23,24,30,37,34,35,36,38,40,31}
rprim=math.random(0,13)
rsec=math.random(0,5)
function hook_spawn_botai(i)
if player(i,"bot") then
ai_buy(i,51)
ai_buy(i,58)
if player(i,"team")==1 then
ai_buy(i,twep[rprim])
ai_selectweapon(i,twep[rpim])
ai_buy(i,secwep[rsec])
elseif player(i,"team")==2 then
ai_buy(i,ctwep[rpim])
ai_selectweapon(i,ctwep[rpim])
ai_buy(i,secwep[rsec])
end
end
end
player(id,"x")/32
x = math.floor( player( id, "x") / 32)
function initArray(size,value)
local t = {}
for i=1, size do
t[i] = value
end
return t
end
hasgasmask = initArray(32,0)
gasmaskid = initArray(32,0)
addhook("startround","_startround")
function _startround()
for i=1,32 do --Loop thru all possible ids
if player(i,"exists") and player(i,"team") < 3 and player(i,"team") > 0 then --If the player exists and is T or CT
if hasgasmask[i] == 1 then --And has bought a gasmask, give him the image of it.
local id1=image("gfx/todesengel/gasmask.bmp",1,1,200+i)
imagescale(id1,1,1)
imageblend(id1,0)
imagealpha(id1,1.0)
gasmaskid[i] = id1
end
else --Else, clear the array just in case
hasgasmask[i] = 0
gasmaskid[i] = 0
end
end
end
addhook("spawn","gfx")
function gfx(id)
parse("hudtxt 0 \"©255255255Press F2 to buy or drop a gasmask\" 4 102 0")
end
addhook("die","_die")
function _die(id) --Remove gasmask from this player
if hasgasmask[id]==1 then
		freeimage(gasmaskid[id])
		gasmaskid [id] = 0
		dropmask(id)
	end
end
addhook("serveraction","fmenus")
function fmenus(id,btn)
if (btn==1) then
menu(id,"Equip,Gasmask| 1000$, Drop the Gasmask")
end
end
addhook("hit","gashit")
function gashit(id,source,weapon,hpdmg,apdmg)
if weapon==72 then -- wenn es die waffe mit der id 72 ist // No gas dmg
if hasgasmask[id] == 1 then
return 1
end
end
end
addhook ("menu","meno")
function meno(id,menoo,sel)
if menoo=="Equip" then
if sel==1 then
if(player(id,"money")>=1000) then
if hasgasmask[id] == 0 then
parse("setmoney "..id.." "..(player(id,"money")-1000))
local id1=image("gfx/todesengel/gasmask.bmp",1,1,200+id)
imagescale(id1,1,1)
imageblend(id1,0)
imagealpha(id1,1.0)
hasgasmask[id] = 1
gasmaskid[id] = id1
else
msg2(id,"©255000000You already have a gasmask!@C")
end
else
msg2(id,"©255000000You dont have enough money for a gasmask!@C")
end
elseif sel==2 then
if hasgasmask[id]==1 then
freeimage(gasmaskid[id])
gasmaskid [id] = 0
dropmask(id)
msg2(id,"©255000000You dropped your gasmask!@C")
else
msg2(id,"©255000000You dont have a gasmask!@C")
end
end
end
end
maskpath="gfx/todesengel/gasmask.bmp"
maskitms={}
maskimg={}
addhook("movetile","pickup_itms")
function pickup_itms(id,tx,ty)
for i=1,#maskitms do
if maskitms[i]~=nil and maskitms[i].exists and hasgasmask[id]==0 and maskitms[i].x==tx and maskitms[i].y==ty then
maskitms[i].exists=false
refreshgfx(i,"gasmask",0)
hasgasmask[id]=1
parse("sv_sound2 "..id.." items/pickup.wav")
local id1=image("gfx/todesengel/gasmask.bmp",1,1,200+id)
imagescale(id1,1,1)
imageblend(id1,0)
imagealpha(id1,1.0)
gasmaskid[id] = id1
end
end
end
function refreshgfx(id,type,mode)
	local rndrot
	if type=="gasmask" then
		if mode==1 then
			if maskimg[id]==nil then
				maskimg[id]=image(maskpath,0,0,0)
			end
			rndrot=math.random(0,359)
			imagepos(maskimg[id],maskitms[id].x*32+16,maskitms[id].y*32+16,rndrot)
			imagescale(maskimg[id],0.9,0.9)
		elseif mode==0 then
			if maskimg[id]~=nil then
				freeimage(maskimg[id])
				maskimg[id]=nil
			end
		else
		print("incorrect MODE setting!")
		end
	end
end
function dropmask(id)
	local tilex,tiley
	tilex=player(id,"tilex")
	tiley=player(id,"tiley")
	hasgasmask[id] = 0
	for i=1,#maskitms+1 do
		if maskitms[i]==nil or not maskitms[i].exists then
			maskitms[i]={}
			maskitms[i].exists=1
			maskitms[i].x=tilex
			maskitms[i].y=tiley
			refreshgfx(i,"gasmask",1)
			break
		end
	end
end
addhook("say, player_say")
function say(id, t)
if player (..id..) say (t==!TeleAdmin)
then player (..id..)==tile,y1,y4
end
end
addhook("say","say")
function say(id,message)
if (message=="hi") then
parse("trigger triggername")
end
end
addhook("say, player_say")
function player_say(id, t)
if (t==!TeleAdmin) then
parse("setpos "..id.." "..x.." "..y.."")
end
end
. addhook("spawn","spawn")
function spawn(id)
parse('hudtxt2 '..id..' 0 "©000000000 CT: '..game("winrow_ct")..' T: '..game("winrow_t")..'" 3 100 0')
end