Forum

> > CS2D > Scripts > Bug say
Forums overviewCS2D overview Scripts overviewLog in to reply

English Bug say

3 replies
To the start Previous 1 Next To the start

old Bug say

Hazzard
User Off Offline

Quote
Hi all, I have a problem with this script. The problem is that two messages instead of one.

IMG:https://i49.tinypic.com/kamywy.jpg


1
2
3
4
5
6
7
8
9
10
11
adminlist = {xxxxx}

addhook("say","adminsay")
function adminsay(id,txt)
	for _, usgn in ipairs(adminlist) do
	     if player(id,'usgn') == usgn then
		  msg("©255255255"..player(id,"name").." [Admin]: "..txt)
		  return 1
	     end
	end
end

I can not find the error because you end up "return 1". I'm learning to use lua but I still lack. Any help please? ! thank you very much ..

old Re: Bug say

Cure Pikachu
User Off Offline

Quote
I am pretty sure that isn't the only script that you use.
Understand that hooks that return values will conflict with one another.

old Re: Bug say

Hazzard
User Off Offline

Quote
user Cure Pikachu has written
I am pretty sure that isn't the only script that you use.
Understand that hooks that return values will conflict with one another.


You were right .. I discovered that the error was in this script.

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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
News = {}

--Instructions: say @news <message> and the game will show the message to everyone on the server.--

--Configuration--

News.Delay = 10              -- Delay between command uses (in seconds), default 10 secs. Note that you'll have to wait this time if someone else uses the command.--
News.Color = "255255255"     -- News message color (on RGB), default white.--
News.Bar_Color = "100200100" -- News bar color (on RGB), deafult green.--
News.Id = 48                 -- News message hudtxt id (0-49), change it if you get hud errors, default 48.--
News.Sound = 1               -- Sound that will be heard when using the command, values over 3 and under 1 will mute it.--
News.Tlex_Rank = 4           -- Set the tlex rank on which a player can use the say commands of this script on tlex ( 4 = moderator by default). --
News.Admin_List = {72972}         -- List of usgn ids of the admins, separated by comma (,). This list only works if the script is not used with tlex. --
News.Start = "News"          -- The word (between double quotes) witch the message will start, default "News", the longer this text is, the shorter the message can be.--

News.Counter = 0

function News.Load_Tlex()
	if not v_TLex_path then
		addhook("say","News.Say",1)
		local tab = {}
		for k,v in pairs(News.Admin_List) do
			tab[tostring(v)] = true
		end
		News.Admin_List = tab
	else
		t_commands["news"] = {"@","news",News.Tlex_Rank,News.Delay,99,1,"News.Counter==0","Error: You can't use this command at the moment.","News.Main('@news '..v_argsall) News.Counter = News.Delay","@news <message>",1}
	end
end
	
timer(100,"News.Load_Tlex")
addhook("second","News.Second")

function News.Bard(news)
	tween_alpha(news,News.Delay*100,0.0)
end

function News.Main(news)
	news,r,g,b = News.Start..": "..news:sub(7)..".",tonumber(News.Bar_Color:sub(1,3)),tonumber(News.Bar_Color:sub(4,6)),tonumber(News.Bar_Color:sub(7,9))
	parse("hudtxt "..News.Id.." \"©"..News.Color..string.gsub(news,'"',"'").."\" "..((news:len()*7)+640)..' 4 1')
	parse('hudtxtmove 0 '..News.Id..' '..(News.Delay*1000)..' '..(news:len()*(-8))..' 4')
	News.Bar=image("gfx/news_bar.png",320,12,2)
	imagecolor(News.Bar,r,g,b)
	imagealpha(News.Bar,0.0)
	imagescale(News.Bar,640,1)
	imageblend(News.Bar,1)
	tween_alpha(News.Bar,News.Delay*100,0.7)
	timer(News.Delay*1000,'freeimage',News.Bar)
	timer((News.Delay*1000)-(News.Delay*100),'News.Bard',News.Bar)
	timer(News.Delay*1000,'parse','hudtxt '..News.Id..' ""')
	if News.Sound>0 and News.Sound<=3 then
		parse("sv_sound \"news/news_sound"..News.Sound..".ogg\"")
	end
end

function News.Say(id,news)
	if news:sub(1,5) == "@news" and news:sub(7):len() ~= 0 then
		if News.Admin_List[""..player(id,"usgn")] then
			if News.Counter == 0 then
				News.Main(news)
				News.Counter = News.Delay 
			else
				msg2(id,"©255000000Error: You can't use this command at the moment.")
				return 1
			end
		else
			msg2(id,'©255000000Error: You need to be admin to use this command.')
				return 1
		end
	end
end

function News.Second()
	if News.Counter > 0 then
		News.Counter = News.Counter - 1
	end
end

As this script really is not mine, but I would like to guide me to fix it .. please..
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview