Spoiler admins = {142925}
addhook ("serveraction","admin_f2")
function admin_f2(id,action)
for _, usgn in ipairs(admins) do
if player(id,"usgn") == usgn then
if action==1 then
menu(id,"Admin Hats,Hats|>")
end
end
addhook("menu", "admin_hats")
function admin_hats(id,title,button)
if title == "Admin Hats" then
if button == 1 then callmenu(id, 1) return 1 end end end end end
hattable = {
{name = "Plague Knight|>", path = "gfx/reco/Plague Knight.png"},
{name = "Skull|>", path = "gfx/hat/skull.png"},
{name = "CT|>", path = "gfx/hat/Soldado ct.png"},
{name = "TT|>", path = "gfx/hat/Soldado tt.png"},
{name = "C.America|>", path = "gfx/hat/captain america hat by spike.png"},
}
function initArray(m)
local array={}
for i=1, m do
array[i]=0
end
return array
end
currenthat = initArray(32)
hatimg = {}
function callmenu(id,page)
local pages = math.ceil(#hattable/7)
local output = "Hat Menu Page "..page
local p = pages * 7
for a = p-6, p do
if hattable[a] then
if (hattable[a].name and hattable[a].path) then
if a ~= currenthat[id] then
output = output..","..hattable[a].name
else
output = output..",("..hattable[a].name
end
else
output = output..","
end
else
output = output..","
end
end
if page == 1 then
if currenthat[id] ~= 0 then
output = output..",No hat"
else
output = output..",(No hat"
end
else
output = output..",Back Page |Page "..page-1
end
if page == pages then
if currenthat[id] ~= 0 then
output = output..",No hat"
else
output = output..",(No hat"
end
else
output = output..",Back Page |Page "..page+1
end
menu(id,output)
end
addhook("menu","hat_menu")
function hat_menu(id,title,button)
if string.sub(title,1,14) == "Hat Menu Page " then
local page = tonumber(string.sub(title,15))
local pages = math.ceil(#hattable/7)
if button >= 1 and button <= 7 then
local pr7 = (page - 1) * 7
local rsel = pr7 + button
if currenthat[id] ~= rsel then
if hatimg[id] then
freeimage(hatimg[id])
end
currenthat[id] = rsel
hatimg[id] = image(hattable[rsel].path,1,1,200+id)
end
elseif button == 8 then
if page == 1 then
if hatimg[id] then
freeimage(hatimg[id])
end
hatimg[id] = nil
currenthat[id] = 0
else
callmenu(id,page-1)
end
elseif button == 9 then
if page == pages then
if hatimg[id] then
freeimage(hatimg[id])
end
hatimg[id] = nil
currenthat[id] = 0
else
callmenu(id,page+1)
end
end
end
end
addhook("die","hat_die")
function hat_die(victim)
if hatimg[victim] then
freeimage(hatimg[victim])
end
hatimg[victim] = nil
end
addhook("leave","savedata")
function savedata(id,reason)
if player(id,"usgn") > 0 then
local f = assert(io.open("sys/lua/hats/saves/"..player(id,"usgn")..".txt","w"))
f:write(tostring(currenthat[id]))
f:close()
end
if hatimg[id] then
freeimage(hatimg[id])
end
hatimg[id] = nil
currenthat[id] = nil
end
addhook("join","loaddata")
function loaddata(id)
local loaded = false
if player(id,"usgn") > 0 then
local f = io.open("sys/lua/hats/saves/"..player(id,"usgn")..".txt","r")
if f ~= nil then
for line in f:lines() do
if line then
currenthat[id] = tonumber(line)
break
end
end
loaded = true
f:close()
end
end
if not loaded then
currenthat[id] = 0
end
end
addhook("spawn","hat_spawn")
function hat_spawn(id)
timer(1,"hat_spawn_delay",id)
end
function hat_spawn_delay(id)
id = tonumber(id)
if currenthat[id] > 0 then
hatimg[id] = image(hattable[currenthat[id]].path,1,1,200+id)
end
end
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
tazehat = {
{path = "gfx/burunpack/cowboy.png"},
	{path = "gfx/burunpack/king.png"},
	{path = "gfx/burunpack/backpacker.png"},
	{path = "gfx/burunpack/spear.png"},
	{path = "gfx/burunpack/skull.png"},
	}
hatstable = {}
function initArray(m)
local array={}
for i=1, m do
array[i]=0
end
return array
end
burun = initArray(32)
addhook("serveraction","actionn")
function actionn(id,act)
	if act == 1 then
		menu(id,"Menu,Hats")
	return 1
end
end
addhook("menu","mmenu")
function mmenu(id,title,button)
	if title == "Menu" then
		if button == 1 then
			menu(id,"hats,cowboy,king,backpacker,spear,skull,nohat")
		end
	return 1
end
if title == "hats" then
	hatincident(id,title,button) ---i guess i make mistake here
return 1
end
end
function hatincident(id,baslik,buton)
	local pages = math.ceil(#tazehat/5)
	if buton >=1 and 5<= buton then
		local idd = buton
		if burun[id] ~= idd then
			if hatstable[id] then
			 freeimage(tazehat[id])
			end
		burun[id] = idd
		hatstable[id] = image(tazehat[idd].path,1,1,200+id)
	end
	if buton == 6 then
		if hatstable[id] then
			freeimage(hatstable[id])
		end
		hatstable[id] = nil
		burun[id] = 0
	end
end
end