For each Different gun like Famas scope.png
when you add the Red Dot Sight, ACOG Scope or something
1
2
2
Left Click and Scope for the gun comes on, Click it again then comes off
edited 1×, last 16.12.11 12:23:16 pm
Left Click and Scope for the gun comes on, Click it again then comes off
Left Click and Scope for the gun comes on, Click it again then comes off
Left Click and Scope for the gun comes on, Click it again then comes off
local Scope = {} local Sprite = {} local Weapons = {} table.insert(Weapons, 30, {35, 55}) table.insert(Weapons, 32, {35, 55}) function DoSetup(id, img) 	if id ~= nil then 		Scope[id] = 0 		 		if img == true then 			if Sprite[id] ~= nil then 				for i = 1, 5 do 					freeimage(Sprite[id][i]) 				end 			end 			 			Sprite[id] = { 				image('gfx/scope.png', -1280, -960, 3, id), 				image('gfx/gui_shade.bmp', -1280, -960, 3, id), 				image('gfx/gui_shade.bmp', -1280, -960, 3, id), 				image('gfx/gui_shade.bmp', -1280, -960, 3, id), 				image('gfx/gui_shade.bmp', -1280, -960, 3, id) 			} 			 			for i = 2, 5 do 				imagecolor(Sprite[id][i], 0, 0, 0) 				imageblend(Sprite[id][i], 3) 			end 		elseif Sprite[id] ~= nil then 			for i = 1, 5 do 				imagepos(Sprite[id][i], -1280, -960, 0) 			end 		end 	else 		for i = 1, 32 do 			DoSetup(i, true) 		end 	end end DoSetup() function OnJoin(id) 	DoSetup(id) end addhook('join', 'OnJoin') function OnAlways() 	reqcld(0, 2) end addhook('always', 'OnAlways') function OnClientData(id, mode, x, y) 	if (mode == 2) then 		if Scope[id] > 0 then 			imagepos(Sprite[id][1], x, y, 0) 			imagepos(Sprite[id][2], x, y - 290, 0) 			imagepos(Sprite[id][3], x + 370, y, 0) 			imagepos(Sprite[id][4], x, y + 290, 0) 			imagepos(Sprite[id][5], x - 370, y, 0) 				 			imagescale(Sprite[id][2], 128, 38, 0) 			imagescale(Sprite[id][3], 54, 96, 0) 			imagescale(Sprite[id][4], 128, 38, 0) 			imagescale(Sprite[id][5], 54, 96, 0) 		end 	end end addhook('clientdata', 'OnClientData') function DoScope(id) 	if player(id, 'team') > 0 and player(id, 'health') > 0 and Weapons[player(id, 'weapontype')] ~= nil then 		local mode = Scope[id] + 1 		 		OnScope(id, mode) 		 		if mode > 2 then 			DoSetup(id) 		else 			Scope[id] = mode 		end 	end end function OnServerAction(id, action) 	if action == 1 then 		DoScope(id) 	end end addhook('serveraction', 'OnServerAction') function OnDie(victim, killer, weapon, x, y) 	DoSetup(victim) end addhook('die', 'OnDie') function OnSelect(id, type, mode) 	DoSetup(id) end addhook('select', 'OnSelect') function OnHit(id, source, weapon, hpdmg, apdmg) 	if Weapons[weapon] ~= nil then 		if Scope[source] == 1 then 			msg2(source, '-- 1x Zoom ('.. Weapons[weapon][1] ..')') 		elseif Scope[source] == 2 then 			msg2(source, '-- 2x Zoom ('.. Weapons[weapon][2] ..')') 		end 	end end addhook('hit', 'OnHit') function OnScope(id, mode) 	 end